[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard string.c
moriyoshi Sat Feb 14 07:00:24 2009 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: - MFH: these should be E_WARNING for consistency with strpos() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.80r2=1.445.2.14.2.81diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.80 php-src/ext/standard/string.c:1.445.2.14.2.81 --- php-src/ext/standard/string.c:1.445.2.14.2.80 Fri Jan 30 00:17:05 2009 +++ php-src/ext/standard/string.c Sat Feb 14 07:00:24 2009 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.80 2009/01/30 00:17:05 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.81 2009/02/14 07:00:24 moriyoshi Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1949,14 +1949,14 @@ if (offset = 0) { if (offset haystack_len) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Offset is greater than the length of haystack string); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset is greater than the length of haystack string); RETURN_FALSE; } p = haystack + offset; e = haystack + haystack_len - needle_len; } else { if (-offset haystack_len) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Offset is greater than the length of haystack string); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset is greater than the length of haystack string); RETURN_FALSE; } @@ -2025,7 +2025,7 @@ Can also avoid tolower emallocs */ if (offset = 0) { if (offset haystack_len) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Offset is greater than the length of haystack string); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset is greater than the length of haystack string); RETURN_FALSE; } p = haystack + offset; @@ -2033,7 +2033,7 @@ } else { p = haystack; if (-offset haystack_len || offset -INT_MAX) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Offset is greater than the length of haystack string); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset is greater than the length of haystack string); RETURN_FALSE; } e = haystack + haystack_len + offset; @@ -2058,7 +2058,7 @@ if (offset haystack_len) { efree(needle_dup); efree(haystack_dup); - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Offset is greater than the length of haystack string); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset is greater than the length of haystack string); RETURN_FALSE; } p = haystack_dup + offset; @@ -2067,7 +2067,7 @@ if (-offset haystack_len || offset -INT_MAX) { efree(needle_dup); efree(haystack_dup); - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Offset is greater than the length of haystack string); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset is greater than the length of haystack string); RETURN_FALSE; } p = haystack_dup; -- 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/standard string.c
iliaa Fri Jan 30 00:17:06 2009 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: MFB: Improved validation checks inside str_pad() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.79r2=1.445.2.14.2.80diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.79 php-src/ext/standard/string.c:1.445.2.14.2.80 --- php-src/ext/standard/string.c:1.445.2.14.2.79 Wed Dec 31 11:17:45 2008 +++ php-src/ext/standard/string.c Fri Jan 30 00:17:05 2009 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.79 2008/12/31 11:17:45 sebastian Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.80 2009/01/30 00:17:05 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4922,7 +4922,7 @@ /* If resulting string turns out to be shorter than input string, we simply copy the input and return. */ - if (Z_LVAL_PP(pad_length) 0 || num_pad_chars 0) { + if (Z_LVAL_PP(pad_length) = 0 || num_pad_chars = 0) { RETURN_ZVAL(*input, 1, 0); } -- 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/standard string.c
felipe Wed Nov 5 18:55:02 2008 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: - Fixed bug #45166 (substr() overflow changes) (now synced with other branches) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.76r2=1.445.2.14.2.77diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.76 php-src/ext/standard/string.c:1.445.2.14.2.77 --- php-src/ext/standard/string.c:1.445.2.14.2.76 Tue Jul 15 14:58:58 2008 +++ php-src/ext/standard/string.c Wed Nov 5 18:55:02 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.76 2008/07/15 14:58:58 scottmac Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.77 2008/11/05 18:55:02 felipe Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -2260,8 +2260,10 @@ } f = Z_LVAL_PP(from); - if (f Z_STRLEN_PP(str) || (f 0 -f Z_STRLEN_PP(str))) { + if (f Z_STRLEN_PP(str)) { RETURN_FALSE; + } else if (f 0 -f Z_STRLEN_PP(str)) { + f = 0; } if (l 0 (l + Z_STRLEN_PP(str) - f) 0) { -- 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/standard string.c /ext/standard/tests/strings bug45485.phpt
felipe Fri Jul 11 12:16:06 2008 UTC Added files: (Branch: PHP_5_2) /php-src/ext/standard/tests/strings bug45485.phpt Modified files: /php-src/ext/standard string.c Log: - Fixed bug #45485 (strip_tags and ?XML tag) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.74r2=1.445.2.14.2.75diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.74 php-src/ext/standard/string.c:1.445.2.14.2.75 --- php-src/ext/standard/string.c:1.445.2.14.2.74 Fri May 9 12:59:41 2008 +++ php-src/ext/standard/string.c Fri Jul 11 12:16:05 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.74 2008/05/09 12:59:41 scottmac Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.75 2008/07/11 12:16:05 felipe Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4519,12 +4519,13 @@ /* fall-through */ case 'l': + case 'L': /* swm: If we encounter '?xml' then we shouldn't be in * state == 2 (PHP). Switch back to HTML. */ - if (state == 2 p buf+2 *(p-1) == 'm' *(p-2) == 'x') { + if (state == 2 p buf+2 strncasecmp(p-2, xm, 2) == 0) { state = 1; break; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug45485.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/strings/bug45485.phpt +++ php-src/ext/standard/tests/strings/bug45485.phpt -- 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/standard string.c
scottmacFri May 9 12:59:42 2008 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: MFH: Fix compile error if _GNU_SOURCE is defined http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.73r2=1.445.2.14.2.74diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.73 php-src/ext/standard/string.c:1.445.2.14.2.74 --- php-src/ext/standard/string.c:1.445.2.14.2.73 Wed Jan 16 08:35:59 2008 +++ php-src/ext/standard/string.c Fri May 9 12:59:41 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.73 2008/01/16 08:35:59 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.74 2008/05/09 12:59:41 scottmac Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -592,14 +592,12 @@ #endif #ifdef DECIMAL_POINT case DECIMAL_POINT: -#endif -#ifdef RADIXCHAR +#elif defined(RADIXCHAR) case RADIXCHAR: #endif #ifdef THOUSANDS_SEP case THOUSANDS_SEP: -#endif -#ifdef THOUSEP +#elif defined(THOUSEP) case THOUSEP: #endif #ifdef GROUPING -- 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/standard string.c
tony2001Thu Dec 13 22:30:28 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.70r2=1.445.2.14.2.71diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.70 php-src/ext/standard/string.c:1.445.2.14.2.71 --- php-src/ext/standard/string.c:1.445.2.14.2.70 Thu Oct 4 13:31:11 2007 +++ php-src/ext/standard/string.c Thu Dec 13 22:30:28 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.70 2007/10/04 13:31:11 jani Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.71 2007/12/13 22:30:28 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -452,15 +452,182 @@ Query language and locale information */ PHP_FUNCTION(nl_langinfo) { - zval **item; + long item; char *value; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, item) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, l, item) == FAILURE) { + return; + } + + switch(item) { /* {{{ */ +#ifdef ABDAY_1 + case ABDAY_1: + case ABDAY_2: + case ABDAY_3: + case ABDAY_4: + case ABDAY_5: + case ABDAY_6: + case ABDAY_7: +#endif +#ifdef DAY_1 + case DAY_1: + case DAY_2: + case DAY_3: + case DAY_4: + case DAY_5: + case DAY_6: + case DAY_7: +#endif +#ifdef ABMON_1 + case ABMON_1: + case ABMON_2: + case ABMON_3: + case ABMON_4: + case ABMON_5: + case ABMON_6: + case ABMON_7: + case ABMON_8: + case ABMON_9: + case ABMON_10: + case ABMON_11: + case ABMON_12: +#endif +#ifdef MON_1 + case MON_1: + case MON_2: + case MON_3: + case MON_4: + case MON_5: + case MON_6: + case MON_7: + case MON_8: + case MON_9: + case MON_10: + case MON_11: + case MON_12: +#endif +#ifdef AM_STR + case AM_STR: +#endif +#ifdef PM_STR + case PM_STR: +#endif +#ifdef D_T_FMT + case D_T_FMT: +#endif +#ifdef D_FMT + case D_FMT: +#endif +#ifdef T_FMT + case T_FMT: +#endif +#ifdef T_FMT_AMPM + case T_FMT_AMPM: +#endif +#ifdef ERA + case ERA: +#endif +#ifdef ERA_YEAR + case ERA_YEAR: +#endif +#ifdef ERA_D_T_FMT + case ERA_D_T_FMT: +#endif +#ifdef ERA_D_FMT + case ERA_D_FMT: +#endif +#ifdef ERA_T_FMT + case ERA_T_FMT: +#endif +#ifdef ALT_DIGITS + case ALT_DIGITS: +#endif +#ifdef INT_CURR_SYMBOL + case INT_CURR_SYMBOL: +#endif +#ifdef CURRENCY_SYMBOL + case CURRENCY_SYMBOL: +#endif +#ifdef CRNCYSTR + case CRNCYSTR: +#endif +#ifdef MON_DECIMAL_POINT + case MON_DECIMAL_POINT: +#endif +#ifdef MON_THOUSANDS_SEP + case MON_THOUSANDS_SEP: +#endif +#ifdef MON_GROUPING + case MON_GROUPING: +#endif +#ifdef POSITIVE_SIGN + case POSITIVE_SIGN: +#endif +#ifdef NEGATIVE_SIGN + case NEGATIVE_SIGN: +#endif +#ifdef INT_FRAC_DIGITS + case INT_FRAC_DIGITS: +#endif +#ifdef FRAC_DIGITS + case FRAC_DIGITS: +#endif +#ifdef P_CS_PRECEDES + case P_CS_PRECEDES: +#endif +#ifdef P_SEP_BY_SPACE + case P_SEP_BY_SPACE: +#endif +#ifdef N_CS_PRECEDES + case N_CS_PRECEDES: +#endif +#ifdef N_SEP_BY_SPACE + case N_SEP_BY_SPACE: +#endif +#ifdef P_SIGN_POSN + case P_SIGN_POSN: +#endif +#ifdef N_SIGN_POSN + case N_SIGN_POSN: +#endif +#ifdef DECIMAL_POINT + case DECIMAL_POINT: +#endif +#ifdef RADIXCHAR + case RADIXCHAR: +#endif +#ifdef THOUSANDS_SEP + case THOUSANDS_SEP: +#endif +#ifdef THOUSEP + case THOUSEP: +#endif +#ifdef GROUPING + case GROUPING: +#endif +#ifdef YESEXPR + case YESEXPR: +#endif +#ifdef NOEXPR + case NOEXPR: +#endif +#ifdef YESSTR + case YESSTR: +#endif +#ifdef NOSTR + case NOSTR: +#endif +#ifdef CODESET + case CODESET: +#endif + break; + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, Item '%ld' is not valid, item); + RETURN_FALSE; } -
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard string.c
pajoye Fri Sep 7 18:23:58 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: - #42592, remove ending dot in warning msg http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.68r2=1.445.2.14.2.69diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.68 php-src/ext/standard/string.c:1.445.2.14.2.69 --- php-src/ext/standard/string.c:1.445.2.14.2.68 Fri Sep 7 02:28:42 2007 +++ php-src/ext/standard/string.c Fri Sep 7 18:23:58 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.68 2007/09/07 02:28:42 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.69 2007/09/07 18:23:58 pajoye Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -659,7 +659,7 @@ } if (linelength == 0 docut) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Can't force cut when width is zero.); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Can't force cut when width is zero); RETURN_FALSE; } -- 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/standard string.c /ext/standard/tests/strings str_pad.phpt
janiMon Jul 23 13:27:59 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c /php-src/ext/standard/tests/strings str_pad.phpt Log: MFH: Fixed str_pad() when passed huge negative pad length. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.64r2=1.445.2.14.2.65diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.64 php-src/ext/standard/string.c:1.445.2.14.2.65 --- php-src/ext/standard/string.c:1.445.2.14.2.64 Sun Jul 22 15:55:15 2007 +++ php-src/ext/standard/string.c Mon Jul 23 13:27:58 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.64 2007/07/22 15:55:15 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.65 2007/07/23 13:27:58 jani Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4746,7 +4746,7 @@ /* If resulting string turns out to be shorter than input string, we simply copy the input and return. */ - if (num_pad_chars 0) { + if (Z_LVAL_PP(pad_length) 0 || num_pad_chars 0) { RETURN_ZVAL(*input, 1, 0); } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_pad.phpt?r1=1.1.2.4r2=1.1.2.5diff_format=u Index: php-src/ext/standard/tests/strings/str_pad.phpt -- 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/standard string.c
stasWed Jun 6 17:59:08 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Fix chunk_split fix - avoid using floats Fix money_format - don't give strfmon more arguments then supplied Fix str[c]spn integer overflow http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.60r2=1.445.2.14.2.61diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.60 php-src/ext/standard/string.c:1.445.2.14.2.61 --- php-src/ext/standard/string.c:1.445.2.14.2.60 Tue Jun 5 13:35:26 2007 +++ php-src/ext/standard/string.c Wed Jun 6 17:59:07 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.60 2007/06/05 13:35:26 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.61 2007/06/06 17:59:07 stas Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -239,10 +239,14 @@ } } - if ((start + len) len1) { + if (len len1 - start) { len = len1 - start; } + if(len == 0) { + RETURN_LONG(0); + } + if (behavior == STR_STRSPN) { RETURN_LONG(php_strspn(s11 + start /*str1_start*/, s22 /*str2_start*/, @@ -1956,18 +1960,23 @@ char *p, *q; int chunks; /* complete chunks! */ int restlen; - float out_len; + int out_len; chunks = srclen / chunklen; restlen = srclen - chunks * chunklen; /* srclen % chunklen */ + if(chunks INT_MAX - 1) { + return NULL; + } out_len = chunks + 1; + if(out_len INT_MAX/endlen) { + return NULL; + } out_len *= endlen; - out_len += srclen + 1; - - if (out_len INT_MAX || out_len = 0) { + if(out_len INT_MAX - srclen - 1) { return NULL; } + out_len += srclen + 1; dest = safe_emalloc((int)out_len, sizeof(char), 0); @@ -4985,13 +4994,28 @@ PHP_FUNCTION(money_format) { int format_len = 0, str_len; - char *format, *str; + char *format, *str, *p, *e; double value; + zend_bool check = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sd, format, format_len, value) == FAILURE) { return; } + p = format; + e = p + format_len; + while ((p = memchr(p, '%', (e - p { + if (*(p + 1) == '%') { + p += 2; + } else if (!check) { + check = 1; + p++; + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Only a single %%i or %%n token can be used); + RETURN_FALSE; + } + } + str_len = format_len + 1024; str = emalloc(str_len); if ((str_len = strfmon(str, str_len, format, value)) 0) { -- 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/standard string.c
stasWed Jun 6 18:15:42 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: fix the chunks fix http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.61r2=1.445.2.14.2.62diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.61 php-src/ext/standard/string.c:1.445.2.14.2.62 --- php-src/ext/standard/string.c:1.445.2.14.2.61 Wed Jun 6 17:59:07 2007 +++ php-src/ext/standard/string.c Wed Jun 6 18:15:41 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.61 2007/06/06 17:59:07 stas Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.62 2007/06/06 18:15:41 stas Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1969,7 +1969,7 @@ return NULL; } out_len = chunks + 1; - if(out_len INT_MAX/endlen) { + if(endlen !=0 out_len INT_MAX/endlen) { return NULL; } out_len *= endlen; -- 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/standard string.c
tony2001Wed Jun 6 21:53:54 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.62r2=1.445.2.14.2.63diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.62 php-src/ext/standard/string.c:1.445.2.14.2.63 --- php-src/ext/standard/string.c:1.445.2.14.2.62 Wed Jun 6 18:15:41 2007 +++ php-src/ext/standard/string.c Wed Jun 6 21:53:54 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.62 2007/06/06 18:15:41 stas Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.63 2007/06/06 21:53:54 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1860,12 +1860,11 @@ e = haystack + haystack_len - 1; } else { p = haystack; - if (-offset haystack_len || -offset 0) { + if (-offset haystack_len || offset -INT_MAX) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, Offset is greater than the length of haystack string); RETURN_FALSE; - } else { - e = haystack + haystack_len + offset; } + e = haystack + haystack_len + offset; } /* Borrow that ord_needle buffer to avoid repeatedly tolower()ing needle */ *ord_needle = tolower(*needle); @@ -1893,7 +1892,7 @@ p = haystack_dup + offset; e = haystack_dup + haystack_len - needle_len; } else { - if (-offset haystack_len || -offset 0) { + if (-offset haystack_len || offset -INT_MAX) { efree(needle_dup); efree(haystack_dup); php_error_docref(NULL TSRMLS_CC, E_NOTICE, Offset is greater than the length of haystack string); -- 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/standard string.c
tony2001Tue Jun 5 13:35:26 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: fix folding http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.59r2=1.445.2.14.2.60diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.59 php-src/ext/standard/string.c:1.445.2.14.2.60 --- php-src/ext/standard/string.c:1.445.2.14.2.59 Sun Jun 3 18:47:10 2007 +++ php-src/ext/standard/string.c Tue Jun 5 13:35:26 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.59 2007/06/03 18:47:10 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.60 2007/06/05 13:35:26 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -204,7 +204,7 @@ } /* }}} */ -static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) +static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{ */ { char *s11, *s22; int len1, len2; @@ -256,6 +256,7 @@ } } +/* }}} */ /* {{{ proto int strspn(string str, string mask [, start [, len]]) Finds length of initial segment consisting entirely of characters found in mask. If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars) */ @@ -831,7 +832,6 @@ } /* }}} */ - /* {{{ proto array explode(string separator, string str [, int limit]) Splits a string on string separator and return array of components. If limit is positive only limit number of components is returned. If limit is negative all components except the last abs(limit) are returned. */ PHP_FUNCTION(explode) @@ -2122,7 +2122,6 @@ } /* }}} */ - /* {{{ proto mixed substr_replace(mixed str, mixed repl, mixed start [, mixed length]) Replaces part of a string with another string */ PHP_FUNCTION(substr_replace) @@ -2354,9 +2353,6 @@ } /* }}} */ - - - /* {{{ proto string quotemeta(string str) Quotes meta characters */ PHP_FUNCTION(quotemeta) @@ -3402,8 +3398,7 @@ { return php_str_to_str_ex(haystack, length, needle, needle_len, str, str_len, _new_length, 1, NULL); } -/* }}} - */ +/* }}} */ /* {{{ php_str_replace_in_subject */ @@ -3812,7 +3807,6 @@ } /* }}} */ - /* {{{ proto string nl2br(string str) Converts newlines to HTML line breaks */ PHP_FUNCTION(nl2br) @@ -3888,7 +3882,6 @@ } /* }}} */ - /* {{{ proto string strip_tags(string str [, string allowable_tags]) Strips HTML and PHP tags from a string */ PHP_FUNCTION(strip_tags) @@ -4127,10 +4120,11 @@ } /* }}} */ -PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, int allow_len) +PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, int allow_len) /* {{{ */ { return php_strip_tags_ex(rbuf, len, stateptr, allow, allow_len, 0); } +/* }}} */ /* {{{ php_strip_tags @@ -4854,8 +4848,7 @@ } /* }}} */ - -static void php_string_shuffle(char *str, long len TSRMLS_DC) +static void php_string_shuffle(char *str, long len TSRMLS_DC) /* {{{ */ { long n_elems, rnd_idx, n_left; char temp; @@ -4879,7 +4872,7 @@ } } } - +/* }}} */ /* {{{ proto void str_shuffle(string str) Shuffles string. One permutation of all possible is created */ -- 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/standard string.c
rasmus Thu May 24 20:53:05 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Avoid running off the end of a non-null terminated string. Not that we should have any of those, but a mistake in an extension could hit this and the check doesn't actually make any sense as far as I am concerned. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.55r2=1.445.2.14.2.56diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.55 php-src/ext/standard/string.c:1.445.2.14.2.56 --- php-src/ext/standard/string.c:1.445.2.14.2.55 Thu May 10 22:10:43 2007 +++ php-src/ext/standard/string.c Thu May 24 20:53:05 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.55 2007/05/10 22:10:43 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.56 2007/05/24 20:53:05 rasmus Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3016,7 +3016,7 @@ php_charmask(what, wlength, flags TSRMLS_CC); - for (source = str, end = source + length, target = new_str; (c = *source) || (source end); source++) { + for (source = str, end = source + length, target = new_str; source end; source++) { if (flags[(unsigned char)c]) { if ((unsigned char) c 32 || (unsigned char) c 126) { *target++ = '\\'; -- 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/standard string.c
iliaa Sat Mar 10 20:07:51 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Re-added check removed by the previous patch http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.51r2=1.445.2.14.2.52diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.51 php-src/ext/standard/string.c:1.445.2.14.2.52 --- php-src/ext/standard/string.c:1.445.2.14.2.51 Fri Mar 9 10:04:59 2007 +++ php-src/ext/standard/string.c Sat Mar 10 20:07:50 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.51 2007/03/09 10:04:59 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.52 2007/03/10 20:07:50 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -2065,6 +2065,8 @@ l = Z_LVAL_PP(len); if ((l 0 -l Z_STRLEN_PP(str))) { RETURN_FALSE; + } else if (l Z_STRLEN_PP(str)) { + l = Z_STRLEN_PP(str); } } else { l = Z_STRLEN_PP(str); -- 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/standard string.c /ext/standard/tests/strings bug40754.phpt
tony2001Fri Mar 9 10:04:59 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c /php-src/ext/standard/tests/strings bug40754.phpt Log: fix substr() it's perfectly legal to do substr(str, 0, 100); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.50r2=1.445.2.14.2.51diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.50 php-src/ext/standard/string.c:1.445.2.14.2.51 --- php-src/ext/standard/string.c:1.445.2.14.2.50 Fri Mar 9 01:58:34 2007 +++ php-src/ext/standard/string.c Fri Mar 9 10:04:59 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.50 2007/03/09 01:58:34 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.51 2007/03/09 10:04:59 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -2063,7 +2063,7 @@ if (argc 2) { convert_to_long_ex(len); l = Z_LVAL_PP(len); - if (l Z_STRLEN_PP(str) || (l 0 -l Z_STRLEN_PP(str))) { + if ((l 0 -l Z_STRLEN_PP(str))) { RETURN_FALSE; } } else { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug40754.phpt?r1=1.1.2.1r2=1.1.2.2diff_format=u Index: php-src/ext/standard/tests/strings/bug40754.phpt diff -u php-src/ext/standard/tests/strings/bug40754.phpt:1.1.2.1 php-src/ext/standard/tests/strings/bug40754.phpt:1.1.2.2 --- php-src/ext/standard/tests/strings/bug40754.phpt:1.1.2.1Fri Mar 9 01:58:34 2007 +++ php-src/ext/standard/tests/strings/bug40754.phptFri Mar 9 10:04:59 2007 @@ -27,36 +27,36 @@ ? --EXPECTF-- -bool(false) +string(4) bcde bool(false) bool(false) bool(false) -Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s/bug40754.php on line %d +Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s on line %d bool(false) -Warning: substr_compare(): The start position cannot exceed initial string length in %s/bug40754.php on line %d +Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d bool(false) -Warning: stripos(): Offset not contained in string. in %s/bug40754.php on line %d +Warning: stripos(): Offset not contained in string. in %s on line %d bool(false) -Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s/bug40754.php on line %d +Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s on line %d bool(false) -Warning: substr_count(): Length value 2147483647 exceeds string length. in %s/bug40754.php on line %d +Warning: substr_count(): Length value 2147483647 exceeds string length. in %s on line %d bool(false) -Warning: strpos(): Offset not contained in string. in %s/bug40754.php on line %d +Warning: strpos(): Offset not contained in string. in %s on line %d bool(false) -Warning: stripos(): Offset not contained in string. in %s/bug40754.php on line %d +Warning: stripos(): Offset not contained in string. in %s on line %d bool(false) -Notice: strrpos(): Offset is greater than the length of haystack string in %s/bug40754.php on line %d +Notice: strrpos(): Offset is greater than the length of haystack string in %s on line %d bool(false) -Notice: strripos(): Offset is greater than the length of haystack string in %s/bug40754.php on line %d +Notice: strripos(): Offset is greater than the length of haystack string in %s on line %d bool(false) int(2) string(8) abcdeabc -- 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/standard string.c
stasWed Mar 7 18:15:46 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: fix MOPB#14 # The error message seems wrong, so maybe better fix is needed http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.45r2=1.445.2.14.2.46diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.45 php-src/ext/standard/string.c:1.445.2.14.2.46 --- php-src/ext/standard/string.c:1.445.2.14.2.45 Sat Mar 3 15:46:29 2007 +++ php-src/ext/standard/string.c Wed Mar 7 18:15:46 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.45 2007/03/03 15:46:29 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.46 2007/03/07 18:15:46 stas Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -5074,7 +5074,7 @@ offset = (offset 0) ? 0 : offset; } - if ((offset + len) s1_len) { + if ((offset + len) s1_len || (offset+len) 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, The start position cannot exceed initial string length); RETURN_FALSE; } -- 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/standard string.c
iliaa Thu Mar 8 00:06:41 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Improved offset validation http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.46r2=1.445.2.14.2.47diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.46 php-src/ext/standard/string.c:1.445.2.14.2.47 --- php-src/ext/standard/string.c:1.445.2.14.2.46 Wed Mar 7 18:15:46 2007 +++ php-src/ext/standard/string.c Thu Mar 8 00:06:41 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.46 2007/03/07 18:15:46 stas Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.47 2007/03/08 00:06:41 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4642,11 +4642,13 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset should be greater than or equal to 0.); RETURN_FALSE; } - p += Z_LVAL_PP(offset); - if (p endp) { + + if (Z_LVAL_PP(offset) Z_STRLEN_PP(haystack)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset value %ld exceeds string length., Z_LVAL_PP(offset)); RETURN_FALSE; } + p += Z_LVAL_PP(offset); + if (ac == 4) { convert_to_long_ex(length); if (Z_LVAL_PP(length) = 0) { -- 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/standard string.c
stasThu Mar 8 00:47:04 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: clarify checks and error messages http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.48r2=1.445.2.14.2.49diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.48 php-src/ext/standard/string.c:1.445.2.14.2.49 --- php-src/ext/standard/string.c:1.445.2.14.2.48 Thu Mar 8 00:18:10 2007 +++ php-src/ext/standard/string.c Thu Mar 8 00:47:04 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.48 2007/03/08 00:18:10 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.49 2007/03/08 00:47:04 stas Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4655,7 +4655,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, Length should be greater than 0.); RETURN_FALSE; } - if ((p + Z_LVAL_PP(length)) = p || (p + Z_LVAL_PP(length)) endp) { + if (Z_LVAL_PP(length) (Z_STRLEN_PP(haystack) - Z_LVAL_PP(offset))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Length value %ld exceeds string length., Z_LVAL_PP(length)); RETURN_FALSE; } @@ -5076,11 +5076,16 @@ offset = (offset 0) ? 0 : offset; } - if ((offset + len) s1_len || (offset+len) 0) { + if(offset s1_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, The start position cannot exceed initial string length); RETURN_FALSE; } + if(len s1_len - offset) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, The length cannot exceed initial string length); + RETURN_FALSE; + } + cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset))); if (!cs) { -- 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/standard string.c /ext/standard/tests/strings bug40704.phpt
iliaa Sat Mar 3 15:46:29 2007 UTC Added files: (Branch: PHP_5_2) /php-src/ext/standard/tests/strings bug40704.phpt Modified files: /php-src/ext/standard string.c Log: Fixed bug #40704 (strip_tags() does not handle single quotes correctly) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.44r2=1.445.2.14.2.45diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.44 php-src/ext/standard/string.c:1.445.2.14.2.45 --- php-src/ext/standard/string.c:1.445.2.14.2.44 Tue Feb 27 03:28:16 2007 +++ php-src/ext/standard/string.c Sat Mar 3 15:46:29 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.44 2007/02/27 03:28:16 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.45 2007/03/03 15:46:29 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4211,7 +4211,7 @@ switch (state) { case 1: /* HTML/XML */ lc = ''; - state = 0; + in_q = state = 0; if (allow) { tp = ((tp-tbuf) = PHP_TAG_BUF_SIZE ? tbuf: tp); *(tp++) = ''; @@ -4226,19 +4226,19 @@ case 2: /* PHP */ if (!br lc != '\' *(p-1) == '?') { - state = 0; + in_q = state = 0; tp = tbuf; } break; case 3: - state = 0; + in_q = state = 0; tp = tbuf; break; case 4: /* JavaScript/CSS/etc... */ if (p = buf + 2 *(p-1) == '-' *(p-2) == '-') { - state = 0; + in_q = state = 0; tp = tbuf; } break; @@ -4263,7 +4263,7 @@ tp = ((tp-tbuf) = PHP_TAG_BUF_SIZE ? tbuf: tp); *(tp++) = c; } - if (p != buf *(p-1) != '\\' (!in_q || *p == in_q)) { + if (state p != buf *(p-1) != '\\' (!in_q || *p == in_q)) { if (in_q) { in_q = 0; } else { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug40704.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/strings/bug40704.phpt +++ php-src/ext/standard/tests/strings/bug40704.phpt -- 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/standard string.c
iliaa Tue Feb 27 00:15:21 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Fixed bug #40637 (Regression in strip_tags() in relation so quote handling) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.42r2=1.445.2.14.2.43diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.42 php-src/ext/standard/string.c:1.445.2.14.2.43 --- php-src/ext/standard/string.c:1.445.2.14.2.42 Sat Feb 24 02:17:27 2007 +++ php-src/ext/standard/string.c Tue Feb 27 00:15:21 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.42 2007/02/24 02:17:27 helly Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.43 2007/02/27 00:15:21 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4263,8 +4263,12 @@ tp = ((tp-tbuf) = PHP_TAG_BUF_SIZE ? tbuf: tp); *(tp++) = c; } - if (p != buf *(p-1) != '\\') { - in_q = !in_q; + if (p != buf *(p-1) != '\\' (!in_q || *p == in_q)) { + if (in_q) { + in_q = 0; + } else { + in_q = *p; + } } break; -- 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/standard string.c
iliaa Tue Feb 13 23:55:20 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Make sure p is not pointing to the start of the buffer http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.40r2=1.445.2.14.2.41diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.40 php-src/ext/standard/string.c:1.445.2.14.2.41 --- php-src/ext/standard/string.c:1.445.2.14.2.40 Tue Feb 13 02:16:22 2007 +++ php-src/ext/standard/string.c Tue Feb 13 23:55:20 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.40 2007/02/13 02:16:22 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.41 2007/02/13 23:55:20 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4263,7 +4263,7 @@ tp = ((tp-tbuf) = PHP_TAG_BUF_SIZE ? tbuf: tp); *(tp++) = c; } - if (*(p-1) != '\\') { + if (p != buf *(p-1) != '\\') { in_q = !in_q; } break; -- 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/standard string.c
tony2001Sat Feb 10 00:48:28 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.38r2=1.445.2.14.2.39diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.38 php-src/ext/standard/string.c:1.445.2.14.2.39 --- php-src/ext/standard/string.c:1.445.2.14.2.38 Thu Feb 1 13:45:25 2007 +++ php-src/ext/standard/string.c Sat Feb 10 00:48:28 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.38 2007/02/01 13:45:25 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.39 2007/02/10 00:48:28 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3148,7 +3148,7 @@ } Z_STRLEN_P(result) = len + (char_count * (to_len - 1)); - Z_STRVAL_P(result) = target = safe_emalloc(char_count, to_len, len); + Z_STRVAL_P(result) = target = safe_emalloc(char_count, to_len, len + 1); Z_TYPE_P(result) = IS_STRING; if (case_sensitivity) { -- 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/standard string.c
tony2001Thu Feb 1 13:45:25 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: fix leaks on error http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.37r2=1.445.2.14.2.38diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.37 php-src/ext/standard/string.c:1.445.2.14.2.38 --- php-src/ext/standard/string.c:1.445.2.14.2.37 Mon Jan 8 14:24:59 2007 +++ php-src/ext/standard/string.c Thu Feb 1 13:45:25 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.37 2007/01/08 14:24:59 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.38 2007/02/01 13:45:25 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1881,6 +1881,8 @@ if (offset = 0) { if (offset haystack_len) { + efree(needle_dup); + efree(haystack_dup); php_error_docref(NULL TSRMLS_CC, E_NOTICE, Offset is greater than the length of haystack string); RETURN_FALSE; } @@ -1888,6 +1890,8 @@ e = haystack_dup + haystack_len - needle_len; } else { if (-offset haystack_len) { + efree(needle_dup); + efree(haystack_dup); php_error_docref(NULL TSRMLS_CC, E_NOTICE, Offset is greater than the length of haystack string); RETURN_FALSE; } -- 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/standard string.c
iliaa Mon Jan 8 14:24:59 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Use safe_emalloc() rather then emalloc() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.36r2=1.445.2.14.2.37diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.36 php-src/ext/standard/string.c:1.445.2.14.2.37 --- php-src/ext/standard/string.c:1.445.2.14.2.36 Mon Jan 1 09:36:09 2007 +++ php-src/ext/standard/string.c Mon Jan 8 14:24:59 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.36 2007/01/01 09:36:09 sebastian Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.37 2007/01/08 14:24:59 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3144,7 +3144,7 @@ } Z_STRLEN_P(result) = len + (char_count * (to_len - 1)); - Z_STRVAL_P(result) = target = emalloc(Z_STRLEN_P(result) + 1); + Z_STRVAL_P(result) = target = safe_emalloc(char_count, to_len, len); Z_TYPE_P(result) = IS_STRING; if (case_sensitivity) { -- 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/standard string.c
tony2001Wed Dec 20 23:30:30 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.33r2=1.445.2.14.2.34diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.33 php-src/ext/standard/string.c:1.445.2.14.2.34 --- php-src/ext/standard/string.c:1.445.2.14.2.33 Mon Dec 18 15:02:16 2006 +++ php-src/ext/standard/string.c Wed Dec 20 23:30:30 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.33 2006/12/18 15:02:16 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.34 2006/12/20 23:30:30 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1235,11 +1235,11 @@ } len = cend - comp; - ret = emalloc(len + 1); - memcpy(ret, comp, len); - ret[len] = '\0'; if (p_ret) { + ret = emalloc(len + 1); + memcpy(ret, comp, len); + ret[len] = '\0'; *p_ret = ret; } if (p_len) { -- 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/standard string.c
tony2001Wed Dec 20 23:36:56 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.34r2=1.445.2.14.2.35diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.34 php-src/ext/standard/string.c:1.445.2.14.2.35 --- php-src/ext/standard/string.c:1.445.2.14.2.34 Wed Dec 20 23:30:30 2006 +++ php-src/ext/standard/string.c Wed Dec 20 23:36:56 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.34 2006/12/20 23:30:30 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.35 2006/12/20 23:36:56 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4045,7 +4045,13 @@ int php_tag_find(char *tag, int len, char *set) { char c, *n, *t; int state=0, done=0; - char *norm = emalloc(len+1); + char *norm; + + if (len = 0) { + return 0; + } + + norm = emalloc(len+1); n = norm; t = tag; @@ -4055,9 +4061,6 @@ and turn any a whatever... into just a and any /tag into tag */ - if (!len) { - return 0; - } while (!done) { switch (c) { case '': -- 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/standard string.c
iliaa Wed Dec 13 15:39:12 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Removed deadcode found by Ron Korving http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.30r2=1.445.2.14.2.31diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.30 php-src/ext/standard/string.c:1.445.2.14.2.31 --- php-src/ext/standard/string.c:1.445.2.14.2.30 Mon Dec 4 18:35:42 2006 +++ php-src/ext/standard/string.c Wed Dec 13 15:39:12 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.30 2006/12/04 18:35:42 stas Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.31 2006/12/13 15:39:12 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -2995,10 +2995,6 @@ wlength = strlen(what); } - if (!length) { - length = strlen(str); - } - php_charmask(what, wlength, flags TSRMLS_CC); for (source = str, end = source + length, target = new_str; (c = *source) || (source end); source++) { -- 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/standard string.c /ext/standard/tests/strings str_word_count.phpt str_word_count1.phpt
tony2001Wed Oct 11 13:15:30 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/standard/tests/strings str_word_count1.phpt Modified files: /php-src/ext/standard string.c /php-src/ext/standard/tests/strings str_word_count.phpt Log: MFH: avoid reading str[-1], add warning when invalid format specified add test http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.25r2=1.445.2.14.2.26diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.25 php-src/ext/standard/string.c:1.445.2.14.2.26 --- php-src/ext/standard/string.c:1.445.2.14.2.25 Thu Oct 5 18:23:19 2006 +++ php-src/ext/standard/string.c Wed Oct 11 13:15:29 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.25 2006/10/05 18:23:19 andrei Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.26 2006/10/11 13:15:29 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4848,7 +4848,7 @@ long type = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|ls, str, str_len, type, char_list, char_list_len) == FAILURE) { - WRONG_PARAM_COUNT; + return; } if (char_list) { @@ -4857,9 +4857,18 @@ p = str; e = str + str_len; - - if (type == 1 || type == 2) { - array_init(return_value); + + switch(type) { + case 1: + case 2: + array_init(return_value); + break; + case 0: + /* nothing to be done */ + break; + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid format value %ld, type); + RETURN_FALSE; } /* first character cannot be ' or -, unless explicitly allowed by the user */ @@ -4867,7 +4876,7 @@ p++; } /* last character cannot be -, unless explicitly allowed by the user */ - if (*(e - 1) == '-' (!char_list || !ch['-'])) { + if (str_len *(e - 1) == '-' (!char_list || !ch['-'])) { e--; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_word_count.phpt?r1=1.4.2.1r2=1.4.2.1.2.1diff_format=u Index: php-src/ext/standard/tests/strings/str_word_count.phpt diff -u php-src/ext/standard/tests/strings/str_word_count.phpt:1.4.2.1 php-src/ext/standard/tests/strings/str_word_count.phpt:1.4.2.1.2.1 --- php-src/ext/standard/tests/strings/str_word_count.phpt:1.4.2.1 Tue Nov 29 16:14:18 2005 +++ php-src/ext/standard/tests/strings/str_word_count.phpt Wed Oct 11 13:15:30 2006 @@ -12,7 +12,7 @@ var_dump(str_word_count($str, 3)); var_dump(str_word_count($str, 123)); var_dump(str_word_count($str, -1)); -var_dump(str_word_count($str, 9)); +var_dump(str_word_count($str, 9)); var_dump(str_word_count($str, array())); var_dump(str_word_count($str, $b)); var_dump($str); @@ -41,6 +41,8 @@ var_dump(str_word_count('foo', 2, ')); var_dump(str_word_count(-foo-, 2)); var_dump(str_word_count(-foo-, 2, -)); + +echo Done\n; ? --EXPECTF-- array(6) { @@ -72,19 +74,23 @@ string(5) today } int(6) -NULL -NULL -NULL -NULL -Warning: str_word_count() expects parameter 2 to be long, array given in %s on line 13 +Warning: str_word_count(): Invalid format value 3 in %s on line %d +bool(false) -Warning: Wrong parameter count for str_word_count() in %s on line 13 -NULL +Warning: str_word_count(): Invalid format value 123 in %s on line %d +bool(false) -Warning: str_word_count() expects parameter 2 to be long, string given in %s on line 14 +Warning: str_word_count(): Invalid format value -1 in %s on line %d +bool(false) -Warning: Wrong parameter count for str_word_count() in %s on line 14 +Warning: str_word_count(): Invalid format value 9 in %s on line %d +bool(false) + +Warning: str_word_count() expects parameter 2 to be long, array given in %s on line %d +NULL + +Warning: str_word_count() expects parameter 2 to be long, string given in %s on line %d NULL string(55) Hello friend, you're looking good today! @@ -92,14 +98,10 @@ int(6) int(5) -Warning: str_word_count() expects parameter 3 to be string, array given in %s on line 21 - -Warning: Wrong parameter count for str_word_count() in %s on line 21 +Warning: str_word_count() expects parameter 3 to be string, array given in %s on line %d NULL -Warning: str_word_count() expects parameter 3 to be string, object given in %s on line 22 - -Warning: Wrong parameter count for str_word_count() in %s on line 22 +Warning: str_word_count() expects parameter 3 to be string, object given in %s on line %d NULL int(7) array(5) { @@ -141,14 +143,10 @@
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard string.c
iliaa Wed Oct 11 14:19:55 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Catch empty strings right away. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.26r2=1.445.2.14.2.27diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.26 php-src/ext/standard/string.c:1.445.2.14.2.27 --- php-src/ext/standard/string.c:1.445.2.14.2.26 Wed Oct 11 13:15:29 2006 +++ php-src/ext/standard/string.c Wed Oct 11 14:19:55 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.26 2006/10/11 13:15:29 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.27 2006/10/11 14:19:55 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4851,19 +4851,18 @@ return; } - if (char_list) { - php_charmask(char_list, char_list_len, ch TSRMLS_CC); - } - - p = str; - e = str + str_len; - switch(type) { case 1: case 2: array_init(return_value); + if (!str_len) { + return; + } break; case 0: + if (!str_len) { + RETURN_LONG(0); + } /* nothing to be done */ break; default: @@ -4871,12 +4870,19 @@ RETURN_FALSE; } + if (char_list) { + php_charmask(char_list, char_list_len, ch TSRMLS_CC); + } + + p = str; + e = str + str_len; + /* first character cannot be ' or -, unless explicitly allowed by the user */ if ((*p == '\'' (!char_list || !ch['\''])) || (*p == '-' (!char_list || !ch['-']))) { p++; } /* last character cannot be -, unless explicitly allowed by the user */ - if (str_len *(e - 1) == '-' (!char_list || !ch['-'])) { + if (*(e - 1) == '-' (!char_list || !ch['-'])) { e--; } -- 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/standard string.c
andrei Thu Oct 5 18:23:21 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Increment replace count value for case-sensitive single char searches. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.24r2=1.445.2.14.2.25diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.24 php-src/ext/standard/string.c:1.445.2.14.2.25 --- php-src/ext/standard/string.c:1.445.2.14.2.24 Wed Oct 4 11:14:32 2006 +++ php-src/ext/standard/string.c Thu Oct 5 18:23:19 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.24 2006/10/04 11:14:32 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.25 2006/10/05 18:23:19 andrei Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3155,6 +3155,9 @@ target += to_len; p++; s = p; + if (replace_count) { + *replace_count += 1; + } } if (s e) { memcpy(target, s, (e - s)); -- 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/standard string.c
andrei Mon Oct 2 19:42:42 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Fix invalid memory access in strrpos(). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.19r2=1.445.2.14.2.20diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.19 php-src/ext/standard/string.c:1.445.2.14.2.20 --- php-src/ext/standard/string.c:1.445.2.14.2.19 Thu Aug 31 14:21:21 2006 +++ php-src/ext/standard/string.c Mon Oct 2 19:42:42 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.19 2006/08/31 14:21:21 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.20 2006/10/02 19:42:42 andrei Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1767,13 +1767,18 @@ } if (offset = 0) { + if (offset haystack_len) { + RETURN_FALSE; + } p = haystack + offset; e = haystack + haystack_len - needle_len; } else { - p = haystack; if (-offset haystack_len) { - e = haystack - needle_len; - } else if (needle_len -offset) { + RETURN_FALSE; + } + + p = haystack; + if (needle_len -offset) { e = haystack + haystack_len - needle_len; } else { e = haystack + haystack_len + offset; -- 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/standard string.c
andrei Mon Oct 2 19:58:15 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: More offset fixes. Added E_NOTICE where appropriate. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.20r2=1.445.2.14.2.21diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.20 php-src/ext/standard/string.c:1.445.2.14.2.21 --- php-src/ext/standard/string.c:1.445.2.14.2.20 Mon Oct 2 19:42:42 2006 +++ php-src/ext/standard/string.c Mon Oct 2 19:58:15 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.20 2006/10/02 19:42:42 andrei Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.21 2006/10/02 19:58:15 andrei Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1768,12 +1768,14 @@ if (offset = 0) { if (offset haystack_len) { + php_error(E_NOTICE, Offset is greater than the length of haystack string); RETURN_FALSE; } p = haystack + offset; e = haystack + haystack_len - needle_len; } else { if (-offset haystack_len) { + php_error(E_NOTICE, Offset is greater than the length of haystack string); RETURN_FALSE; } @@ -1841,12 +1843,17 @@ /* Single character search can shortcut memcmps Can also avoid tolower emallocs */ if (offset = 0) { + if (offset haystack_len) { + php_error(E_NOTICE, Offset is greater than the length of haystack string); + RETURN_FALSE; + } p = haystack + offset; e = haystack + haystack_len - 1; } else { p = haystack; if (-offset haystack_len) { - e = haystack + haystack_len - 1; + php_error(E_NOTICE, Offset is greater than the length of haystack string); + RETURN_FALSE; } else { e = haystack + haystack_len + offset; } @@ -1868,13 +1875,19 @@ php_strtolower(haystack_dup, haystack_len); if (offset = 0) { + if (offset haystack_len) { + php_error(E_NOTICE, Offset is greater than the length of haystack string); + RETURN_FALSE; + } p = haystack_dup + offset; e = haystack_dup + haystack_len - needle_len; } else { - p = haystack_dup; if (-offset haystack_len) { - e = haystack_dup - needle_len; - } else if (needle_len -offset) { + php_error(E_NOTICE, Offset is greater than the length of haystack string); + RETURN_FALSE; + } + p = haystack_dup; + if (needle_len -offset) { e = haystack_dup + haystack_len - needle_len; } else { e = haystack_dup + haystack_len + offset; -- 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/standard string.c
tony2001Thu Aug 31 14:21:21 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: more z/Z fixes http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.18r2=1.445.2.14.2.19diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.18 php-src/ext/standard/string.c:1.445.2.14.2.19 --- php-src/ext/standard/string.c:1.445.2.14.2.18 Tue Aug 29 19:50:04 2006 +++ php-src/ext/standard/string.c Thu Aug 31 14:21:21 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.18 2006/08/29 19:50:04 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.19 2006/08/31 14:21:21 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1741,22 +1741,22 @@ Finds position of last occurrence of a string within another string */ PHP_FUNCTION(strrpos) { - zval *zneedle; + zval **zneedle; char *needle, *haystack; int needle_len, haystack_len; long offset = 0; char *p, *e, ord_needle[2]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sz|l, haystack, haystack_len, zneedle, offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sZ|l, haystack, haystack_len, zneedle, offset) == FAILURE) { RETURN_FALSE; } - if (Z_TYPE_P(zneedle) == IS_STRING) { - needle = Z_STRVAL_P(zneedle); - needle_len = Z_STRLEN_P(zneedle); + if (Z_TYPE_PP(zneedle) == IS_STRING) { + needle = Z_STRVAL_PP(zneedle); + needle_len = Z_STRLEN_PP(zneedle); } else { - convert_to_long(zneedle); - ord_needle[0] = (char)(Z_LVAL_P(zneedle) 0xFF); + convert_to_long_ex(zneedle); + ord_needle[0] = (char)(Z_LVAL_PP(zneedle) 0xFF); ord_needle[1] = '\0'; needle = ord_needle; needle_len = 1; @@ -1806,23 +1806,23 @@ Finds position of last occurrence of a string within another string */ PHP_FUNCTION(strripos) { - zval *zneedle; + zval **zneedle; char *needle, *haystack; int needle_len, haystack_len; long offset = 0; char *p, *e, ord_needle[2]; char *needle_dup, *haystack_dup; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sz|l, haystack, haystack_len, zneedle, offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sZ|l, haystack, haystack_len, zneedle, offset) == FAILURE) { RETURN_FALSE; } - if (Z_TYPE_P(zneedle) == IS_STRING) { - needle = Z_STRVAL_P(zneedle); - needle_len = Z_STRLEN_P(zneedle); + if (Z_TYPE_PP(zneedle) == IS_STRING) { + needle = Z_STRVAL_PP(zneedle); + needle_len = Z_STRLEN_PP(zneedle); } else { - convert_to_long(zneedle); - ord_needle[0] = (char)(Z_LVAL_P(zneedle) 0xFF); + convert_to_long_ex(zneedle); + ord_needle[0] = (char)(Z_LVAL_PP(zneedle) 0xFF); ord_needle[1] = '\0'; needle = ord_needle; needle_len = 1; -- 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/standard string.c
tony2001Tue Aug 29 12:20:18 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: fix win32 build EG(precision) can be changed in runtime, even in php_implode() (hint: __toString()), so please think twice before optimizing http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.15r2=1.445.2.14.2.16diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.15 php-src/ext/standard/string.c:1.445.2.14.2.16 --- php-src/ext/standard/string.c:1.445.2.14.2.15 Mon Aug 28 23:33:37 2006 +++ php-src/ext/standard/string.c Tue Aug 29 12:20:18 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.15 2006/08/28 23:33:37 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.16 2006/08/29 12:20:18 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -920,9 +920,11 @@ break; case IS_DOUBLE: { - char stmp[MAX_LENGTH_OF_DOUBLE + EG(precision) + 1]; + char *stmp; + stmp = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1); str_len = sprintf(stmp, %.*G, (int) EG(precision), Z_DVAL_PP(tmp)); smart_str_appendl(implstr, stmp, str_len); + efree(stmp); } break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard string.c
Your imagination is just fabulous. so please think twice before optimizing means be careful and do not try to optimize this code, even though it looks like it can be optimized by moving the emalloc() call to the beginning of the function. Please try to understand what I've really said before posting your comments again. Please do not commit obvious integer overflows to the code of PHP again. It actually doesn't matter what you meant. You removed an possible overflow and replaced it with another possible overflow. So please be careful and do not try to fix code, when all you come up with is just a different kind of overflow. Stefan -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard string.c
On 29.08.2006 17:15, Stefan Esser wrote: Your imagination is just fabulous. so please think twice before optimizing means be careful and do not try to optimize this code, even though it looks like it can be optimized by moving the emalloc() call to the beginning of the function. Please try to understand what I've really said before posting your comments again. It actually doesn't matter what you meant. I'll take this as sorry, but you really need to learn to say it yourself. -- Wbr, Antony Dovgal -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard string.c
It actually doesn't matter what you meant. I'll take this as sorry, but you really need to learn to say it yourself. Antony, you are unbelievable. Do you think you are funny? Do you think it is funny to have overflows all over the code because people like you are commiting this crap code again and again? Fix the damned integer overflow and shut up. Stefan -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard string.c
On 29.08.2006 17:29, Stefan Esser wrote: It actually doesn't matter what you meant. I'll take this as sorry, but you really need to learn to say it yourself. Antony, you are unbelievable. Do you think you are funny? Do you think it is funny to have overflows all over the code because people like you are commiting this crap code again and again? Fix the damned integer overflow and shut up. First of all, change your attitude NOW. I'm not your son and you're not my father to tell me what to do and how. And next time when your groundless attack fails, be so smart to apologize. -- Wbr, Antony Dovgal -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard string.c
First of all, change your attitude NOW. I'm not your son and you're not my father to tell me what to do and how. And next time when your groundless attack fails, be so smart to apologize. Groundless attack? Ohh... Okay that obviously means, you cannot see the overflow. Okay I will fix it later. Stefan -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard string.c
On Tue, 29 Aug 2006, Antony Dovgal wrote: On 29.08.2006 17:29, Stefan Esser wrote: It actually doesn't matter what you meant. I'll take this as sorry, but you really need to learn to say it yourself. Antony, you are unbelievable. Do you think you are funny? Do you think it is funny to have overflows all over the code because people like you are commiting this crap code again and again? Fix the damned integer overflow and shut up. First of all, change your attitude NOW. I'm not your son and you're not my father to tell me what to do and how. And next time when your groundless attack fails, be so smart to apologize. Take this crap off list please. Derick -- 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/standard string.c
iliaa Tue Aug 29 14:32:16 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Finalize implode() patch http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.16r2=1.445.2.14.2.17diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.16 php-src/ext/standard/string.c:1.445.2.14.2.17 --- php-src/ext/standard/string.c:1.445.2.14.2.16 Tue Aug 29 12:20:18 2006 +++ php-src/ext/standard/string.c Tue Aug 29 14:32:16 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.16 2006/08/29 12:20:18 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.17 2006/08/29 14:32:16 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -905,7 +905,7 @@ case IS_LONG: { char stmp[MAX_LENGTH_OF_LONG + 1]; - str_len = sprintf(stmp, %ld, Z_LVAL_PP(tmp)); + str_len = snprintf(stmp, sizeof(stmp), %ld, Z_LVAL_PP(tmp)); smart_str_appendl(implstr, stmp, str_len); } break; @@ -920,11 +920,10 @@ break; case IS_DOUBLE: { - char *stmp; - stmp = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1); - str_len = sprintf(stmp, %.*G, (int) EG(precision), Z_DVAL_PP(tmp)); + char *stmp = (char *) do_alloca(MAX_LENGTH_OF_DOUBLE + EG(precision) + 2); /* +1 for decimal point */ + str_len = snprintf(stmp, sizeof(stmp), %.*G, (int) EG(precision), Z_DVAL_PP(tmp)); smart_str_appendl(implstr, stmp, str_len); - efree(stmp); + free_alloca(stmp); } break; -- 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/standard string.c
iliaa Tue Aug 29 19:50:05 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Corrected problems introduced by previous commit. # Issue found by Stefan http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.17r2=1.445.2.14.2.18diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.17 php-src/ext/standard/string.c:1.445.2.14.2.18 --- php-src/ext/standard/string.c:1.445.2.14.2.17 Tue Aug 29 14:32:16 2006 +++ php-src/ext/standard/string.c Tue Aug 29 19:50:04 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.17 2006/08/29 14:32:16 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.18 2006/08/29 19:50:04 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -905,7 +905,7 @@ case IS_LONG: { char stmp[MAX_LENGTH_OF_LONG + 1]; - str_len = snprintf(stmp, sizeof(stmp), %ld, Z_LVAL_PP(tmp)); + str_len = sprintf(stmp, %ld, Z_LVAL_PP(tmp)); smart_str_appendl(implstr, stmp, str_len); } break; @@ -920,10 +920,10 @@ break; case IS_DOUBLE: { - char *stmp = (char *) do_alloca(MAX_LENGTH_OF_DOUBLE + EG(precision) + 2); /* +1 for decimal point */ - str_len = snprintf(stmp, sizeof(stmp), %.*G, (int) EG(precision), Z_DVAL_PP(tmp)); + char *stmp; + str_len = spprintf(stmp, 0, %.*G, (int) EG(precision), Z_DVAL_PP(tmp)); smart_str_appendl(implstr, stmp, str_len); - free_alloca(stmp); + efree(stmp); } break; -- 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/standard string.c
tony2001Mon Aug 28 09:56:29 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: fix ZTS build http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.13r2=1.445.2.14.2.14diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.13 php-src/ext/standard/string.c:1.445.2.14.2.14 --- php-src/ext/standard/string.c:1.445.2.14.2.13 Sun Aug 27 19:06:09 2006 +++ php-src/ext/standard/string.c Mon Aug 28 09:56:28 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.13 2006/08/27 19:06:09 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.14 2006/08/28 09:56:28 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -888,6 +888,7 @@ intnumelems, i = 0; zval tmp_val; int str_len; + TSRMLS_FETCH(); numelems = zend_hash_num_elements(Z_ARRVAL_P(arr)); -- 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/standard string.c
iliaa Sun Aug 27 19:06:09 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: Optimize the operation of implode() on non-string parameters http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.12r2=1.445.2.14.2.13diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.12 php-src/ext/standard/string.c:1.445.2.14.2.13 --- php-src/ext/standard/string.c:1.445.2.14.2.12 Tue Aug 22 19:55:56 2006 +++ php-src/ext/standard/string.c Sun Aug 27 19:06:09 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.12 2006/08/22 19:55:56 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.13 2006/08/27 19:06:09 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -886,9 +886,7 @@ HashPosition pos; smart_str implstr = {0}; intnumelems, i = 0; - zend_bool free_tmp_val; zval tmp_val; - char *str; int str_len; numelems = zend_hash_num_elements(Z_ARRVAL_P(arr)); @@ -900,9 +898,35 @@ zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **) tmp, pos) == SUCCESS) { - free_tmp_val = 0; - if ((*tmp)-type != IS_STRING) { - if ((*tmp)-type == IS_OBJECT) { + switch ((*tmp)-type) { + case IS_STRING: + smart_str_appendl(implstr, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); + break; + + case IS_LONG: { + char stmp[MAX_LENGTH_OF_LONG + 1]; + str_len = sprintf(stmp, %ld, Z_LVAL_PP(tmp)); + smart_str_appendl(implstr, stmp, str_len); + } + break; + + case IS_BOOL: + if (Z_LVAL_PP(tmp) == 1) { + smart_str_appendl(implstr, 1, sizeof(1)-1); + } + break; + + case IS_NULL: + break; + + case IS_DOUBLE: { + char stmp[MAX_LENGTH_OF_DOUBLE + EG(precision) + 1]; + str_len = sprintf(stmp, %.*G, (int) EG(precision), Z_DVAL_PP(tmp)); + smart_str_appendl(implstr, stmp, str_len); + } + break; + + case IS_OBJECT: { int copy; zval expr; zend_make_printable_zval(*tmp, expr, copy); @@ -910,26 +934,19 @@ if (copy) { zval_dtor(expr); } - goto next; - } else { + } + break; + + default: tmp_val = **tmp; zval_copy_ctor(tmp_val); convert_to_string(tmp_val); - str = Z_STRVAL(tmp_val); - str_len = Z_STRLEN(tmp_val); - free_tmp_val = 1; - } - } else { - str = Z_STRVAL_PP(tmp); - str_len = Z_STRLEN_PP(tmp); + smart_str_appendl(implstr, Z_STRVAL(tmp_val), Z_STRLEN(tmp_val)); + zval_dtor(tmp_val); + break; + } - - smart_str_appendl(implstr, str, str_len); - if (free_tmp_val) { - zval_dtor(tmp_val); - } -next: if (++i != numelems) { smart_str_appendl(implstr, Z_STRVAL_P(delim), Z_STRLEN_P(delim)); } -- 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/standard string.c
tony2001Tue Aug 22 19:55:56 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c Log: fix implode() function (see http://news.php.net/php.qa/26876) add test http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.11r2=1.445.2.14.2.12diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.11 php-src/ext/standard/string.c:1.445.2.14.2.12 --- php-src/ext/standard/string.c:1.445.2.14.2.11 Thu Aug 10 14:40:12 2006 +++ php-src/ext/standard/string.c Tue Aug 22 19:55:56 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.11 2006/08/10 14:40:12 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.12 2006/08/22 19:55:56 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -886,6 +886,10 @@ HashPosition pos; smart_str implstr = {0}; intnumelems, i = 0; + zend_bool free_tmp_val; + zval tmp_val; + char *str; + int str_len; numelems = zend_hash_num_elements(Z_ARRVAL_P(arr)); @@ -896,6 +900,7 @@ zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **) tmp, pos) == SUCCESS) { + free_tmp_val = 0; if ((*tmp)-type != IS_STRING) { if ((*tmp)-type == IS_OBJECT) { int copy; @@ -907,12 +912,23 @@ } goto next; } else { - SEPARATE_ZVAL(tmp); - convert_to_string(*tmp); + tmp_val = **tmp; + zval_copy_ctor(tmp_val); + convert_to_string(tmp_val); + str = Z_STRVAL(tmp_val); + str_len = Z_STRLEN(tmp_val); + free_tmp_val = 1; } - } + } else { + str = Z_STRVAL_PP(tmp); + str_len = Z_STRLEN_PP(tmp); + } - smart_str_appendl(implstr, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); + smart_str_appendl(implstr, str, str_len); + + if (free_tmp_val) { + zval_dtor(tmp_val); + } next: if (++i != numelems) { smart_str_appendl(implstr, Z_STRVAL_P(delim), Z_STRLEN_P(delim)); -- 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/standard string.c /ext/standard/tests/strings strings001.phpt
tony2001Tue Aug 8 10:22:26 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard string.c /php-src/ext/standard/tests/strings strings001.phpt Log: use memrchr/zend_memrchr instead of strrchr http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.9r2=1.445.2.14.2.10diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.9 php-src/ext/standard/string.c:1.445.2.14.2.10 --- php-src/ext/standard/string.c:1.445.2.14.2.9Fri Jul 28 12:23:18 2006 +++ php-src/ext/standard/string.c Tue Aug 8 10:22:25 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.9 2006/07/28 12:23:18 tony2001 Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.10 2006/08/08 10:22:25 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1382,7 +1382,7 @@ php_basename(path, path_len, NULL, 0, ret, ret_len TSRMLS_CC); } - p = strrchr(ret, '.'); + p = zend_memrchr(ret, '.', ret_len); if (p) { idx = p - ret; @@ -1399,7 +1399,7 @@ php_basename(path, path_len, NULL, 0, ret, ret_len TSRMLS_CC); } - p = strrchr(ret, '.'); + p = zend_memrchr(ret, '.', ret_len); idx = p ? (p - ret) : ret_len; add_assoc_stringl(tmp, filename, ret, idx, 1); @@ -1871,10 +1871,10 @@ convert_to_string_ex(haystack); if (Z_TYPE_PP(needle) == IS_STRING) { - found = strrchr(Z_STRVAL_PP(haystack), *Z_STRVAL_PP(needle)); + found = zend_memrchr(Z_STRVAL_PP(haystack), *Z_STRVAL_PP(needle), Z_STRLEN_PP(haystack)); } else { convert_to_long_ex(needle); - found = strrchr(Z_STRVAL_PP(haystack), (char) Z_LVAL_PP(needle)); + found = zend_memrchr(Z_STRVAL_PP(haystack), (char) Z_LVAL_PP(needle), Z_STRLEN_PP(haystack)); } if (found) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strings001.phpt?r1=1.2r2=1.2.20.1diff_format=u Index: php-src/ext/standard/tests/strings/strings001.phpt diff -u php-src/ext/standard/tests/strings/strings001.phpt:1.2 php-src/ext/standard/tests/strings/strings001.phpt:1.2.20.1 --- php-src/ext/standard/tests/strings/strings001.phpt:1.2 Sat Oct 26 20:07:49 2002 +++ php-src/ext/standard/tests/strings/strings001.phpt Tue Aug 8 10:22:25 2006 @@ -9,4 +9,4 @@ ? --EXPECTREGEX-- string\(18\) \nica\x00turska panica\ -string\(19\) \ nica\x00turska panica\ +string\(7\) \ panica\ -- 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/standard string.c /ext/standard/tests/strings pathinfo.phpt
tony2001Mon Jul 17 06:45:08 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/standard/tests/strings pathinfo.phpt Modified files: /php-src/ext/standard string.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.6r2=1.445.2.14.2.7diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.6 php-src/ext/standard/string.c:1.445.2.14.2.7 --- php-src/ext/standard/string.c:1.445.2.14.2.6Sun Jul 16 10:37:24 2006 +++ php-src/ext/standard/string.c Mon Jul 17 06:45:08 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.445.2.14.2.6 2006/07/16 10:37:24 helly Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.7 2006/07/17 06:45:08 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1341,7 +1341,7 @@ { zval *tmp; char *path, *ret = NULL; - int path_len; + int path_len, have_basename; size_t ret_len; long opt = PHP_PATHINFO_ALL; @@ -1349,6 +1349,8 @@ return; } + have_basename = ((opt PHP_PATHINFO_BASENAME) == PHP_PATHINFO_BASENAME); + MAKE_STD_ZVAL(tmp); array_init(tmp); @@ -1359,19 +1361,18 @@ add_assoc_string(tmp, dirname, ret, 1); } efree(ret); + ret = NULL; } - if ((opt PHP_PATHINFO_BASENAME) == PHP_PATHINFO_BASENAME) { + if (have_basename) { php_basename(path, path_len, NULL, 0, ret, ret_len TSRMLS_CC); add_assoc_stringl(tmp, basename, ret, ret_len, 0); - } + } if ((opt PHP_PATHINFO_EXTENSION) == PHP_PATHINFO_EXTENSION) { char *p; int idx; - int have_basename = ((opt PHP_PATHINFO_BASENAME) == PHP_PATHINFO_BASENAME); - /* Have we alrady looked up the basename? */ if (!have_basename) { php_basename(path, path_len, NULL, 0, ret, ret_len TSRMLS_CC); } @@ -1382,19 +1383,14 @@ idx = p - ret; add_assoc_stringl(tmp, extension, ret + idx + 1, ret_len - idx - 1, 1); } - - if (!have_basename) { - efree(ret); - } } if ((opt PHP_PATHINFO_FILENAME) == PHP_PATHINFO_FILENAME) { char *p; int idx; - int have_basename = ((opt PHP_PATHINFO_BASENAME) == PHP_PATHINFO_BASENAME); /* Have we alrady looked up the basename? */ - if (!have_basename) { + if (!have_basename !ret) { php_basename(path, path_len, NULL, 0, ret, ret_len TSRMLS_CC); } @@ -1402,10 +1398,10 @@ idx = p ? (p - ret) : ret_len; add_assoc_stringl(tmp, filename, ret, idx, 1); + } - if (!have_basename) { - efree(ret); - } + if (!have_basename ret) { + efree(ret); } if (opt == PHP_PATHINFO_ALL) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/pathinfo.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/strings/pathinfo.phpt +++ php-src/ext/standard/tests/strings/pathinfo.phpt --TEST-- pathinfo() tests --FILE-- ?php var_dump(pathinfo()); var_dump(pathinfo()); var_dump(pathinfo(.)); var_dump(pathinfo(..)); var_dump(pathinfo(/)); var_dump(pathinfo(./)); var_dump(pathinfo(/.)); var_dump(pathinfo(.cvsignore)); var_dump(pathinfo(__FILE__, PATHINFO_BASENAME)); var_dump(pathinfo(__FILE__, PATHINFO_FILENAME)); var_dump(pathinfo(__FILE__, PATHINFO_EXTENSION)); var_dump(pathinfo(__FILE__, PATHINFO_DIRNAME)); var_dump(pathinfo(__FILE__, PATHINFO_EXTENSION|PATHINFO_FILENAME|PATHINFO_DIRNAME)); var_dump(pathinfo(__FILE__, PATHINFO_EXTENSION|PATHINFO_FILENAME|PATHINFO_BASENAME)); var_dump(pathinfo(__FILE__, PATHINFO_EXTENSION|PATHINFO_FILENAME)); var_dump(pathinfo(__FILE__, PATHINFO_EXTENSION|PATHINFO_BASENAME)); var_dump(pathinfo(__FILE__, PATHINFO_FILENAME|PATHINFO_DIRNAME)); var_dump(pathinfo(__FILE__, PATHINFO_FILENAME|PATHINFO_BASENAME)); var_dump(pathinfo(__FILE__, PATHINFO_DIRNAME|PATHINFO_EXTENSION)); var_dump(pathinfo(__FILE__, PATHINFO_DIRNAME|PATHINFO_BASENAME)); echo Done\n; ? --EXPECTF-- Warning: pathinfo() expects at least 1 parameter, 0 given in %s on line %d NULL array(2) { [basename]= string(0) [filename]= string(0) } array(4) { [dirname]= string(1) . [basename]= string(1) . [extension]= string(0) [filename]= string(0) } array(4) { [dirname]= string(1) . [basename]= string(2) .. [extension]= string(0) [filename]=