cvs: /php3 ChangeLog /php3/functions string.c

From: Date: Mon, 06 Dec 1999 17:49:15 +0000
Subject: cvs: /php3 ChangeLog /php3/functions string.c
Groups: php.dev 
Request: Send a blank email to php-dev+get-13473@lists.php.net to get a copy of this message
thies Mon Dec 6 12:49:15 1999 EDT Modified files: /php3 ChangeLog /php3/functions string.c Log: strpos is now binary-safe. Index: php3/ChangeLog diff -u php3/ChangeLog:1.797 php3/ChangeLog:1.798 --- php3/ChangeLog:1.797 Fri Dec 3 08:38:10 1999 +++ php3/ChangeLog Mon Dec 6 12:49:13 1999 @@ -2,6 +2,7 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| xx xx xxxx, Version 3.0.13 +- strpos() is now binary-safe. (Thies) - Add configure command to phpinfo() output (Stig) - added sketchy support for GNU recode 3.5 (Kristian) - Added tmpfile() function (Stig) Index: php3/functions/string.c diff -u php3/functions/string.c:1.202 php3/functions/string.c:1.203 --- php3/functions/string.c:1.202 Fri Nov 12 18:26:21 1999 +++ php3/functions/string.c Mon Dec 6 12:49:14 1999 @@ -30,7 +30,7 @@ */ -/* $Id: string.c,v 1.202 1999/11/12 23:26:21 cmv Exp $ */ +/* $Id: string.c,v 1.203 1999/12/06 17:49:14 thies Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif @@ -44,6 +44,8 @@ # include <locale.h> #endif +static inline char *_php3_memnstr(char *haystack, char *needle, int needle_len, char *end); + static char hexconvtab[] = "0123456789abcdef"; static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t *newlen) @@ -693,6 +695,8 @@ pval *haystack, *needle, *OFFSET; int offset = 0; char *found = NULL; + char *endp; + char *startp; TLS_VARS; switch(ARG_COUNT(ht)) { @@ -706,6 +710,10 @@ WRONG_PARAM_COUNT; } convert_to_long(OFFSET); + if (offset < 0) { + php3_error(E_WARNING,"offset not contained in string"); + RETURN_FALSE; + } offset = OFFSET->value.lval; break; default: @@ -717,15 +725,25 @@ RETURN_FALSE; } + startp = haystack->value.str.val; + startp+= offset; + + endp = haystack->value.str.val; + endp+= haystack->value.str.len; + if (needle->type == IS_STRING) { if (needle->value.str.len==0) { php3_error(E_WARNING,"Empty delimiter"); RETURN_FALSE; } - found = strstr(haystack->value.str.val+offset, needle->value.str.val); + found = _php3_memnstr(startp, needle->value.str.val, needle->value.str.len, endp); } else { + char buf; + convert_to_long(needle); - found = strchr(haystack->value.str.val+offset, (char) needle->value.lval); + buf = (char) needle->value.lval; + + found = _php3_memnstr(startp, &buf, 1, endp); } if (found) {

« previous php.dev (#13473) next »