svn: /pear/packages/File/trunk/ File/CSV.php package-File_CSV.xml tests/CSV/bug15233.csv tests/CSV/bug15233.phpt
| From: | Helgi Þormar Þorbjörnsson | Date: | Tue, 15 Mar 2011 01:58:02 +0000 |
| Subject: | svn: /pear/packages/File/trunk/ File/CSV.php package-File_CSV.xml tests/CSV/bug15233.csv tests/CSV/bug15233.phpt | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-61441@lists.php.net to get a copy of this message | ||
dufuz Tue, 15 Mar 2011 01:58:02 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=309244
Log:
Fixed Bug #15233: discoverFormat finds wrong separator [dufuz]
Bug: http://pear.php.net/bugs/15233 (unknown)
Changed paths:
U pear/packages/File/trunk/File/CSV.php
U pear/packages/File/trunk/package-File_CSV.xml
A pear/packages/File/trunk/tests/CSV/bug15233.csv
A pear/packages/File/trunk/tests/CSV/bug15233.phpt
Modified: pear/packages/File/trunk/File/CSV.php
===================================================================
--- pear/packages/File/trunk/File/CSV.php 2011-03-15 00:29:05 UTC (rev 309243)
+++ pear/packages/File/trunk/File/CSV.php 2011-03-15 01:58:02 UTC (rev 309244)
@@ -621,7 +621,7 @@
ini_set('auto_detect_line_endings', '1');
}
- // Take the first 30 lines and store the number of ocurrences
+ // Take the first 30 lines and store the number of occurrences
// for each separator in each line
$lines = '';
for ($i = 0; $i < 30 && !feof($fp) && $line = fgets($fp, 4096); $i++) {
@@ -638,8 +638,6 @@
$matches = array();
$quotes = '"\'';
- // XXX commenting this line fixes bug #11526
- // $lines = str_replace('""', '', $lines);
while ($lines != ($newLines = preg_replace('|((["\'])[^"]*(\2))|',
'\2_\2', $lines))) {
$lines = $newLines;
}
@@ -681,7 +679,7 @@
$times[0] = 0;
foreach ($res as $k => $num) {
if ($num > 0) {
- $times[$num] = isset($times[$num]) ? $times[$num] + 1 : 1;
+ $times[$num] = isset($times[$num]) ? $times[$num] + $num : 1;
}
}
arsort($times);
Modified: pear/packages/File/trunk/package-File_CSV.xml
===================================================================
--- pear/packages/File/trunk/package-File_CSV.xml 2011-03-15 00:29:05 UTC (rev 309243)
+++ pear/packages/File/trunk/package-File_CSV.xml 2011-03-15 01:58:02 UTC (rev 309244)
@@ -42,6 +42,7 @@
<license uri="http://www.opensource.org/licenses/bsd-license.php">New
BSD</license>
<notes>
* Fixed Bug #15123: Broken CSV unit tests [dufuz]
+* Fixed Bug #15233: discoverFormat finds wrong separator [dufuz]
* Fixed Bug #18049: discoverFormat bug, Find all seps that are within qoutes [dufuz]
* Fixed Bug #18111: discoverFormat: Quote not detected in short lines [dufuz]
* Fixed Bug #18358: Headers incorrectly being applied to quoted rows only [dufuz]
@@ -160,11 +161,6 @@
<min>1.7.0</min>
</pearinstaller>
<package>
- <name>PEAR</name>
- <channel>pear.php.net</channel>
- <min>1.5.3</min>
- </package>
- <package>
<name>File</name>
<channel>pear.php.net</channel>
<min>1.4.0alpha1</min>
Added: pear/packages/File/trunk/tests/CSV/bug15233.csv
===================================================================
--- pear/packages/File/trunk/tests/CSV/bug15233.csv (rev 0)
+++ pear/packages/File/trunk/tests/CSV/bug15233.csv 2011-03-15 01:58:02 UTC (rev 309244)
@@ -0,0 +1,3 @@
+test;this,here;and then
+you;go,here with this;and see the horse
+the horse provides;loads of good;fun, that is true
\ No newline at end of file
Added: pear/packages/File/trunk/tests/CSV/bug15233.phpt
===================================================================
--- pear/packages/File/trunk/tests/CSV/bug15233.phpt (rev 0)
+++ pear/packages/File/trunk/tests/CSV/bug15233.phpt 2011-03-15 01:58:02 UTC (rev 309244)
@@ -0,0 +1,25 @@
+--TEST--
+File_CSV Test Case bug15233: discoverFormat finds wrong separator
+--FILE--
+<?php
+// $Id: $
+/**
+ * Test for:
+ * - File_CSV::discoverFormat()
+ */
+
+require_once 'File/CSV.php';
+
+$file = dirname(__FILE__) . '/bug15233.csv';
+$conf = File_CSV::discoverFormat($file);
+echo "Format:\n";
+print_r($conf);
+?>
+--EXPECT--
+Format:
+Array
+(
+ [fields] => 3
+ [sep] => ;
+ [quote] =>
+)
\ No newline at end of file