cvs: php4 /ext/standard string.c
| From: | James Moore | Date: | Fri, 02 Nov 2001 19:19:24 +0000 |
| Subject: | cvs: php4 /ext/standard string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-8061@lists.php.net to get a copy of this message | ||
jmoore Fri Nov 2 14:19:24 2001 EDT
Modified files:
/php4/ext/standard string.c
Log:
@- Fix behaviour of strtok. Bug 13866 (jmoore)
# I have brought the behaviour of strtok into line with how the
# libc strtok's behave. currently given
# <string1><token><string2><token><token>string>
# three recursive calls to strtok returns <string1>. <string2>,
<token><string3>
# it now returns <string1>, <string2>, <string3>. (there was some
# debate in #php.bugs if it should return <string1>, <string2>, false, <string3>
# but php's strtok now behaves the same way as the libc version.
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.250 php4/ext/standard/string.c:1.251
--- php4/ext/standard/string.c:1.250 Thu Oct 4 11:25:39 2001
+++ php4/ext/standard/string.c Fri Nov 2 14:19:24 2001
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.250 2001/10/04 15:25:39 derick Exp $ */
+/* $Id: string.c,v 1.251 2001/11/02 19:19:24 jmoore Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -923,6 +923,7 @@
char *token_end;
char *p;
char *pe;
+ int skipped = 0;
if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2 ||
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE)
@@ -963,12 +964,15 @@
/* Skip leading delimiters */
while (STRTOK_TABLE(p))
+ {
if (++p >= pe) {
/* no other chars left */
BG(strtok_last) = NULL;
RETVAL_FALSE;
goto restore;
}
+ skipped++;
+ }
/* We know at this place that *p is no delimiter, so skip it */
while (++p < pe)
@@ -977,7 +981,7 @@
if (p - BG(strtok_last)) {
return_token:
- RETVAL_STRINGL(BG(strtok_last), p - BG(strtok_last), 1);
+ RETVAL_STRINGL(BG(strtok_last) + skipped, (p - BG(strtok_last)) - skipped, 1);
BG(strtok_last) = p + 1;
} else {
RETVAL_FALSE;