CVS update: php3/functions
| From: | sas | Date: | Tue, 05 Jan 1999 16:33:08 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3288@lists.php.net to get a copy of this message | ||
Date: Tuesday January 5, 1999 @ 11:33
Author: sas
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv20998/functions
Modified Files:
string.c
Log Message:
Okay, this should produce correct results even in the last
special case now. Tested (not only) with
$file = "/netbsd";
$fd = fopen($file, "r");
$buf = fread($fd, filesize($file));
fclose($fd);
$rep = str_replace("\0\0", "thiswasnull", $buf);
$rep2 = str_replace("thiswasnull", "\0\0", $rep);
echo !strcmp($rep2, $buf) ? "no differences<br>\n" : "diffs<br>\n";
Index: php3/functions/string.c
diff -c php3/functions/string.c:1.167 php3/functions/string.c:1.168
*** php3/functions/string.c:1.167 Tue Jan 5 07:54:04 1999
--- php3/functions/string.c Tue Jan 5 11:33:03 1999
***************
*** 30,36 ****
*/
! /* $Id: string.c,v 1.167 1999/01/05 12:54:04 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 30,36 ----
*/
! /* $Id: string.c,v 1.168 1999/01/05 16:33:03 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 1320,1327 ****
char *p = haystack;
char *s = NULL;
! for(; p < end - needle_len + 1&&
! (s = memchr(p, *needle, end - haystack)); p = s + 1) {
if(memcmp(s, needle, needle_len) == 0)
return s;
}
--- 1320,1327 ----
char *p = haystack;
char *s = NULL;
! for(; p < end - needle_len &&
! (s = memchr(p, *needle, end - p - needle_len)); p = s + 1) {
if(memcmp(s, needle, needle_len) == 0)
return s;
}
***************
*** 1351,1362 ****
off = realloc(new, (q - new) + (r - p) + (str_len) + 1);
if(off != new) {
if(!off) {
! /* we should raise a warning here */
! *q = '\0';
! if(_new_length) *_new_length = q - new;
! return new;
}
- /* correct pointers */
q += off - new;
new = off;
}
--- 1351,1358 ----
off = realloc(new, (q - new) + (r - p) + (str_len) + 1);
if(off != new) {
if(!off) {
! goto finish;
}
q += off - new;
new = off;
}
***************
*** 1365,1378 ****
memcpy(q, str, str_len);
q += str_len;
p = r + needle_len;
}
/* if there is a rest, copy it */
! if((end - p)) {
s = (q) + (end - p);
! new = realloc(new, s - new + 1);
memcpy(q, p, end - p);
q = s;
}
*q = '\0';
if(_new_length) *_new_length = q - new;
return new;
--- 1361,1384 ----
memcpy(q, str, str_len);
q += str_len;
p = r + needle_len;
+ hits++;
}
+
/* if there is a rest, copy it */
! if((end - p) > 0) {
s = (q) + (end - p);
! off = realloc(new, s - new + 1);
! if(off != new) {
! if(!off) {
! goto finish;
! }
! q += off - new;
! new = off;
! }
memcpy(q, p, end - p);
q = s;
}
+ finish:
*q = '\0';
if(_new_length) *_new_length = q - new;
return new;
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net