cvs: /php4/ext/standard string.c

From: Date: Wed, 21 Jul 1999 09:31:49 +0000
Subject: cvs: /php4/ext/standard string.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-2408@lists.php.net to get a copy of this message
sas Wed Jul 21 05:31:49 1999 EDT Modified files: /php4/ext/standard string.c Log: use the same version as in php3 Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.23 php4/ext/standard/string.c:1.24 --- php4/ext/standard/string.c:1.23 Fri Jul 16 13:06:48 1999 +++ php4/ext/standard/string.c Wed Jul 21 05:31:48 1999 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.23 1999/07/16 17:06:48 zeev Exp $ */ +/* $Id: string.c,v 1.24 1999/07/21 09:31:48 sas Exp $ */ /* Synced with php3 revision 1.193 1999-06-16 [ssb] */ @@ -1344,11 +1344,6 @@ *target = 0; } -#if 0 -/* - * this is a binary safe equivalent to strnstr - * note that we don't check for the end in str_to_str but here - */ static inline char * _php3_memnstr(char *haystack, char *needle, int needle_len, char *end) @@ -1414,55 +1409,6 @@ return new; } -#else - -static char *_php3_memstr(char *s, char *c, size_t n, size_t m) -{ - char *p; - - for(p = s; (p - s) < n; p++) - if(memcmp(p, c, m) == 0) - return p; - return NULL; -} - -#define ATTCHSTR(st, sz) \ - nl += sz; \ - n = erealloc(n, nl + 1); \ - memcpy(n + no, st, sz); \ - no += sz - - -PHPAPI char *_php3_str_to_str(char *a, int al, char *b, int bl, char *c, int cl, - int *newlen) -{ - char *n = NULL, *p, *q; - int nl = 0; - int no = 0; - - /* run through all occurences of b in a */ - for(p = q = a; (p = _php3_memstr(p, b, al - (p - a), bl)); q = p) { - /* attach everything between the previous occ. and this one */ - ATTCHSTR(q, p - q); - /* attach the replacement string c */ - ATTCHSTR(c, cl); - /* jump over string b in a */ - p += bl; - } - - /* anything left over ? */ - if((al - (q - a)) > 0) { - ATTCHSTR(q, al - (q - a)); - } - - if(newlen) *newlen = nl; - n[nl] = '\0'; - - return n; -} - -#undef ATTCHSTR -#endif /* {{{ proto string str_replace(string needle, string str, string haystack) Replace all occurrences of needle in haystack with str */

« previous php.version4 (#2408) next »