[PHP-CVS] cvs: php-src /ext/standard dns.c math.c
dmitry Mon Sep 25 06:59:02 2006 UTC Modified files: /php-src/ext/standard dns.c math.c Log: ZTS fix http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dns.c?r1=1.81&r2=1.82&diff_format=u Index: php-src/ext/standard/dns.c diff -u php-src/ext/standard/dns.c:1.81 php-src/ext/standard/dns.c:1.82 --- php-src/ext/standard/dns.c:1.81 Mon Sep 25 02:27:24 2006 +++ php-src/ext/standard/dns.c Mon Sep 25 06:59:02 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: dns.c,v 1.81 2006/09/25 02:27:24 pollita Exp $ */ +/* $Id: dns.c,v 1.82 2006/09/25 06:59:02 dmitry Exp $ */ /* {{{ includes */ #include "php.h" @@ -370,7 +370,7 @@ #endif /* {{{ php_parserr */ -static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, zval **subarray) +static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, zval **subarray TSRMLS_DC) { u_short type, class, dlen; u_long ttl; @@ -781,7 +781,7 @@ while (an-- && cp && cp < end) { zval *retval; - cp = php_parserr(cp, &answer, type_to_fetch, store_results, &retval); + cp = php_parserr(cp, &answer, type_to_fetch, store_results, &retval TSRMLS_CC); if (retval != NULL && store_results) { add_next_index_zval(return_value, retval); } @@ -798,7 +798,7 @@ while (ns-- > 0 && cp && cp < end) { zval *retval = NULL; - cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, &retval); + cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, &retval TSRMLS_CC); if (retval != NULL) { add_next_index_zval(authns, retval); } @@ -810,7 +810,7 @@ while (ar-- > 0 && cp && cp < end) { zval *retval = NULL; - cp = php_parserr(cp, &answer, DNS_T_ANY, 1, &retval); + cp = php_parserr(cp, &answer, DNS_T_ANY, 1, &retval TSRMLS_CC); if (retval != NULL) { add_next_index_zval(addtl, retval); } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/math.c?r1=1.137&r2=1.138&diff_format=u Index: php-src/ext/standard/math.c diff -u php-src/ext/standard/math.c:1.137 php-src/ext/standard/math.c:1.138 --- php-src/ext/standard/math.c:1.137 Sun Sep 24 17:59:40 2006 +++ php-src/ext/standard/math.c Mon Sep 25 06:59:02 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: math.c,v 1.137 2006/09/24 17:59:40 pollita Exp $ */ +/* $Id: math.c,v 1.138 2006/09/25 06:59:02 dmitry Exp $ */ #include "php.h" #include "php_math.h" @@ -59,7 +59,7 @@ return; } - convert_scalar_to_number(value); + convert_scalar_to_number(value TSRMLS_CC); if (Z_TYPE_P(value) == IS_DOUBLE) { RETURN_DOUBLE(fabs(Z_DVAL_P(value))); @@ -84,7 +84,7 @@ return; } - convert_scalar_to_number(value); + convert_scalar_to_number(value TSRMLS_CC); if (Z_TYPE_P(value) == IS_DOUBLE) { RETURN_DOUBLE(ceil(Z_DVAL_P(value))); @@ -106,7 +106,7 @@ return; } - convert_scalar_to_number(value); + convert_scalar_to_number(value TSRMLS_CC); if (Z_TYPE_P(value) == IS_DOUBLE) { RETURN_DOUBLE(floor(Z_DVAL_P(value))); @@ -130,7 +130,7 @@ return; } - convert_scalar_to_number(value); + convert_scalar_to_number(value TSRMLS_CC); switch (Z_TYPE_P(value)) { case IS_LONG: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard type.c
Actually, the whole if() thing can be replaced by convert_to_text(). -Andrei On Sep 24, 2006, at 6:37 PM, Sara Golemon wrote: + } else if (!strcasecmp(new_type, "string")) { /* runtime string type */ + if (UG(unicode)) { + convert_to_unicode(*var); + } else { + convert_to_string(*var); + } + } else if (!strcasecmp(new_type, "unicode")) { /* explicit unicode cast */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard dns.c
pollita Mon Sep 25 02:27:24 2006 UTC Modified files: /php-src/ext/standard dns.c Log: PHP6 Updates and some very minor feature add in dns_get_record() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dns.c?r1=1.80&r2=1.81&diff_format=u Index: php-src/ext/standard/dns.c diff -u php-src/ext/standard/dns.c:1.80 php-src/ext/standard/dns.c:1.81 --- php-src/ext/standard/dns.c:1.80 Tue Sep 19 10:38:31 2006 +++ php-src/ext/standard/dns.c Mon Sep 25 02:27:24 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: dns.c,v 1.80 2006/09/19 10:38:31 dmitry Exp $ */ +/* $Id: dns.c,v 1.81 2006/09/25 02:27:24 pollita Exp $ */ /* {{{ includes */ #include "php.h" @@ -119,22 +119,21 @@ static char *php_gethostbyaddr(char *ip); static char *php_gethostbyname(char *name); -/* {{{ proto string gethostbyaddr(string ip_address) +/* {{{ proto string gethostbyaddr(string ip_address) U Get the Internet host name corresponding to a given IP address */ PHP_FUNCTION(gethostbyaddr) { - zval **arg; - char *addr; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - ZEND_WRONG_PARAM_COUNT(); - } + char *addr; + int addr_len; + char *hostname; - convert_to_string_ex(arg); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addr, &addr_len) == FAILURE) { + return; + } - addr = php_gethostbyaddr(Z_STRVAL_PP(arg)); + hostname = php_gethostbyaddr(addr); - if (addr == NULL) { + if (hostname == NULL) { #if HAVE_IPV6 && HAVE_INET_PTON php_error_docref(NULL TSRMLS_CC, E_WARNING, "Address is not a valid IPv4 or IPv6 address"); #else @@ -142,10 +141,7 @@ #endif RETVAL_FALSE; } else { - RETVAL_RT_STRING(addr, 0); - if (UG(unicode)) { - efree(addr); - } + RETVAL_RT_STRING(hostname, ZSTR_AUTOFREE); } } /* }}} */ @@ -185,42 +181,39 @@ } /* }}} */ -/* {{{ proto string gethostbyname(string hostname) +/* {{{ proto string gethostbyname(string hostname) U Get the IP address corresponding to a given Internet host name */ PHP_FUNCTION(gethostbyname) { - zval **arg; - char *tmp; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - ZEND_WRONG_PARAM_COUNT(); + char *hostname; + int hostname_len; + char *addr; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &hostname_len) == FAILURE) { + return; } - convert_to_string_ex(arg); + addr = php_gethostbyname(hostname); - tmp = php_gethostbyname(Z_STRVAL_PP(arg)); - RETVAL_RT_STRING(tmp, 0); - if (UG(unicode)) { - efree(tmp); - } + RETVAL_RT_STRING(addr, ZSTR_AUTOFREE); } /* }}} */ -/* {{{ proto array gethostbynamel(string hostname) +/* {{{ proto array gethostbynamel(string hostname) U Return a list of IP addresses that a given hostname resolves to. */ PHP_FUNCTION(gethostbynamel) { - zval **arg; + char *hostname; + int hostname_len; struct hostent *hp; struct in_addr in; int i; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - ZEND_WRONG_PARAM_COUNT(); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &hostname_len) == FAILURE) { + return; } - convert_to_string_ex(arg); - hp = gethostbyname(Z_STRVAL_PP(arg)); + hp = gethostbyname(hostname); if (hp == NULL || hp->h_addr_list == NULL) { RETURN_FALSE; } @@ -229,7 +222,7 @@ for (i = 0 ; hp->h_addr_list[i] != 0 ; i++) { in = *(struct in_addr *) hp->h_addr_list[i]; - add_next_index_rt_string(return_value, inet_ntoa(in), 1); + add_next_index_rt_string(return_value, inet_ntoa(in), ZSTR_DUPLICATE); } } /* }}} */ @@ -254,55 +247,41 @@ #if HAVE_RES_SEARCH && !(defined(__BEOS__)||defined(PHP_WIN32) || defined(NETWARE)) -/* {{{ proto int dns_check_record(string host [, string type]) +/* {{{ proto int dns_check_record(string host [, string type]) U Check DNS records corresponding to a given Internet host name or IP address */ PHP_FUNCTION(dns_check_record) { - zval **arg1, **arg2; - int type, i; #ifndef MAXPACKET #define MAXPACKET 8192 /* max packet size used internally by BIND */ #endif u_char ans[MAXPACKET]; + char *hostname, *rectype = NULL; + int hostname_len, rectype_len = 0; + int type = T_MX, i; - switch (ZEND_NUM_ARGS()) { - case 1: - if (zend_get_parameters_ex(1, &arg1) == FAILUR
[PHP-CVS] cvs: php-src /ext/standard type.c
pollita Mon Sep 25 01:37:55 2006 UTC Modified files: /php-src/ext/standard type.c Log: Make settype($var, 'string'); behave like $var = (string)$var; e.g. switch between (binary) and (unicode) depending on UG(unicode) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/type.c?r1=1.43&r2=1.44&diff_format=u Index: php-src/ext/standard/type.c diff -u php-src/ext/standard/type.c:1.43 php-src/ext/standard/type.c:1.44 --- php-src/ext/standard/type.c:1.43Sun Sep 24 18:23:47 2006 +++ php-src/ext/standard/type.c Mon Sep 25 01:37:55 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: type.c,v 1.43 2006/09/24 18:23:47 pollita Exp $ */ +/* $Id: type.c,v 1.44 2006/09/25 01:37:55 pollita Exp $ */ #include "php.h" #include "php_incomplete_class.h" @@ -113,9 +113,15 @@ convert_to_double(*var); } else if (!strcasecmp(new_type, "double")) { /* deprecated */ convert_to_double(*var); - } else if (!strcasecmp(new_type, "string")) { + } else if (!strcasecmp(new_type, "binary")) { /* explicit binary cast */ convert_to_string(*var); - } else if (!strcasecmp(new_type, "unicode")) { + } else if (!strcasecmp(new_type, "string")) { /* runtime string type */ + if (UG(unicode)) { + convert_to_unicode(*var); + } else { + convert_to_string(*var); + } + } else if (!strcasecmp(new_type, "unicode")) { /* explicit unicode cast */ convert_to_unicode(*var); } else if (!strcasecmp(new_type, "array")) { convert_to_array(*var); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard crc32.c crypt.c
pollita Mon Sep 25 01:33:57 2006 UTC Modified files: /php-src/ext/standard crc32.c crypt.c Log: Flag a couple more unicode ready functions http://cvs.php.net/viewvc.cgi/php-src/ext/standard/crc32.c?r1=1.19&r2=1.20&diff_format=u Index: php-src/ext/standard/crc32.c diff -u php-src/ext/standard/crc32.c:1.19 php-src/ext/standard/crc32.c:1.20 --- php-src/ext/standard/crc32.c:1.19 Thu Feb 9 15:48:18 2006 +++ php-src/ext/standard/crc32.cMon Sep 25 01:33:57 2006 @@ -16,13 +16,13 @@ +--+ */ -/* $Id: crc32.c,v 1.19 2006/02/09 15:48:18 pajoye Exp $ */ +/* $Id: crc32.c,v 1.20 2006/09/25 01:33:57 pollita Exp $ */ #include "php.h" #include "basic_functions.h" #include "crc32.h" -/* {{{ proto string crc32(string str) +/* {{{ proto string crc32(string str) U Calculate the crc32 polynomial of a string */ PHP_NAMED_FUNCTION(php_if_crc32) { @@ -31,7 +31,7 @@ php_uint32 crcinit = 0; register php_uint32 crc; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &p, &nr) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &p, &nr) == FAILURE) { return; } crc = crcinit^0x; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/crypt.c?r1=1.63&r2=1.64&diff_format=u Index: php-src/ext/standard/crypt.c diff -u php-src/ext/standard/crypt.c:1.63 php-src/ext/standard/crypt.c:1.64 --- php-src/ext/standard/crypt.c:1.63 Sun Jan 1 13:09:55 2006 +++ php-src/ext/standard/crypt.cMon Sep 25 01:33:57 2006 @@ -17,7 +17,7 @@ | Rasmus Lerdorf <[EMAIL PROTECTED]> | +--+ */ -/* $Id: crypt.c,v 1.63 2006/01/01 13:09:55 sniper Exp $ */ +/* $Id: crypt.c,v 1.64 2006/09/25 01:33:57 pollita Exp $ */ #include #include "php.h" @@ -111,8 +111,8 @@ } } -/* {{{ proto string crypt(string str [, string salt]) - Encrypt a string */ +/* {{{ proto string crypt(string str [, string salt]) U + Hash a string */ PHP_FUNCTION(crypt) { char salt[PHP_MAX_SALT_LEN+1]; @@ -124,7 +124,7 @@ available (passing always 2-character salt). At least for glibc6.1 */ memset(&salt[1], '$', PHP_MAX_SALT_LEN-1); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S", &str, &str_len, &salt_in, &salt_in_len) == FAILURE) { return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard base64.c
pollita Mon Sep 25 01:27:11 2006 UTC Modified files: /php-src/ext/standard base64.c Log: base64 functions are basicly binary-only ops http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.48&r2=1.49&diff_format=u Index: php-src/ext/standard/base64.c diff -u php-src/ext/standard/base64.c:1.48 php-src/ext/standard/base64.c:1.49 --- php-src/ext/standard/base64.c:1.48 Mon Jun 26 22:17:42 2006 +++ php-src/ext/standard/base64.c Mon Sep 25 01:27:11 2006 @@ -15,7 +15,7 @@ | Author: Jim Winstead <[EMAIL PROTECTED]> | +--+ */ -/* $Id: base64.c,v 1.48 2006/06/26 22:17:42 bjori Exp $ */ +/* $Id: base64.c,v 1.49 2006/09/25 01:27:11 pollita Exp $ */ #include @@ -203,7 +203,7 @@ } /* }}} */ -/* {{{ proto string base64_encode(string str) +/* {{{ proto string base64_encode(string str) U Encodes string using MIME base64 algorithm */ PHP_FUNCTION(base64_encode) { @@ -211,7 +211,7 @@ unsigned char *result; int str_len, ret_length; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str, &str_len) == FAILURE) { return; } result = php_base64_encode((unsigned char*)str, str_len, &ret_length); @@ -224,7 +224,7 @@ /* }}} */ -/* {{{ proto string base64_decode(string str[, bool strict]) +/* {{{ proto string base64_decode(string str[, bool strict]) U Decodes string using MIME base64 algorithm */ PHP_FUNCTION(base64_decode) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/zip php_zip.c /ext/zip/tests 38943.phpt
pajoye Sun Sep 24 22:27:57 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/zip/tests 38943.phpt Modified files: /php-src/ext/zipphp_zip.c Log: - #38943, properties in extended class cannot be set - use zend_object_std_init instead of a manual initialisation http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.14&r2=1.1.2.15&diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.14 php-src/ext/zip/php_zip.c:1.1.2.15 --- php-src/ext/zip/php_zip.c:1.1.2.14 Fri Sep 15 12:12:25 2006 +++ php-src/ext/zip/php_zip.c Sun Sep 24 22:27:57 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.14 2006/09/15 12:12:25 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.15 2006/09/24 22:27:57 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -526,7 +526,6 @@ intern = emalloc(sizeof(ze_zip_object)); memset(&intern->zo, 0, sizeof(zend_object)); - intern->zo.ce = class_type; intern->za = NULL; intern->buffers = NULL; @@ -534,8 +533,7 @@ intern->buffers_cnt = 0; intern->prop_handler = &zip_prop_handlers; - ALLOC_HASHTABLE(intern->zo.properties); - zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_object_std_init(&intern->zo, class_type TSRMLS_CC); zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); @@ -1895,7 +1893,6 @@ memcpy(&zip_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); zip_object_handlers.clone_obj = NULL; zip_object_handlers.get_property_ptr_ptr = php_zip_get_property_ptr_ptr; - zip_object_handlers.write_property = NULL; zip_object_handlers.get_properties = php_zip_get_properties; zip_object_handlers.read_property = php_zip_read_property; @@ -1987,7 +1984,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "Zip", "enabled"); - php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.1.2.14 2006/09/15 12:12:25 pajoye Exp $"); + php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.1.2.15 2006/09/24 22:27:57 pajoye Exp $"); php_info_print_table_row(2, "Zip version", "2.0.0"); php_info_print_table_row(2, "Libzip version", "0.7.1"); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/38943.phpt?view=markup&rev=1.1 Index: php-src/ext/zip/tests/38943.phpt +++ php-src/ext/zip/tests/38943.phpt --TEST-- #38943, properties in extended class cannot be set --SKIPIF-- --FILE-- testarray[] = 1; var_dump($this->testarray); } } $z = new myZip; $z->testp = "foobar"; var_dump($z); ?> --EXPECTF-- array(1) { [0]=> int(1) } object(myZip)#1 (%d) { ["test:private"]=> int(0) ["testp"]=> string(6) "foobar" ["testarray:private"]=> array(1) { [0]=> int(1) } ["status"]=> int(0) ["statusSys"]=> int(0) ["numFiles"]=> int(0) ["filename"]=> string(0) "" ["comment"]=> string(0) "" } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/zip php_zip.c /ext/zip/tests 38943.phpt
pajoye Sun Sep 24 22:27:20 2006 UTC Added files: /php-src/ext/zip/tests 38943.phpt Modified files: /php-src/ext/zipphp_zip.c Log: - #38943, properties in extended class cannot be set - use zend_object_std_init instead of a manual initialisation http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.15&r2=1.16&diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.15 php-src/ext/zip/php_zip.c:1.16 --- php-src/ext/zip/php_zip.c:1.15 Fri Sep 15 12:10:50 2006 +++ php-src/ext/zip/php_zip.c Sun Sep 24 22:27:19 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.15 2006/09/15 12:10:50 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.16 2006/09/24 22:27:19 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -506,7 +506,6 @@ intern = emalloc(sizeof(ze_zip_object)); memset(&intern->zo, 0, sizeof(zend_object)); - intern->zo.ce = class_type; intern->za = NULL; intern->buffers = NULL; @@ -514,8 +513,7 @@ intern->buffers_cnt = 0; intern->prop_handler = &zip_prop_handlers; - ALLOC_HASHTABLE(intern->zo.properties); - zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_object_std_init(&intern->zo, class_type TSRMLS_CC); zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); @@ -1870,7 +1868,6 @@ memcpy(&zip_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); zip_object_handlers.clone_obj = NULL; zip_object_handlers.get_property_ptr_ptr = php_zip_get_property_ptr_ptr; - zip_object_handlers.write_property = NULL; zip_object_handlers.get_properties = php_zip_get_properties; zip_object_handlers.read_property = php_zip_read_property; @@ -1962,7 +1959,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "Zip", "enabled"); - php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.15 2006/09/15 12:10:50 pajoye Exp $"); + php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.16 2006/09/24 22:27:19 pajoye Exp $"); php_info_print_table_row(2, "Zip version", "2.0.0"); php_info_print_table_row(2, "Libzip version", "0.7.1"); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/38943.phpt?view=markup&rev=1.1 Index: php-src/ext/zip/tests/38943.phpt +++ php-src/ext/zip/tests/38943.phpt --TEST-- #38943, properties in extended class cannot be set --SKIPIF-- --FILE-- testarray[] = 1; var_dump($this->testarray); } } $z = new myZip; $z->testp = "foobar"; var_dump($z); ?> --EXPECTF-- array(1) { [0]=> int(1) } object(myZip)#1 (%d) { ["test:private"]=> int(0) ["testp"]=> string(6) "foobar" ["testarray:private"]=> array(1) { [0]=> int(1) } ["status"]=> int(0) ["statusSys"]=> int(0) ["numFiles"]=> int(0) ["filename"]=> string(0) "" ["comment"]=> string(0) "" } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard type.c
For settype(), should we treat 'string' the same as (string) casting, i.e. make it depend on u.s switch? -Andrei On Sep 24, 2006, at 11:23 AM, Sara Golemon wrote: pollita Sun Sep 24 18:23:47 2006 UTC Modified files: /php-src/ext/standard type.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/type.c? r1=1.42&r2=1.43&diff_format=u Index: php-src/ext/standard/type.c diff -u php-src/ext/standard/type.c:1.42 php-src/ext/standard/ type.c:1.43 --- php-src/ext/standard/type.c:1.42Fri Mar 17 23:00:20 2006 +++ php-src/ext/standard/type.c Sun Sep 24 18:23:47 2006 @@ -16,12 +16,12 @@ +- -+ */ -/* $Id: type.c,v 1.42 2006/03/17 23:00:20 andrei Exp $ */ +/* $Id: type.c,v 1.43 2006/09/24 18:23:47 pollita Exp $ */ #include "php.h" #include "php_incomplete_class.h" -/* {{{ proto string gettype(mixed var) +/* {{{ proto string gettype(mixed var) U Returns the type of the variable */ PHP_FUNCTION(gettype) { @@ -91,7 +91,7 @@ } /* }}} */ -/* {{{ proto bool settype(mixed var, string type) +/* {{{ proto bool settype(mixed var, string type) U Set the type of the variable */ PHP_FUNCTION(settype) { @@ -115,6 +115,8 @@ convert_to_double(*var); } else if (!strcasecmp(new_type, "string")) { convert_to_string(*var); + } else if (!strcasecmp(new_type, "unicode")) { + convert_to_unicode(*var); } else if (!strcasecmp(new_type, "array")) { convert_to_array(*var); } else if (!strcasecmp(new_type, "object")) { @@ -136,7 +138,7 @@ } /* }}} */ -/* {{{ proto int intval(mixed var [, int base]) +/* {{{ proto int intval(mixed var [, int base]) U Get the integer value of a variable using the optional base for the conversion */ PHP_FUNCTION(intval) { @@ -168,22 +170,21 @@ } /* }}} */ -/* {{{ proto float floatval(mixed var) +/* {{{ proto float floatval(mixed var) U Get the float value of a variable */ PHP_FUNCTION(floatval) { - zval **num; + double retval; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &retval) == FAILURE) { + return; } - RETVAL_ZVAL(*num, 1, 0); - convert_to_double(return_value); + RETURN_DOUBLE(retval); } /* }}} */ -/* {{{ proto string strval(mixed var) +/* {{{ proto string strval(mixed var) U Get the string value of a variable */ PHP_FUNCTION(strval) { @@ -211,29 +212,41 @@ static void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type) { - zval **arg; + zval *arg; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only one argument expected"); - RETURN_FALSE; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { + return; } - if (Z_TYPE_PP(arg) == type) { + if (Z_TYPE_P(arg) == type) { if (type == IS_OBJECT) { zend_class_entry *ce; - if(Z_OBJ_HT_PP(arg)->get_class_entry == NULL) { - /* if there's no get_class_entry it's not a PHP object, so it can't be INCOMPLETE_CLASS */ + + if(Z_OBJ_HT_P(arg)->get_class_entry == NULL) { +/* if there's no get_class_entry it's not a PHP object, so it can't be INCOMPLETE_CLASS */ RETURN_TRUE; } - ce = Z_OBJCE_PP(arg); - /* FIXME: Unicode support??? */ - if (!strcmp(ce->name.s, INCOMPLETE_CLASS)) { - RETURN_FALSE; + ce = Z_OBJCE_P(arg); + + if (ce->name_length != sizeof(INCOMPLETE_CLASS) - 1) { +/* We can get away with this because INCOMPLETE_CLASS is ascii and has a 1:1 relationship with unicode */ + RETURN_TRUE; + } else if (UG(unicode)) { +U_STRING_DECL(uIncompleteClass, INCOMPLETE_CLASS, sizeof (INCOMPLETE_CLASS) - 1); +U_STRING_INIT(uIncompleteClass, INCOMPLETE_CLASS, sizeof (INCOMPLETE_CLASS) - 1); + +if (!memcmp(ce->name.u, uIncompleteClass, UBYTES(sizeof (INCOMPLETE_CLASS { + RETURN_FALSE; + } + } else { +if (!memcmp(ce->name.s, INCOMPLETE_CLASS, sizeof (INCOMPLETE_CLASS))) { + RETURN_FALSE; + } } } if (type == IS_RESOURCE) { char *type_name; - type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(arg) TSRMLS_CC); + type_name = zend_rsrc
[PHP-CVS] cvs: php-src /ext/standard fsock.c
pollita Sun Sep 24 21:43:42 2006 UTC Modified files: /php-src/ext/standard fsock.c Log: PHP6 Update: fsockopen/psfockopen http://cvs.php.net/viewvc.cgi/php-src/ext/standard/fsock.c?r1=1.123&r2=1.124&diff_format=u Index: php-src/ext/standard/fsock.c diff -u php-src/ext/standard/fsock.c:1.123 php-src/ext/standard/fsock.c:1.124 --- php-src/ext/standard/fsock.c:1.123 Sun Feb 19 04:29:41 2006 +++ php-src/ext/standard/fsock.cSun Sep 24 21:43:41 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: fsock.c,v 1.123 2006/02/19 04:29:41 andi Exp $ */ +/* $Id: fsock.c,v 1.124 2006/09/24 21:43:41 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -98,7 +98,7 @@ if (zerrstr && errstr) { /* no need to dup; we need to efree buf anyway */ zval_dtor(zerrstr); - ZVAL_STRING(zerrstr, errstr, 0); + ZVAL_RT_STRING(zerrstr, errstr, ZSTR_AUTOFREE); } else if (!zerrstr && errstr) { efree(errstr); @@ -116,14 +116,14 @@ /* }}} */ -/* {{{ proto resource fsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]]) +/* {{{ proto resource fsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]]) U Open Internet or Unix domain socket connection */ PHP_FUNCTION(fsockopen) { php_fsockopen_stream(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } /* }}} */ -/* {{{ proto resource pfsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]]) +/* {{{ proto resource pfsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]]) U Open persistent Internet or Unix domain socket connection */ PHP_FUNCTION(pfsockopen) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Sun Sep 24 21:40:45 2006 UTC Modified files: /php-src/ext/standard file.c Log: PHP6 Updates for rmdir/mkdir/rename http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.456&r2=1.457&diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.456 php-src/ext/standard/file.c:1.457 --- php-src/ext/standard/file.c:1.456 Sun Sep 24 20:33:14 2006 +++ php-src/ext/standard/file.c Sun Sep 24 21:40:44 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.456 2006/09/24 20:33:14 pollita Exp $ */ +/* $Id: file.c,v 1.457 2006/09/24 21:40:44 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1485,6 +1485,7 @@ /* {{{ php_mkdir */ +/* DEPRECATED APIs: Use php_stream_mkdir() instead */ PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC) { int ret; @@ -1506,43 +1507,65 @@ } /* }}} */ -/* {{{ proto bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]]) +/* {{{ proto bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]]) U Create a directory */ PHP_FUNCTION(mkdir) { + char *dir; + int dir_len; + zend_uchar dir_type; zval *zcontext = NULL; long mode = 0777; - int dir_len; zend_bool recursive = 0; - char *dir; php_stream_context *context; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lbr", &dir, &dir_len, &mode, &recursive, &zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|lbr", &dir, &dir_len, &dir_type, &mode, &recursive, &zcontext) == FAILURE) { RETURN_FALSE; } context = php_stream_context_from_zval(zcontext, 0); - RETURN_BOOL(php_stream_mkdir(dir, mode, (recursive ? PHP_STREAM_MKDIR_RECURSIVE : 0) | REPORT_ERRORS, context)); + if (dir_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, &dir, &dir_len, (UChar*)dir, dir_len, REPORT_ERRORS, context)) { + RETURN_FALSE; + } + } + + RETVAL_BOOL(php_stream_mkdir(dir, mode, (recursive ? PHP_STREAM_MKDIR_RECURSIVE : 0) | REPORT_ERRORS, context)); + + if (dir_type == IS_UNICODE) { + efree(dir); + } } /* }}} */ -/* {{{ proto bool rmdir(string dirname[, resource context]) +/* {{{ proto bool rmdir(string dirname[, resource context]) U Remove a directory */ PHP_FUNCTION(rmdir) { char *dir; + int dir_len; + zend_uchar dir_type; zval *zcontext = NULL; php_stream_context *context; - int dir_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &dir, &dir_len, &zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|r", &dir, &dir_len, &dir_type, &zcontext) == FAILURE) { RETURN_FALSE; } context = php_stream_context_from_zval(zcontext, 0); - RETURN_BOOL(php_stream_rmdir(dir, REPORT_ERRORS, context)); + if (dir_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, &dir, &dir_len, (UChar*)dir, dir_len, REPORT_ERRORS, context)) { + RETURN_FALSE; + } + } + + RETVAL_BOOL(php_stream_rmdir(dir, REPORT_ERRORS, context)); + + if (dir_type == IS_UNICODE) { + efree(dir); + } } /* }}} */ @@ -1639,40 +1662,65 @@ } /* }}} */ -/* {{{ proto bool rename(string old_name, string new_name[, resource context]) +/* {{{ proto bool rename(string old_name, string new_name[, resource context]) U Rename a file */ PHP_FUNCTION(rename) { char *old_name, *new_name; int old_name_len, new_name_len; + zend_uchar old_name_type, new_name_type; + zend_uchar free_old_name = 0, free_new_name = 0; zval *zcontext = NULL; php_stream_wrapper *wrapper; php_stream_context *context; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|r", &old_name, &old_name_len, &new_name, &new_name_len, &zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "tt|r", &old_name, &old_name_len, &old_name_type, &new_name, &new_name_len, &new_name_type, &zcontext) == FAILURE) { RETURN_FALSE; } + context = php_stream_context_from_zval(zcontext, 0); + RETVAL_FALSE; + + if (old_name_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, &old_name, &old_name_len, (UChar*)old_name, old_name_len, REPORT_ERRORS, context)) { + goto rename_cleanup; + } + free_old_name = 1; + } + wrapper = php_stream_locate_url_wrapper(old_name, NULL, 0 TSRMLS_CC); if (!wrapper || !wrapper->wops) { ph
[PHP-CVS] cvs: php-src /ext/standard file.c /main php_streams.h /main/streams plain_wrapper.c streams.c
pollita Sun Sep 24 20:33:14 2006 UTC Modified files: /php-src/main php_streams.h /php-src/main/streams streams.c plain_wrapper.c /php-src/ext/standard file.c Log: PHP6 Updates for popen() and related functionality http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.114&r2=1.115&diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.114 php-src/main/php_streams.h:1.115 --- php-src/main/php_streams.h:1.114Fri Sep 22 19:54:30 2006 +++ php-src/main/php_streams.h Sun Sep 24 20:33:14 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_streams.h,v 1.114 2006/09/22 19:54:30 pollita Exp $ */ +/* $Id: php_streams.h,v 1.115 2006/09/24 20:33:14 pollita Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -561,6 +561,7 @@ PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC); PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC); PHPAPI int php_unregister_url_stream_wrapper_volatile(char *protocol TSRMLS_DC); +PHPAPI void php_stream_fix_encoding(php_stream *stream, const char *mode, php_stream_context *context TSRMLS_DC); PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char **path_for_open, int options TSRMLS_DC); PHPAPI void *php_stream_locate_eol(php_stream *stream, zstr zbuf, int buf_len TSRMLS_DC); http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.136&r2=1.137&diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.136 php-src/main/streams/streams.c:1.137 --- php-src/main/streams/streams.c:1.136Fri Sep 22 19:54:30 2006 +++ php-src/main/streams/streams.c Sun Sep 24 20:33:14 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.136 2006/09/22 19:54:30 pollita Exp $ */ +/* $Id: streams.c,v 1.137 2006/09/24 20:33:14 pollita Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -2285,6 +2285,32 @@ } /* }}} */ +/* {{{ php_stream_fix_encoding + * Sets read/write encoding on a stream based on the fopen mode, context options, and INI setting */ +PHPAPI void php_stream_fix_encoding(php_stream *stream, const char *mode, php_stream_context *context TSRMLS_DC) +{ + /* Output encoding on text mode streams defaults to utf8 unless specified in context parameter */ + if (stream && strchr(mode, 't') && UG(unicode)) { + /* Only apply implicit unicode.to. filter if the wrapper didn't do it for us */ + if ((php_stream_filter_product(&stream->writefilters, IS_UNICODE) == IS_UNICODE) && + (strchr(mode, 'w') || strchr(mode, 'a') || strchr(mode, '+'))) { + char *encoding = (context && context->output_encoding) ? context->output_encoding : UG(stream_encoding); + + /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via context params */ + php_stream_encoding_apply(stream, 1, encoding, UG(from_error_mode), UG(from_subst_char)); + } + + /* Only apply implicit unicode.from. filter if the wrapper didn't do it for us */ + if ((stream->readbuf_type == IS_STRING) && (strchr(mode, 'r') || strchr(mode, '+'))) { + char *encoding = (context && context->input_encoding) ? context->input_encoding : UG(stream_encoding); + + /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via context params */ + php_stream_encoding_apply(stream, 0, encoding, UG(to_error_mode), NULL); + } + } +} +/* }}} */ + /* {{{ php_stream_open_wrapper_ex */ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) @@ -2387,25 +2413,8 @@ } } - /* Output encoding on text mode streams defaults to utf8 unless specified in context parameter */ - if (stream && strchr(implicit_mode, 't') && UG(unicode)) { - /* Only apply implicit unicode.to. filter if the wrapper didn't do it for us */ - if ((php_stream_filter_product(&stream->writefilters, IS_UNICODE) == IS_UNICODE) && - (strchr(implicit_mode, 'w') || strchr(implicit_mode, 'a') || strchr(implicit_mode, '+'))) { - char *encoding = (context && context->output_encoding) ? context->output_encoding : UG(stream_encoding); - /* UTODO: (Maybe?) Allow overriding the default error ha
[PHP-CVS] cvs: php-src /ext/standard file.c
pollita Sun Sep 24 20:01:29 2006 UTC Modified files: /php-src/ext/standard file.c Log: PHP6 Update for get_meta_tags() -- What a silly function... http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.454&r2=1.455&diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.454 php-src/ext/standard/file.c:1.455 --- php-src/ext/standard/file.c:1.454 Fri Sep 22 21:48:33 2006 +++ php-src/ext/standard/file.c Sun Sep 24 20:01:29 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.454 2006/09/22 21:48:33 pollita Exp $ */ +/* $Id: file.c,v 1.455 2006/09/24 20:01:29 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -353,7 +353,7 @@ #define PHP_META_UNSAFE ".\\+*?[^]$() " -/* {{{ proto array get_meta_tags(string filename [, bool use_include_path]) +/* {{{ proto array get_meta_tags(string filename [, bool use_include_path]) U Extracts all meta tag content attributes from a file and returns an array */ PHP_FUNCTION(get_meta_tags) @@ -383,7 +383,7 @@ RETURN_FALSE; } } - md.stream = php_stream_open_wrapper(filename, "rb", + md.stream = php_stream_open_wrapper(filename, "rt", (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL); if (filename_type == IS_UNICODE) { @@ -393,6 +393,31 @@ RETURN_FALSE; } + if (md.stream->readbuf_type == IS_UNICODE) { + /* Either stream auto-applied encoding (which http:// wrapper does do) +* Or the streams layer unicodified it for us */ + zval *filterparams; + php_stream_filter *filter; + + /* Be lazy and convert contents to utf8 again +* This could be made more efficient by detecting if +* it's being upconverted from utf8 and cancelling all conversion +* rather than reconverting, but this is a silly function anyway */ + + MAKE_STD_ZVAL(filterparams); + array_init(filterparams); + add_ascii_assoc_long(filterparams, "error_mode", UG(from_error_mode)); + add_ascii_assoc_unicode(filterparams, "subst_char", UG(from_subst_char), 1); + filter = php_stream_filter_create("unicode.to.utf8", filterparams, 0 TSRMLS_CC); + zval_ptr_dtor(&filterparams); + + if (!filter) { + php_stream_close(md.stream); + RETURN_FALSE; + } + php_stream_filter_append(&md.stream->readfilters, filter); + } + array_init(return_value); tok_last = TOK_EOF; @@ -473,9 +498,9 @@ /* For BC */ php_strtolower(name, strlen(name)); if (have_content) { - add_assoc_string(return_value, name, value, 0); + add_assoc_utf8_string(return_value, name, value, 0); } else { - add_assoc_string(return_value, name, "", 1); + add_assoc_utf8_string(return_value, name, "", 1); } efree(name); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard type.c
pollita Sun Sep 24 18:23:47 2006 UTC Modified files: /php-src/ext/standard type.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/type.c?r1=1.42&r2=1.43&diff_format=u Index: php-src/ext/standard/type.c diff -u php-src/ext/standard/type.c:1.42 php-src/ext/standard/type.c:1.43 --- php-src/ext/standard/type.c:1.42Fri Mar 17 23:00:20 2006 +++ php-src/ext/standard/type.c Sun Sep 24 18:23:47 2006 @@ -16,12 +16,12 @@ +--+ */ -/* $Id: type.c,v 1.42 2006/03/17 23:00:20 andrei Exp $ */ +/* $Id: type.c,v 1.43 2006/09/24 18:23:47 pollita Exp $ */ #include "php.h" #include "php_incomplete_class.h" -/* {{{ proto string gettype(mixed var) +/* {{{ proto string gettype(mixed var) U Returns the type of the variable */ PHP_FUNCTION(gettype) { @@ -91,7 +91,7 @@ } /* }}} */ -/* {{{ proto bool settype(mixed var, string type) +/* {{{ proto bool settype(mixed var, string type) U Set the type of the variable */ PHP_FUNCTION(settype) { @@ -115,6 +115,8 @@ convert_to_double(*var); } else if (!strcasecmp(new_type, "string")) { convert_to_string(*var); + } else if (!strcasecmp(new_type, "unicode")) { + convert_to_unicode(*var); } else if (!strcasecmp(new_type, "array")) { convert_to_array(*var); } else if (!strcasecmp(new_type, "object")) { @@ -136,7 +138,7 @@ } /* }}} */ -/* {{{ proto int intval(mixed var [, int base]) +/* {{{ proto int intval(mixed var [, int base]) U Get the integer value of a variable using the optional base for the conversion */ PHP_FUNCTION(intval) { @@ -168,22 +170,21 @@ } /* }}} */ -/* {{{ proto float floatval(mixed var) +/* {{{ proto float floatval(mixed var) U Get the float value of a variable */ PHP_FUNCTION(floatval) { - zval **num; + double retval; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &retval) == FAILURE) { + return; } - RETVAL_ZVAL(*num, 1, 0); - convert_to_double(return_value); + RETURN_DOUBLE(retval); } /* }}} */ -/* {{{ proto string strval(mixed var) +/* {{{ proto string strval(mixed var) U Get the string value of a variable */ PHP_FUNCTION(strval) { @@ -211,29 +212,41 @@ static void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type) { - zval **arg; + zval *arg; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only one argument expected"); - RETURN_FALSE; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { + return; } - if (Z_TYPE_PP(arg) == type) { + if (Z_TYPE_P(arg) == type) { if (type == IS_OBJECT) { zend_class_entry *ce; - if(Z_OBJ_HT_PP(arg)->get_class_entry == NULL) { - /* if there's no get_class_entry it's not a PHP object, so it can't be INCOMPLETE_CLASS */ + + if(Z_OBJ_HT_P(arg)->get_class_entry == NULL) { + /* if there's no get_class_entry it's not a PHP object, so it can't be INCOMPLETE_CLASS */ RETURN_TRUE; } - ce = Z_OBJCE_PP(arg); - /* FIXME: Unicode support??? */ - if (!strcmp(ce->name.s, INCOMPLETE_CLASS)) { - RETURN_FALSE; + ce = Z_OBJCE_P(arg); + + if (ce->name_length != sizeof(INCOMPLETE_CLASS) - 1) { + /* We can get away with this because INCOMPLETE_CLASS is ascii and has a 1:1 relationship with unicode */ + RETURN_TRUE; + } else if (UG(unicode)) { + U_STRING_DECL(uIncompleteClass, INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1); + U_STRING_INIT(uIncompleteClass, INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1); + + if (!memcmp(ce->name.u, uIncompleteClass, UBYTES(sizeof(INCOMPLETE_CLASS { + RETURN_FALSE; + } + } else { + if (!memcmp(ce->name.s, INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS))) { + RETURN_FALSE; + } } } if (type == IS_RESOURCE) { char *type_name; - type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(arg
[PHP-CVS] cvs: php-src /ext/imap config.m4 php_imap.c
iliaa Sun Sep 24 18:06:53 2006 UTC Modified files: /php-src/ext/imap php_imap.c config.m4 Log: MFB: Fixed bug #38941 (imap extension does not compile against new version of the imap library). http://cvs.php.net/viewvc.cgi/php-src/ext/imap/php_imap.c?r1=1.223&r2=1.224&diff_format=u Index: php-src/ext/imap/php_imap.c diff -u php-src/ext/imap/php_imap.c:1.223 php-src/ext/imap/php_imap.c:1.224 --- php-src/ext/imap/php_imap.c:1.223 Tue Sep 5 11:24:23 2006 +++ php-src/ext/imap/php_imap.c Sun Sep 24 18:06:53 2006 @@ -26,7 +26,7 @@ | PHP 4.0 updates: Zeev Suraski <[EMAIL PROTECTED]> | +--+ */ -/* $Id: php_imap.c,v 1.223 2006/09/05 11:24:23 tony2001 Exp $ */ +/* $Id: php_imap.c,v 1.224 2006/09/24 18:06:53 iliaa Exp $ */ #define IMAP41 @@ -75,7 +75,11 @@ void rfc822_date(char *date); char *cpystr(const char *str); char *cpytxt(SIZEDTEXT *dst, char *text, unsigned long size); +#ifndef HAVE_NEW_MIME2TEXT long utf8_mime2text(SIZEDTEXT *src, SIZEDTEXT *dst); +#else +long utf8_mime2text (SIZEDTEXT *src, SIZEDTEXT *dst, long flags); +#endif unsigned long find_rightmost_bit(unsigned long *valptr); void fs_give(void **block); void *fs_get(size_t size); http://cvs.php.net/viewvc.cgi/php-src/ext/imap/config.m4?r1=1.69&r2=1.70&diff_format=u Index: php-src/ext/imap/config.m4 diff -u php-src/ext/imap/config.m4:1.69 php-src/ext/imap/config.m4:1.70 --- php-src/ext/imap/config.m4:1.69 Sun May 29 23:16:41 2005 +++ php-src/ext/imap/config.m4 Sun Sep 24 18:06:53 2006 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4,v 1.69 2005/05/29 23:16:41 sniper Exp $ +dnl $Id: config.m4,v 1.70 2006/09/24 18:06:53 iliaa Exp $ dnl AC_DEFUN([IMAP_INC_CHK],[if test -r "$i$1/c-client.h"; then @@ -114,6 +114,11 @@ AC_EGREP_HEADER(mail_fetch_overview_sequence, $IMAP_INC_DIR/mail.h, [ AC_DEFINE(HAVE_IMAP2004,1,[ ]) ]) + +dnl Check for new version of the utf8_mime2text() function +AC_EGREP_HEADER(mail_append_set, $IMAP_INC_DIR/mail.h, [ + AC_DEFINE(HAVE_NEW_MIME2TEXT,1,[ ]) +]) dnl Check for c-client version 2001 old_CPPFLAGS=$CPPFLAGS -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) / NEWS /ext/imap config.m4 php_imap.c
iliaa Sun Sep 24 18:06:38 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/imap php_imap.c config.m4 /php-srcNEWS Log: Fixed bug #38941 (imap extension does not compile against new version of the imap library). http://cvs.php.net/viewvc.cgi/php-src/ext/imap/php_imap.c?r1=1.208.2.7.2.5&r2=1.208.2.7.2.6&diff_format=u Index: php-src/ext/imap/php_imap.c diff -u php-src/ext/imap/php_imap.c:1.208.2.7.2.5 php-src/ext/imap/php_imap.c:1.208.2.7.2.6 --- php-src/ext/imap/php_imap.c:1.208.2.7.2.5 Tue Sep 5 11:24:49 2006 +++ php-src/ext/imap/php_imap.c Sun Sep 24 18:06:37 2006 @@ -26,7 +26,7 @@ | PHP 4.0 updates: Zeev Suraski <[EMAIL PROTECTED]> | +--+ */ -/* $Id: php_imap.c,v 1.208.2.7.2.5 2006/09/05 11:24:49 tony2001 Exp $ */ +/* $Id: php_imap.c,v 1.208.2.7.2.6 2006/09/24 18:06:37 iliaa Exp $ */ #define IMAP41 @@ -75,7 +75,11 @@ void rfc822_date(char *date); char *cpystr(const char *str); char *cpytxt(SIZEDTEXT *dst, char *text, unsigned long size); +#ifndef HAVE_NEW_MIME2TEXT long utf8_mime2text(SIZEDTEXT *src, SIZEDTEXT *dst); +#else +long utf8_mime2text (SIZEDTEXT *src, SIZEDTEXT *dst, long flags); +#endif unsigned long find_rightmost_bit(unsigned long *valptr); void fs_give(void **block); void *fs_get(size_t size); http://cvs.php.net/viewvc.cgi/php-src/ext/imap/config.m4?r1=1.69&r2=1.69.4.1&diff_format=u Index: php-src/ext/imap/config.m4 diff -u php-src/ext/imap/config.m4:1.69 php-src/ext/imap/config.m4:1.69.4.1 --- php-src/ext/imap/config.m4:1.69 Sun May 29 23:16:41 2005 +++ php-src/ext/imap/config.m4 Sun Sep 24 18:06:37 2006 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4,v 1.69 2005/05/29 23:16:41 sniper Exp $ +dnl $Id: config.m4,v 1.69.4.1 2006/09/24 18:06:37 iliaa Exp $ dnl AC_DEFUN([IMAP_INC_CHK],[if test -r "$i$1/c-client.h"; then @@ -114,6 +114,11 @@ AC_EGREP_HEADER(mail_fetch_overview_sequence, $IMAP_INC_DIR/mail.h, [ AC_DEFINE(HAVE_IMAP2004,1,[ ]) ]) + +dnl Check for new version of the utf8_mime2text() function +AC_EGREP_HEADER(mail_append_set, $IMAP_INC_DIR/mail.h, [ + AC_DEFINE(HAVE_NEW_MIME2TEXT,1,[ ]) +]) dnl Check for c-client version 2001 old_CPPFLAGS=$CPPFLAGS http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.261&r2=1.2027.2.547.2.262&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.261 php-src/NEWS:1.2027.2.547.2.262 --- php-src/NEWS:1.2027.2.547.2.261 Wed Sep 20 13:42:50 2006 +++ php-src/NEWSSun Sep 24 18:06:37 2006 @@ -6,6 +6,8 @@ - Fixed mess with CGI/CLI -d option (now it works with cgi; constants are working exactly like in php.ini; with FastCGI -d affects all requests). (Dmitry) +- Fixed bug #38941 (imap extension does not compile against new version of + the imap library). (Ilia) - Fixed bug #38844 (curl_easy_strerror() is defined only since cURL 7.12.0). (Tony) - Fixed bug #38623 (leaks in a tricky code with switch() and exceptions). -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard math.c
pollita Sun Sep 24 17:59:41 2006 UTC Modified files: /php-src/ext/standard math.c Log: PHP6 Updates w/ minor refactoring http://cvs.php.net/viewvc.cgi/php-src/ext/standard/math.c?r1=1.136&r2=1.137&diff_format=u Index: php-src/ext/standard/math.c diff -u php-src/ext/standard/math.c:1.136 php-src/ext/standard/math.c:1.137 --- php-src/ext/standard/math.c:1.136 Sun Aug 27 18:20:39 2006 +++ php-src/ext/standard/math.c Sun Sep 24 17:59:40 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: math.c,v 1.136 2006/08/27 18:20:39 bjori Exp $ */ +/* $Id: math.c,v 1.137 2006/09/24 17:59:40 pollita Exp $ */ #include "php.h" #include "php_math.h" @@ -49,108 +49,100 @@ val = !zend_isnan(tmp_val) ? tmp_val : val; \ } \ -/* {{{ proto int abs(int number) +/* {{{ proto int abs(int number) U Return the absolute value of the number */ PHP_FUNCTION(abs) { - zval **value; + zval *value; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &value) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &value) == FAILURE) { + return; } - convert_scalar_to_number_ex(value); + convert_scalar_to_number(value); - if (Z_TYPE_PP(value) == IS_DOUBLE) { - RETURN_DOUBLE(fabs(Z_DVAL_PP(value))); - } else if (Z_TYPE_PP(value) == IS_LONG) { - if (Z_LVAL_PP(value) == LONG_MIN) { + if (Z_TYPE_P(value) == IS_DOUBLE) { + RETURN_DOUBLE(fabs(Z_DVAL_P(value))); + } else if (Z_TYPE_P(value) == IS_LONG) { + if (Z_LVAL_P(value) == LONG_MIN) { RETURN_DOUBLE(-(double)LONG_MIN); } else { - RETURN_LONG(Z_LVAL_PP(value) < 0 ? -Z_LVAL_PP(value) : Z_LVAL_PP(value)); + RETURN_LONG(Z_LVAL_P(value) < 0 ? -Z_LVAL_P(value) : Z_LVAL_P(value)); } } RETURN_FALSE; } /* }}} */ -/* {{{ proto float ceil(float number) +/* {{{ proto float ceil(float number) U Returns the next highest integer value of the number */ PHP_FUNCTION(ceil) { - zval **value; + zval *value; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &value) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &value) == FAILURE) { + return; } - convert_scalar_to_number_ex(value); + convert_scalar_to_number(value); - if (Z_TYPE_PP(value) == IS_DOUBLE) { - RETURN_DOUBLE(ceil(Z_DVAL_PP(value))); - } else if (Z_TYPE_PP(value) == IS_LONG) { - convert_to_double_ex(value); - RETURN_DOUBLE(Z_DVAL_PP(value)); + if (Z_TYPE_P(value) == IS_DOUBLE) { + RETURN_DOUBLE(ceil(Z_DVAL_P(value))); + } else if (Z_TYPE_P(value) == IS_LONG) { + RETURN_DOUBLE((double)Z_LVAL_P(value)); } RETURN_FALSE; } /* }}} */ -/* {{{ proto float floor(float number) +/* {{{ proto float floor(float number) U Returns the next lowest integer value from the number */ PHP_FUNCTION(floor) { - zval **value; + zval *value; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &value) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &value) == FAILURE) { + return; } - convert_scalar_to_number_ex(value); + convert_scalar_to_number(value); - if (Z_TYPE_PP(value) == IS_DOUBLE) { - RETURN_DOUBLE(floor(Z_DVAL_PP(value))); - } else if (Z_TYPE_PP(value) == IS_LONG) { - convert_to_double_ex(value); - RETURN_DOUBLE(Z_DVAL_PP(value)); + if (Z_TYPE_P(value) == IS_DOUBLE) { + RETURN_DOUBLE(floor(Z_DVAL_P(value))); + } else if (Z_TYPE_P(value) == IS_LONG) { + RETURN_DOUBLE((double)Z_LVAL_P(value)); } RETURN_FALSE; } /* }}} */ -/* {{{ proto float round(float number [, int precision]) +/* {{{ proto float round(float number [, int precision]) U Returns the number rounded to specified precision */ PHP_FUNCTION(round) { - zval **value, **precision; - int places = 0; + zval *value; + long places = 0; double return_val; - if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2 || - zend_get_parameters_ex(ZEND_NUM_ARGS(), &value, &precision) == FAILURE) { - WRONG_PARAM_COUNT; - } - - if (ZEND_NUM_ARGS() == 2) { - convert_to_long_ex(precision); - places = (int) Z_LVAL_PP(precision); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z
[PHP-CVS] cvs: php-src /ext/standard md5.c sha1.c
pollita Sun Sep 24 17:09:46 2006 UTC Modified files: /php-src/ext/standard md5.c sha1.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/md5.c?r1=1.46&r2=1.47&diff_format=u Index: php-src/ext/standard/md5.c diff -u php-src/ext/standard/md5.c:1.46 php-src/ext/standard/md5.c:1.47 --- php-src/ext/standard/md5.c:1.46 Thu Mar 2 13:12:45 2006 +++ php-src/ext/standard/md5.c Sun Sep 24 17:09:46 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: md5.c,v 1.46 2006/03/02 13:12:45 dmitry Exp $ */ +/* $Id: md5.c,v 1.47 2006/09/24 17:09:46 pollita Exp $ */ /* * md5.c - Copyright 1997 Lachlan Roche @@ -38,7 +38,7 @@ *md5str = '\0'; } -/* {{{ proto string md5(string str, [ bool raw_output]) +/* {{{ proto string md5(string str, [ bool raw_output]) U Calculate the md5 hash of a string */ PHP_NAMED_FUNCTION(php_if_md5) { @@ -49,7 +49,7 @@ PHP_MD5_CTX context; unsigned char digest[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -61,13 +61,13 @@ RETURN_STRINGL((char*)digest, 16, 1); } else { make_digest(md5str, digest); - RETVAL_ASCII_STRING(md5str, 1); + RETVAL_ASCII_STRING(md5str, ZSTR_DUPLICATE); } } /* }}} */ -/* {{{ proto string md5_file(string filename [, bool raw_output]) +/* {{{ proto string md5_file(string filename [, bool raw_output]) U Calculate the md5 hash of given filename */ PHP_NAMED_FUNCTION(php_if_md5_file) { @@ -81,7 +81,7 @@ int n; php_stream*stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -108,7 +108,7 @@ RETURN_STRINGL((char*)digest, 16, 1); } else { make_digest(md5str, digest); - RETVAL_ASCII_STRING(md5str, 1); + RETVAL_ASCII_STRING(md5str, ZSTR_DUPLICATE); } } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/sha1.c?r1=1.17&r2=1.18&diff_format=u Index: php-src/ext/standard/sha1.c diff -u php-src/ext/standard/sha1.c:1.17 php-src/ext/standard/sha1.c:1.18 --- php-src/ext/standard/sha1.c:1.17Thu Mar 2 13:12:45 2006 +++ php-src/ext/standard/sha1.c Sun Sep 24 17:09:46 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sha1.c,v 1.17 2006/03/02 13:12:45 dmitry Exp $ */ +/* $Id: sha1.c,v 1.18 2006/09/24 17:09:46 pollita Exp $ */ #include "php.h" @@ -36,7 +36,7 @@ *sha1str = '\0'; } -/* {{{ proto string sha1(string str [, bool raw_output]) +/* {{{ proto string sha1(string str [, bool raw_output]) U Calculate the sha1 hash of a string */ PHP_FUNCTION(sha1) { @@ -47,7 +47,7 @@ PHP_SHA1_CTX context; unsigned char digest[20]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -59,7 +59,7 @@ RETURN_STRINGL((char*)digest, 20, 1); } else { make_sha1_digest(sha1str, digest); - RETVAL_ASCII_STRING(sha1str, 1); + RETVAL_ASCII_STRING(sha1str, ZSTR_DUPLICATE); } } @@ -67,7 +67,7 @@ /* }}} */ -/* {{{ proto string sha1_file(string filename [, bool raw_output]) +/* {{{ proto string sha1_file(string filename [, bool raw_output]) U Calculate the sha1 hash of given filename */ PHP_FUNCTION(sha1_file) { @@ -81,7 +81,7 @@ int n; php_stream*stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -108,7 +108,7 @@ RETURN_STRINGL((char*)digest, 20, 1); } else { make_sha1_digest(sha1str, digest); - RETVAL_ASCII_STRING(sha1str, 1); + RETVAL_ASCII_STRING(sha1str, ZSTR_DUPLICATE); } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard exec.c
pollita Sun Sep 24 17:03:58 2006 UTC Modified files: /php-src/ext/standard exec.c Log: PHP6 Updates http://cvs.php.net/viewvc.cgi/php-src/ext/standard/exec.c?r1=1.120&r2=1.121&diff_format=u Index: php-src/ext/standard/exec.c diff -u php-src/ext/standard/exec.c:1.120 php-src/ext/standard/exec.c:1.121 --- php-src/ext/standard/exec.c:1.120 Sun Jun 11 20:33:29 2006 +++ php-src/ext/standard/exec.c Sun Sep 24 17:03:58 2006 @@ -16,7 +16,7 @@ | Ilia Alshanetsky <[EMAIL PROTECTED]> | +--+ */ -/* $Id: exec.c,v 1.120 2006/06/11 20:33:29 bjori Exp $ */ +/* $Id: exec.c,v 1.121 2006/09/24 17:03:58 pollita Exp $ */ #include #include "php.h" @@ -55,6 +55,7 @@ * If type==2, all lines will be saved to given array (exec with &$array) * If type==3, output will be printed binary, no lines will be saved or returned (passthru) * + * Unicode command strings are encoding using filesystem_encoding, returned data is not decoded back to unicode */ int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_DC) { @@ -168,15 +169,16 @@ { char *cmd; int cmd_len; + zend_uchar cmd_type; zval *ret_code=NULL, *ret_array=NULL; int ret; if (mode) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/", &cmd, &cmd_len, &ret_code) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|z/", &cmd, &cmd_len, &cmd_type, &ret_code) == FAILURE) { RETURN_FALSE; } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/z/", &cmd, &cmd_len, &ret_array, &ret_code) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|z/z/", &cmd, &cmd_len, &cmd_type, &ret_array, &ret_code) == FAILURE) { RETURN_FALSE; } } @@ -185,6 +187,12 @@ RETURN_FALSE; } + if (cmd_type == IS_UNICODE) { + if (FAILURE == php_stream_path_encode(NULL, &cmd, &cmd_len, (UChar*)cmd, cmd_len, REPORT_ERRORS, FG(default_context))) { + RETURN_FALSE; + } + } + if (!ret_array) { ret = php_exec(mode, cmd, NULL, return_value TSRMLS_CC); } else { @@ -198,9 +206,13 @@ zval_dtor(ret_code); ZVAL_LONG(ret_code, ret); } + + if (cmd_type == IS_UNICODE) { + efree(cmd); + } } -/* {{{ proto string exec(string command [, array &output [, int &return_value]]) +/* {{{ proto string exec(string command [, array &output [, int &return_value]]) U Execute an external program */ PHP_FUNCTION(exec) { @@ -209,7 +221,7 @@ /* }}} */ -/* {{{ proto int system(string command [, int &return_value]) +/* {{{ proto int system(string command [, int &return_value]) U Execute an external program and display output */ PHP_FUNCTION(system) { @@ -217,7 +229,7 @@ } /* }}} */ -/* {{{ proto void passthru(string command [, int &return_value]) +/* {{{ proto void passthru(string command [, int &return_value]) U Execute an external program and display raw output */ PHP_FUNCTION(passthru) { @@ -235,11 +247,11 @@ *NOT* safe for binary strings */ char *php_escape_shell_cmd(char *str) { - register int x, y, l; + register int x, y, l = strlen(str); char *cmd; char *p = NULL; + size_t estimate = (2 * l) + 1; - l = strlen(str); cmd = safe_emalloc(2, l, 1); for (x = 0, y = 0; x < l; x++) { @@ -292,6 +304,13 @@ } } cmd[y] = '\0'; + + if ((estimate - y) > 4096) { + /* realloc if the estimate was way overill +* Arbitrary cutoff point of 4096 */ + cmd = erealloc(cmd, y + 1); + } + return cmd; } /* }}} */ @@ -299,12 +318,10 @@ /* {{{ php_escape_shell_arg */ char *php_escape_shell_arg(char *str) { - int x, y, l; + int x, y = 0, l = strlen(str); char *cmd; + size_t estimate = (4 * l) + 3; - y = 0; - l = strlen(str); - cmd = safe_emalloc(4, l, 3); /* worst case */ #ifdef PHP_WIN32 @@ -337,71 +354,106 @@ cmd[y++] = '\''; #endif cmd[y] = '\0'; + + if ((estimate - y) > 4096) { + /* realloc if the estimate was way overill +* Arbitrary cutoff point of 4096 */ + cmd = erealloc(cmd, y + 1); + } return cmd; } /* }}} */ -/* {{{ proto string escapeshellcmd(string command) +/* {{{ proto string escapeshellcmd(string command) U Escape shell metacharacters */ PHP_FUNCTION(escapeshellcmd) { - zval **arg1; + char *command; + int command_len; + zend_uchar command_type;
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/mbstring mbstring.c
hirokawaSun Sep 24 07:10:54 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/mbstring mbstring.c Log: disabled mb_list_*_names() and mb_list_encodings(arg) which are introduced in PHP 5.2.0RC to reconsider/discuss the specification. http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.224.2.22.2.14&r2=1.224.2.22.2.15&diff_format=u Index: php-src/ext/mbstring/mbstring.c diff -u php-src/ext/mbstring/mbstring.c:1.224.2.22.2.14 php-src/ext/mbstring/mbstring.c:1.224.2.22.2.15 --- php-src/ext/mbstring/mbstring.c:1.224.2.22.2.14 Thu Sep 21 16:37:20 2006 +++ php-src/ext/mbstring/mbstring.c Sun Sep 24 07:10:54 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: mbstring.c,v 1.224.2.22.2.14 2006/09/21 16:37:20 masugata Exp $ */ +/* $Id: mbstring.c,v 1.224.2.22.2.15 2006/09/24 07:10:54 hirokawa Exp $ */ /* * PHP 4 Multibyte String module "mbstring" @@ -224,8 +224,6 @@ PHP_FE(mb_convert_encoding, NULL) PHP_FE(mb_detect_encoding, NULL) PHP_FE(mb_list_encodings, NULL) - PHP_FE(mb_list_encodings_alias_names, NULL) - PHP_FE(mb_list_mime_names, NULL) PHP_FE(mb_convert_kana, NULL) PHP_FE(mb_encode_mimeheader,NULL) PHP_FE(mb_decode_mimeheader,NULL) @@ -2657,41 +2655,19 @@ } /* }}} */ -/* {{{ proto mixed mb_list_encodings([string alias_encoding]) - Returns an array of all supported entity encodings or Returns the entity encoding as a string */ +/* {{{ proto mixed mb_list_encodings() + Returns an array of all supported entity encodings */ PHP_FUNCTION(mb_list_encodings) { const mbfl_encoding **encodings; const mbfl_encoding *encoding; - enum mbfl_no_encoding no_encoding; int i; - char *name = NULL; - int name_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { - RETURN_FALSE; - } - - if (name == NULL) { - array_init(return_value); - i = 0; - encodings = mbfl_get_supported_encodings(); - while ((encoding = encodings[i++]) != NULL) { - add_next_index_string(return_value, (char *) encoding->name, 1); - } - } else { - no_encoding = mbfl_name2no_encoding(name); - if (no_encoding == mbfl_no_encoding_invalid) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown encoding \"%s\"", name); - RETURN_FALSE; - } - name = (char *)mbfl_no_encoding2name(no_encoding); - if (name != NULL) { - RETURN_STRING(name, 1); - } else { - RETURN_FALSE; - } + array_init(return_value); + i = 0; + encodings = mbfl_get_supported_encodings(); + while ((encoding = encodings[i++]) != NULL) { + add_next_index_string(return_value, (char *) encoding->name, 1); } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php