iliaa Fri Dec 12 14:25:34 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/standard file.c Log: For BC reasons we need to do ltrim() on csv entries. Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.279.2.43 php-src/ext/standard/file.c:1.279.2.44 --- php-src/ext/standard/file.c:1.279.2.43 Sun Dec 7 16:55:16 2003 +++ php-src/ext/standard/file.c Fri Dec 12 14:25:33 2003 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.279.2.43 2003/12/07 21:55:16 moriyoshi Exp $ */ +/* $Id: file.c,v 1.279.2.44 2003/12/12 19:25:33 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -2266,10 +2266,25 @@ array_init(return_value); +#define CSV_ADD_ENTRY(s, es, st, copy) { \ + int len = es - st; \ + if (len) { \ + while (isspace((int)*(unsigned char *)s)) { \ + s++; \ + len--; \ + } \ + } \ + if (len) { \ + add_next_index_stringl(return_value, s, len, copy); \ + } else { \ + add_next_index_string(return_value, "", 1); \ + } \ +} \ + if (!enclosure || !(p = _php_fgetcsv_find_enclosure(s, (e - s), enclosure))) { no_enclosure: while ((p = memchr(s, delimiter, (e - s)))) { - add_next_index_stringl(return_value, s, (p - s), 1); + CSV_ADD_ENTRY(s, p, s, 1); s = p + 1; } } else { @@ -2278,7 +2293,7 @@ enclosure: /* handle complete fields before the enclosure */ while (s < p && (p2 = memchr(s, delimiter, (p - s)))) { - add_next_index_stringl(return_value, s, (p2 - s), 1); + CSV_ADD_ENTRY(s, p2, s, 1); s = p2 + 1; } @@ -2322,7 +2337,7 @@ buf2_len += (p - p2); } buf2[buf2_len] = '\0'; - add_next_index_stringl(return_value, buf2, buf2_len, 0); + CSV_ADD_ENTRY(buf2, buf2_len, 0, 0); if (!(p = _php_fgetcsv_find_enclosure(s, (e - s), enclosure))) { goto no_enclosure; @@ -2342,12 +2357,12 @@ enclosure_done: s = e = NULL; buf2[buf2_len] = '\0'; - add_next_index_stringl(return_value, buf2, buf2_len, 0); + CSV_ADD_ENTRY(buf2, buf2_len, 0, 0); } } if (s < e) { - add_next_index_stringl(return_value, s, (e - s), 1); + CSV_ADD_ENTRY(s, e, s, 1); } efree(buf); }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php