cvs: php-src /ext/standard file.c
| From: | Felipe Pena | Date: | Wed, 06 Feb 2008 02:56:49 +0000 |
| Subject: | cvs: php-src /ext/standard file.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-48364@lists.php.net to get a copy of this message | ||
felipe Wed Feb 6 02:56:49 2008 UTC
Modified files:
/php-src/ext/standard file.c
Log:
Fixed bug #42167 (fgetcsv gives different output on php6 compared to php5), #42219 (length
argument of fgetcsv() is not effective/working in PHP6)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.506&r2=1.507&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.506 php-src/ext/standard/file.c:1.507
--- php-src/ext/standard/file.c:1.506 Mon Feb 4 19:48:14 2008
+++ php-src/ext/standard/file.c Wed Feb 6 02:56:49 2008
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.506 2008/02/04 19:48:14 felipe Exp $ */
+/* $Id: file.c,v 1.507 2008/02/06 02:56:49 felipe Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -2158,7 +2158,7 @@
}
if (stream->readbuf_type == IS_STRING) {
- /* Binary mode stream needs binary delmiter/enclosure */
+ /* Binary mode stream needs binary delimiter/enclosure */
if (delimiter_type == IS_UNICODE) {
if (FAILURE == zend_unicode_to_string(ZEND_U_CONVERTER(UG(runtime_encoding_conv)),
&delimiter, &delimiter_len, (UChar*)delimiter, delimiter_len TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed converting delimiter from
unicode");
@@ -2211,7 +2211,17 @@
}
}
- buf.v = php_stream_get_line_ex(stream, stream->readbuf_type, NULL_ZSTR, 0, (len < 0) ? 0 :
len, &buf_len);
+ if (len < 0) {
+ buf.v = php_stream_get_line_ex(stream, stream->readbuf_type, NULL_ZSTR, 0, 0, &buf_len);
+ } else {
+ buf.v = stream->readbuf_type == IS_UNICODE ? emalloc(UBYTES(len + 1)) : emalloc(len + 1);
+ if (php_stream_get_line_ex(stream, stream->readbuf_type, buf, len + 1, len + 1, &buf_len)
== NULL) {
+ efree(buf.v);
+ RETVAL_FALSE;
+ goto cleanup;
+ }
+ }
+
if (!buf.v) {
/* No data */
RETVAL_FALSE;
@@ -2473,7 +2483,7 @@
case PHP_FGETCSV_FIELD_NO_ENC:
/* Check for escapes */
- if (PHP_FGETCSV_BIN_CHECK(p, e, escape, escape_len)) {
+ if (!PHP_FGETCSV_BIN_CHECK(p, e, delimiter, delimiter_len) && PHP_FGETCSV_BIN_CHECK(p,
e, escape, escape_len)) {
p += escape_len + 1;
}
@@ -2682,7 +2692,7 @@
case PHP_FGETCSV_FIELD_NO_ENC:
/* Check for escapes */
- if (PHP_FGETCSV_UNI_CHECK(p, e, escape, escape_len)) {
+ if (!PHP_FGETCSV_UNI_CHECK(p, e, delimiter, delimiter_len) && PHP_FGETCSV_UNI_CHECK(p,
e, escape, escape_len)) {
p += escape_len + 1;
}