array_init(return_value);
-#define CSV_ADD_ENTRY(s, es, st) { \
- int len = es - st; \
- if (len) { \
- while (isspace((int)*(unsigned char *)s)) { \
- s++; \
- len--; \
+#define CSV_ADD_ENTRY(os, es, st) { \
+ int tmp_sl = es - st; \
+ char *tmp_s=os; \
+ if (tmp_sl) { \
+ while (isspace((int)*(unsigned char *)tmp_s)) { \
+ tmp_s++; \
+ tmp_sl--; \
} \
} \
- if (len) { \
- add_next_index_stringl(return_value, s, len, 1); \
+ if (tmp_sl) { \
+ add_next_index_stringl(return_value, tmp_s, tmp_sl, 1); \
} else { \
add_next_index_string(return_value, "", 1); \
} \
--- /dev/null
+--TEST--
+Bug #26634 (fgetcsv() incorrect handling of multiline entries with backslashes)
+--FILE--
+<?php
+$fp = fopen(dirname(__FILE__).'/test4.csv', 'r');
+while ($row = fgetcsv($fp, 4096, "\t")) {
+ print_r($row);
+}
+?>
+--EXPECT--
+Array
+(
+ [0] =>
+ [1] =>
+ [2] => 971221
+ [3] => 1
+)
+Array
+(
+ [0] =>
+ [1] =>
+ [2] => 950707
+ [3] => \\
+\\
+)
+Array
+(
+ [0] =>
+ [1] =>
+ [2] => 999637
+ [3] => ERYC 250
+)