diff options
author | Peter Cowburn <petercowburn@gmail.com> | 2014-11-24 20:13:14 +0000 |
---|---|---|
committer | Julien Pauli <jpauli@php.net> | 2014-12-05 10:10:10 +0100 |
commit | 557026301f0a49fcc4f358e20e0e126a1eab6fd0 (patch) | |
tree | d17bdf120e5117df4008d089430a0a4a9d266155 /ext/spl/spl_directory.c | |
parent | c65143d571b46d52b82807c0c214c4cc6af9e0fb (diff) | |
download | php-git-557026301f0a49fcc4f358e20e0e126a1eab6fd0.tar.gz |
Fixed #68479 - Added escape parameter to SplFileObject::fputcsv
Diffstat (limited to 'ext/spl/spl_directory.c')
-rw-r--r-- | ext/spl/spl_directory.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 9f4e43f727..0d7ef38607 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -2615,19 +2615,26 @@ SPL_METHOD(SplFileObject, fgetcsv) } /* }}} */ -/* {{{ proto int SplFileObject::fputcsv(array fields, [string delimiter [, string enclosure]]) +/* {{{ proto int SplFileObject::fputcsv(array fields, [string delimiter [, string enclosure [, string escape]]]) Output a field array as a CSV line */ SPL_METHOD(SplFileObject, fputcsv) { spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); char delimiter = intern->u.file.delimiter, enclosure = intern->u.file.enclosure, escape = intern->u.file.escape; - char *delim = NULL, *enclo = NULL; - int d_len = 0, e_len = 0, ret; + char *delim = NULL, *enclo = NULL, *esc = NULL; + int d_len = 0, e_len = 0, esc_len = 0, ret; zval *fields = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|ss", &fields, &delim, &d_len, &enclo, &e_len) == SUCCESS) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|sss", &fields, &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) { switch(ZEND_NUM_ARGS()) { + case 4: + if (esc_len != 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "escape must be a character"); + RETURN_FALSE; + } + escape = esc[0]; + /* no break */ case 3: if (e_len != 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "enclosure must be a character"); @@ -2945,6 +2952,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fputcsv, 0, 0, 1) ZEND_ARG_INFO(0, fields) ZEND_ARG_INFO(0, delimiter) ZEND_ARG_INFO(0, enclosure) + ZEND_ARG_INFO(0, escape) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_flock, 0, 0, 1) |