[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
pollita Fri Jun 20 11:44:48 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: MFH (r-1.391) When skipping blank searchvals we should advance the corresponding replace hash as well Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.30 php4/ext/standard/string.c:1.333.2.31 --- php4/ext/standard/string.c:1.333.2.30 Tue Jun 10 22:16:49 2003 +++ php4/ext/standard/string.c Fri Jun 20 11:44:48 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.30 2003/06/11 02:16:49 iliaa Exp $ */ +/* $Id: string.c,v 1.333.2.31 2003/06/20 15:44:48 pollita Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -2629,6 +2629,9 @@ convert_to_string(*search_entry); if (Z_STRLEN_PP(search_entry) == 0) { zend_hash_move_forward(Z_ARRVAL_P(search)); + if (Z_TYPE_P(replace) == IS_ARRAY) { + zend_hash_move_forward(Z_ARRVAL_P(replace)); + } continue; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
iliaa Tue Jun 10 22:16:50 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: MFH: proto fix Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.29 php4/ext/standard/string.c:1.333.2.30 --- php4/ext/standard/string.c:1.333.2.29 Mon May 26 16:56:01 2003 +++ php4/ext/standard/string.c Tue Jun 10 22:16:49 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.29 2003/05/26 20:56:01 msopacua Exp $ */ +/* $Id: string.c,v 1.333.2.30 2003/06/11 02:16:49 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -4024,7 +4024,7 @@ } /* }}} */ -/* {{{ proto void str_word_count(string str, [int format]) +/* {{{ proto mixed str_word_count(string str, [int format]) Counts the number of words inside a string. If format of 1 is specified, then the function will return an array containing all the words found inside the string. If format of 2 is specified, then the function -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
derick Thu Apr 3 01:21:21 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: - CS Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.20 php4/ext/standard/string.c:1.333.2.21 --- php4/ext/standard/string.c:1.333.2.20 Wed Apr 2 16:31:52 2003 +++ php4/ext/standard/string.c Thu Apr 3 01:21:21 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.20 2003/04/02 21:31:52 rasmus Exp $ */ +/* $Id: string.c,v 1.333.2.21 2003/04/03 06:21:21 derick Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3121,7 +3121,9 @@ } while (1) { if (Z_TYPE_PP(args[1]) == IS_ARRAY) { - if(!zend_hash_num_elements(Z_ARRVAL_PP(args[1]))) break; + if (!zend_hash_num_elements(Z_ARRVAL_PP(args[1]))) { + break; + } zend_hash_get_current_data(Z_ARRVAL_PP(args[1]),(void **)plocale); } else { plocale = args[i]; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
iliaa Tue Apr 1 19:25:57 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: MFH Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.18 php4/ext/standard/string.c:1.333.2.19 --- php4/ext/standard/string.c:1.333.2.18 Fri Mar 7 08:42:20 2003 +++ php4/ext/standard/string.c Tue Apr 1 19:25:57 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.18 2003/03/07 13:42:20 ddhill Exp $ */ +/* $Id: string.c,v 1.333.2.19 2003/04/02 00:25:57 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3531,6 +3531,10 @@ /* Initialize the result string */ result_len = Z_STRLEN_PP(input_str) * Z_LVAL_PP(mult); + if (result_len 1 || result_len 2147483647) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, You may not create strings longer then 2147483647 bytes); + RETURN_FALSE; + } result = (char *)emalloc(result_len + 1); /* Heavy optimization for situations where input string is 1 byte long */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c /ext/standard/tests/strings bug22224.phpt
moriyoshi Fri Feb 14 13:44:51 2003 EDT Added files: (Branch: PHP_4_3) /php4/ext/standard/tests/stringsbug4.phpt Modified files: /php4/ext/standard string.c Log: MFH(r1.357): Fixed bug #4 MFH: Added test case for the bug Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.12 php4/ext/standard/string.c:1.333.2.13 --- php4/ext/standard/string.c:1.333.2.12 Mon Feb 10 14:37:27 2003 +++ php4/ext/standard/string.c Fri Feb 14 13:44:50 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.12 2003/02/10 19:37:27 pollita Exp $ */ +/* $Id: string.c,v 1.333.2.13 2003/02/14 18:44:50 moriyoshi Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -836,7 +836,8 @@ while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **) tmp, pos) == SUCCESS) { - convert_to_string_ex(tmp); + SEPARATE_ZVAL(tmp); + convert_to_string(tmp); smart_str_appendl(implstr, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); if (++i != numelems) { Index: php4/ext/standard/tests/strings/bug4.phpt +++ php4/ext/standard/tests/strings/bug4.phpt --TEST-- Bug #4 (implode changes object references in array) --INI-- error_reporting=0 --FILE-- ?php class foo { } $a = new foo(); $arr = array(0=$a, 1=$a); var_dump(implode(,,$arr)); var_dump($arr) ? --EXPECT-- string(13) Object,Object array(2) { [0]= object(foo)(0) { } [1]= object(foo)(0) { } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
moriyoshi Fri Feb 14 14:00:44 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: MFH(r1.358): Fixed a str_replace() bug similar to bug #4 Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.13 php4/ext/standard/string.c:1.333.2.14 --- php4/ext/standard/string.c:1.333.2.13 Fri Feb 14 13:44:50 2003 +++ php4/ext/standard/string.c Fri Feb 14 14:00:43 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.13 2003/02/14 18:44:50 moriyoshi Exp $ */ +/* $Id: string.c,v 1.333.2.14 2003/02/14 19:00:43 moriyoshi Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -2621,7 +2621,8 @@ /* For each entry in the search array, get the entry */ while (zend_hash_get_current_data(Z_ARRVAL_P(search), (void **) search_entry) == SUCCESS) { /* Make sure we're dealing with strings. */ - convert_to_string_ex(search_entry); + SEPARATE_ZVAL(search_entry); + convert_to_string(*search_entry); if (Z_STRLEN_PP(search_entry) == 0) { zend_hash_move_forward(Z_ARRVAL_P(search)); continue; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
moriyoshi Fri Feb 14 14:07:38 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: Fixed wrong commit: s//*/ Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.14 php4/ext/standard/string.c:1.333.2.15 --- php4/ext/standard/string.c:1.333.2.14 Fri Feb 14 14:00:43 2003 +++ php4/ext/standard/string.c Fri Feb 14 14:07:38 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.14 2003/02/14 19:00:43 moriyoshi Exp $ */ +/* $Id: string.c,v 1.333.2.15 2003/02/14 19:07:38 moriyoshi Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -837,7 +837,7 @@ (void **) tmp, pos) == SUCCESS) { SEPARATE_ZVAL(tmp); - convert_to_string(tmp); + convert_to_string(*tmp); smart_str_appendl(implstr, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); if (++i != numelems) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
pollita Mon Feb 10 14:37:27 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: Partial MFH. Deprecated BM algo for str_replace can hang execution. See Bug#22141 Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.11 php4/ext/standard/string.c:1.333.2.12 --- php4/ext/standard/string.c:1.333.2.11 Mon Jan 27 11:22:33 2003 +++ php4/ext/standard/string.c Mon Feb 10 14:37:27 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.11 2003/01/27 16:22:33 andrey Exp $ */ +/* $Id: string.c,v 1.333.2.12 2003/02/10 19:37:27 pollita Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -2553,86 +2553,6 @@ } /* }}} */ -/* {{{ boyer_str_to_str */ -static char *boyer_str_to_str(char *haystack, int length, - char *needle, int needle_len, char *str, - int str_len, int *new_length) -{ - char *p, *pe, *cursor, *end, *r; - int off; - char jump_table[256]; - smart_str result = {0}; - - /* -* We implement only the first half of the Boyer-Moore algorithm, -* because the second half is too expensive to compute during run-time. -* TODO: Split matching into compile-/match-stage. -*/ - - /* Prepare the jump_table which contains the skip offsets */ - memset(jump_table, needle_len, 256); - - off = needle_len - 1; - - /* Calculate the default start where each comparison starts */ - pe = needle + off; - - /* Assign skip offsets based on the pattern */ - for (p = needle; p = pe; p++) - jump_table[(unsigned char) *p] = off--; - - /* Start to look at the first possible position for the pattern */ - cursor = haystack + needle_len - 1; - - /* The cursor must not cross this limit */ - end = haystack + length; - - /* Start to copy at haystack */ - r = haystack; - -nextiter: - while (cursor end) { - p = pe; /* Compare from right to left */ - while (*p == *cursor) { - if (--p needle) { /* Found the pattern */ - - /* Append whatever was not matched */ - smart_str_appendl(result, r, cursor - r); - - /* Append replacement string */ - smart_str_appendl(result, str, str_len); - - /* Update copy pointer */ - r = cursor + needle_len; - - /* needle_len was substracted from cursor for -* this comparison, add it back. Also add -* needle_len - 1 which is the default search -* offset. -*/ - cursor += (needle_len 1) - 1; - - /* Next iteration */ - goto nextiter; - } - cursor--; - } - - cursor += jump_table[(unsigned char) *cursor]; - } - - if (r end)/* Copy the remaining data */ - smart_str_appendl(result, r, end - r); - - smart_str_0(result); /* NUL-ify result */ - - if (new_length) - *new_length = result.len; - - return result.c; -} -/* }}} */ - /* {{{ php_str_to_str */ PHPAPI char *php_str_to_str(char *haystack, int length, @@ -2664,17 +2584,14 @@ /* {{{ php_str_replace_in_subject */ -static void php_str_replace_in_subject(zval *search, zval *replace, zval **subject, zval *result, int boyer) +static void php_str_replace_in_subject(zval *search, zval *replace, zval **subject, +zval *result) { zval**search_entry, **replace_entry = NULL, temp_result; char*replace_value = NULL; int replace_len = 0; - char *(*str_to_str)(char *, int, char *, int, char *, int, int *); - str_to_str = boyer ? boyer_str_to_str : php_str_to_str; - /* Make sure we're dealing with strings. */ convert_to_string_ex(subject); Z_TYPE_P(result) = IS_STRING; @@ -2736,9 +2653,9 @@ replace_len, temp_result); } else if
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
andrey Mon Jan 27 11:22:33 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: MFH Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.10 php4/ext/standard/string.c:1.333.2.11 --- php4/ext/standard/string.c:1.333.2.10 Sun Jan 19 07:56:25 2003 +++ php4/ext/standard/string.c Mon Jan 27 11:22:33 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.10 2003/01/19 12:56:25 moriyoshi Exp $ */ +/* $Id: string.c,v 1.333.2.11 2003/01/27 16:22:33 andrey Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -202,7 +202,7 @@ static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) { char *s11, *s22; - long len1, len2, start, len; + int len1, len2, start, len; start = 0; len = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c /ext/standard/tests/strings bug21744.phpt
moriyoshi Sun Jan 19 07:56:26 2003 EDT Added files: (Branch: PHP_4_3) /php4/ext/standard/tests/stringsbug21744.phpt Modified files: /php4/ext/standard string.c Log: MFH: fixed bug #21744 Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.9 php4/ext/standard/string.c:1.333.2.10 --- php4/ext/standard/string.c:1.333.2.9Mon Jan 6 17:16:29 2003 +++ php4/ext/standard/string.c Sun Jan 19 07:56:25 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.9 2003/01/06 22:16:29 iliaa Exp $ */ +/* $Id: string.c,v 1.333.2.10 2003/01/19 12:56:25 moriyoshi Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3515,8 +3515,16 @@ state = 3; lc = c; } else { - *(rp++) = c; - } + if (state == 0) { + *(rp++) = c; + } else if (allow state == 1) { + *(tp++) = c; + if ( (tp-tbuf) = PHP_TAG_BUF_SIZE ) { + /* prevent buffer overflows */ + tp = tbuf; + } + } + } break; case '?': Index: php4/ext/standard/tests/strings/bug21744.phpt +++ php4/ext/standard/tests/strings/bug21744.phpt --TEST-- Bug #21744 (strip_tags misses exclamation marks in alt text) --FILE-- ?php $test = HERE a href=test?test\\!!!testtest/a !-- test -- HERE; print strip_tags($test, ''); print strip_tags($test, 'a'); ? --EXPECT-- test a href=test?test\!!!testtest/a -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
derick Fri Jan 3 07:31:13 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: - MFH for bug #21311 Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.5 php4/ext/standard/string.c:1.333.2.6 --- php4/ext/standard/string.c:1.333.2.5Tue Dec 31 11:35:34 2002 +++ php4/ext/standard/string.c Fri Jan 3 07:31:13 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.5 2002/12/31 16:35:34 sebastian Exp $ */ +/* $Id: string.c,v 1.333.2.6 2003/01/03 12:31:13 derick Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1399,6 +1399,9 @@ if (Z_TYPE_PP(needle) == IS_STRING) { if (!Z_STRLEN_PP(needle)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Empty delimiter.); + efree(haystack_orig); + zval_ptr_dtor(haystack); + zval_ptr_dtor(needle); RETURN_FALSE; } @@ -3509,11 +3512,12 @@ /* JavaScript Other HTML scripting languages */ if (state == 1 *(p-1) == '') { state = 3; + lc = c; } else { *(rp++) = c; } break; - + case '?': if (state == 1 *(p-1)=='') { @@ -3522,13 +3526,28 @@ break; } + case 'E': + case 'e': + /* !DOCTYPE exception */ + if (state==3 p buf+6 + tolower(*(p-1)) == 'p' + tolower(*(p-2)) == 'y' + tolower(*(p-3)) == 't' + tolower(*(p-4)) == 'c' + tolower(*(p-5)) == 'o' + tolower(*(p-6)) == 'd') { + state = 1; + break; + } + /* fall-through */ + case 'l': /* swm: If we encounter '?xml' then we shouldn't be in * state == 2 (PHP). Switch back to HTML. */ - if (state == 2 *(p-1) == 'm' *(p-2) == 'x') { + if (state == 2 p buf+2 *(p-1) == 'm' *(p-2) +== 'x') { state = 1; break; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
derick Fri Jan 3 13:57:38 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: - Remove broken lines (due to MFH) Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.6 php4/ext/standard/string.c:1.333.2.7 --- php4/ext/standard/string.c:1.333.2.6Fri Jan 3 07:31:13 2003 +++ php4/ext/standard/string.c Fri Jan 3 13:57:37 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.6 2003/01/03 12:31:13 derick Exp $ */ +/* $Id: string.c,v 1.333.2.7 2003/01/03 18:57:37 derick Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1399,9 +1399,6 @@ if (Z_TYPE_PP(needle) == IS_STRING) { if (!Z_STRLEN_PP(needle)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Empty delimiter.); - efree(haystack_orig); - zval_ptr_dtor(haystack); - zval_ptr_dtor(needle); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
sterlingThu Dec 26 22:22:42 2002 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: mfh Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.3 php4/ext/standard/string.c:1.333.2.4 --- php4/ext/standard/string.c:1.333.2.3Thu Dec 12 08:45:33 2002 +++ php4/ext/standard/string.c Thu Dec 26 22:22:42 2002 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.3 2002/12/12 13:45:33 iliaa Exp $ */ +/* $Id: string.c,v 1.333.2.4 2002/12/27 03:22:42 sterling Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1352,6 +1352,9 @@ if (Z_TYPE_PP(needle) == IS_STRING) { if (!Z_STRLEN_PP(needle)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Empty delimiter.); + efree(haystack_orig); + zval_ptr_dtor(haystack); + zval_ptr_dtor(needle); RETURN_FALSE; } @@ -1372,6 +1375,8 @@ RETVAL_FALSE; } + zval_ptr_dtor(haystack); + zval_ptr_dtor(needle); efree(haystack_orig); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c /ext/standard/tests/strings bug20927.phpt
iliaa Thu Dec 12 08:45:34 2002 EDT Added files: (Branch: PHP_4_3) /php4/ext/standard/tests/stringsbug20927.phpt Modified files: /php4/ext/standard string.c Log: MFH Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333.2.2 php4/ext/standard/string.c:1.333.2.3 --- php4/ext/standard/string.c:1.333.2.2Thu Dec 5 17:46:40 2002 +++ php4/ext/standard/string.c Thu Dec 12 08:45:33 2002 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333.2.2 2002/12/05 22:46:40 iliaa Exp $ */ +/* $Id: string.c,v 1.333.2.3 2002/12/12 13:45:33 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -628,7 +628,7 @@ { const char *text, *breakchar = \n; char *newtext; - int textlen, breakcharlen = 1, newtextlen; + int textlen, breakcharlen = 1, newtextlen, alloced, chk; long current = 0, laststart = 0, lastspace = 0; long linelength = 75; zend_bool docut = 0; @@ -670,18 +670,24 @@ } else { /* Multiple character line break or forced cut */ if (linelength 0) { - /* Add extra 10% to accomodate strings with unpredicatable number of breaks */ - newtextlen = textlen + (int)((textlen/linelength + 1) * breakcharlen * 1.1) + 1; + chk = (int)(textlen/linelength + 1); + alloced = textlen + chk * breakcharlen + 1; } else { - newtextlen = textlen * (breakcharlen + 1) + 1; + chk = textlen; + alloced = textlen * (breakcharlen + 1) + 1; } - newtext = emalloc(newtextlen); - + newtext = emalloc(alloced); + /* now keep track of the actual new text length */ newtextlen = 0; laststart = lastspace = 0; for (current = 0; current textlen; current++) { + if (chk = 0) { + alloced += (int) (((textlen - current + 1)/linelength ++ 1) * breakcharlen) + 1; + newtext = erealloc(newtext, alloced); + chk = (int) ((textlen - current)/linelength) + 1; + } /* when we hit an existing break, copy to new buffer, and * fix up laststart and lastspace */ if (text[current] == breakchar[0] @@ -691,6 +697,7 @@ newtextlen += current-laststart+breakcharlen; current += breakcharlen - 1; laststart = lastspace = current + 1; + chk--; } /* if it is a space, check if it is at the line boundary, * copy and insert a break, or just keep track of it */ @@ -701,6 +708,7 @@ memcpy(newtext+newtextlen, breakchar, breakcharlen); newtextlen += breakcharlen; laststart = current + 1; + chk--; } lastspace = current; } @@ -714,6 +722,7 @@ memcpy(newtext+newtextlen, breakchar, breakcharlen); newtextlen += breakcharlen; laststart = lastspace = current; + chk--; } /* if the current word puts us over the linelength, copy * back up until the last space, insert a break, and move @@ -725,6 +734,7 @@ memcpy(newtext+newtextlen, breakchar, breakcharlen); newtextlen += breakcharlen; laststart = lastspace = lastspace + 1; + chk--; } } Index: php4/ext/standard/tests/strings/bug20927.phpt +++ php4/ext/standard/tests/strings/bug20927.phpt --TEST-- Segfault on wordwrap statement bug #20927 --SKIPIF-- --FILE-- ?php $x = ADV:CLAIM YOUR FORTUNE NOW !!MAKE; $x .= xxHUNDREDS OF THOUSANDS; $b = CANITBREAKFOO\n; $x = wordwrap($x, 20, $b, 1); $x = wordwrap($x, 20, $b, 1); print $x\n; ? --EXPECT-- ADV:CLAIM YOURCANITBREAKFOO FORTUNE NOW !!MAKECANITBREAKFOO xxHUNDREDSCANITBREAKFOO OFCANITBREAKFOO THOUSANDSxxxCANITBREAKFOO x -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c /ext/standard/tests/strings strip_tags.phpt
iliaa Wed Nov 27 01:20:37 2002 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c /php4/ext/standard/tests/stringsstrip_tags.phpt Log: MFH Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.333 php4/ext/standard/string.c:1.333.2.1 --- php4/ext/standard/string.c:1.333Tue Nov 5 08:52:11 2002 +++ php4/ext/standard/string.c Wed Nov 27 01:20:37 2002 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: string.c,v 1.333 2002/11/05 13:52:11 moriyoshi Exp $ */ +/* $Id: string.c,v 1.333.2.1 2002/11/27 06:20:37 iliaa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3496,6 +3496,8 @@ /* JavaScript Other HTML scripting languages */ if (state == 1 *(p-1) == '') { state = 3; + } else { + *(rp++) = c; } break; Index: php4/ext/standard/tests/strings/strip_tags.phpt diff -u php4/ext/standard/tests/strings/strip_tags.phpt:1.1 php4/ext/standard/tests/strings/strip_tags.phpt:1.1.2.1 --- php4/ext/standard/tests/strings/strip_tags.phpt:1.1 Sat Sep 21 13:34:45 2002 +++ php4/ext/standard/tests/strings/strip_tags.phpt Wed Nov 27 01:20:37 2002 @@ -16,6 +16,8 @@ echo \n; echo strip_tags('NEAT ? echo \'\\\'\'? STUFF'); echo \n; + echo strip_tags('TESTS ?!!?!?!!!?!!'); + echo \n; ? --EXPECT-- NEAT STUFF @@ -24,3 +26,4 @@ NEAT STUFF NEAT STUFF NEAT STUFF +TESTS ?!!?!?!!!?!! -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard string.c
sander Sun Oct 6 07:31:20 2002 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard string.c Log: MFH Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.313 php4/ext/standard/string.c:1.313.2.1 --- php4/ext/standard/string.c:1.313Fri Oct 4 16:44:19 2002 +++ php4/ext/standard/string.c Sun Oct 6 07:31:19 2002 -18,7 +18,7 +--+ */ -/* $Id: string.c,v 1.313 2002/10/04 20:44:19 sterling Exp $ */ +/* $Id: string.c,v 1.313.2.1 2002/10/06 11:31:19 sander Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ -825,6 +825,10 numelems = zend_hash_num_elements(Z_ARRVAL_P(arr)); + if(numelems == 0) { + RETURN_EMPTY_STRING(); + } + zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **) tmp, -888,6 +892,8 zval_ptr_dtor(arg1); if (arg2) { zval_ptr_dtor(arg2); + } else { + FREE_ZVAL(delim); } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php