com php-src: Fix #72646: SplFileObject::getCsvControl does not return the escape character: NEWS ext/spl/spl_directory.c ext/spl/te
sts/SplFileObject_getCsvControl_basic_001.phpt
| From: | Christoph Michael Becker | Date: | Fri, 22 Jul 2016 13:24:50 +0000 |
| Subject: | com php-src: Fix #72646: SplFileObject::getCsvControl does not return the escape character: NEWS ext/spl/spl_directory.c ext/spl/te sts/SplFileObject_getCsvControl_basic_001.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93313@lists.php.net to get a copy of this message | ||
Commit: 6b116932b28b76c3f075921a0f2660f7bf5ac4e1
Author: Christoph M. Becker <cmb@php.net> Fri, 22 Jul 2016 14:55:13 +0200
Parents: fb4a6dc0f1df106dae84c9d8f3ec53cc0da7231b
Branches: PHP-5.6 PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6b116932b28b76c3f075921a0f2660f7bf5ac4e1
Log:
Fix #72646: SplFileObject::getCsvControl does not return the escape character
This has obviously been missed when adding the $escape parameter to
SplFileObject::setCsvControl() in PHP 5.3, so we catch up on this.
Bugs:
https://bugs.php.net/72646
Changed paths:
M NEWS
M ext/spl/spl_directory.c
M ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt
Diff:
diff --git a/NEWS b/NEWS
index c2cae0a..f04f36b 100644
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,8 @@ PHP NEWS
- SPL:
. Fixed bug #72122 (IteratorIterator breaks '@' error suppression). (kinglozzer)
+ . Fixed bug #72646 (SplFileObject::getCsvControl does not return the escape
+ character). (cmb)
21 Jul 2016, PHP 5.6.24
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 8613c93..c083345 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -2692,7 +2692,7 @@ SPL_METHOD(SplFileObject, fputcsv)
/* }}} */
/* {{{ proto void SplFileObject::setCsvControl([string delimiter = ',' [, string
enclosure = '"' [, string escape = '\\']]])
- Set the delimiter and enclosure character used in fgetcsv */
+ Set the delimiter, enclosure and escape character used in fgetcsv */
SPL_METHOD(SplFileObject, setCsvControl)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis()
TSRMLS_CC);
@@ -2735,11 +2735,11 @@ SPL_METHOD(SplFileObject, setCsvControl)
/* }}} */
/* {{{ proto array SplFileObject::getCsvControl()
- Get the delimiter and enclosure character used in fgetcsv */
+ Get the delimiter, enclosure and escape character used in fgetcsv */
SPL_METHOD(SplFileObject, getCsvControl)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis()
TSRMLS_CC);
- char delimiter[2], enclosure[2];
+ char delimiter[2], enclosure[2], escape[2];
array_init(return_value);
@@ -2747,9 +2747,12 @@ SPL_METHOD(SplFileObject, getCsvControl)
delimiter[1] = '\0';
enclosure[0] = intern->u.file.enclosure;
enclosure[1] = '\0';
+ escape[0] = intern->u.file.escape;
+ escape[1] = '\0';
add_next_index_string(return_value, delimiter, 1);
add_next_index_string(return_value, enclosure, 1);
+ add_next_index_string(return_value, escape, 1);
}
/* }}} */
diff --git a/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt
b/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt
index e21f08f..4e3de4b 100644
--- a/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt
+++ b/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt
@@ -6,10 +6,12 @@ $obj = New
SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
var_dump($obj->getCsvControl());
?>
---EXPECTF--
-array(2) {
+--EXPECT--
+array(3) {
[0]=>
- %unicode|string%(1) ","
+ string(1) ","
[1]=>
- %unicode|string%(1) """
+ string(1) """
+ [2]=>
+ string(1) "\"
}