Skip to content

Commit 58bb4ad

Browse files
author
Sascha Schumann
committed
use the same version as in php3
1 parent 63f7648 commit 58bb4ad

File tree

1 file changed

+0
-54
lines changed

1 file changed

+0
-54
lines changed

ext/standard/string.c

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,11 +1344,6 @@ PHPAPI void _php3_char_to_str(char *str,uint len,char from,char *to,int to_len,p
13441344
*target = 0;
13451345
}
13461346

1347-
#if 0
1348-
/*
1349-
* this is a binary safe equivalent to strnstr
1350-
* note that we don't check for the end in str_to_str but here
1351-
*/
13521347

13531348
static inline char *
13541349
_php3_memnstr(char *haystack, char *needle, int needle_len, char *end)
@@ -1414,55 +1409,6 @@ PHPAPI char *_php3_str_to_str(char *haystack, int length,
14141409
return new;
14151410
}
14161411

1417-
#else
1418-
1419-
static char *_php3_memstr(char *s, char *c, size_t n, size_t m)
1420-
{
1421-
char *p;
1422-
1423-
for(p = s; (p - s) < n; p++)
1424-
if(memcmp(p, c, m) == 0)
1425-
return p;
1426-
return NULL;
1427-
}
1428-
1429-
#define ATTCHSTR(st, sz) \
1430-
nl += sz; \
1431-
n = erealloc(n, nl + 1); \
1432-
memcpy(n + no, st, sz); \
1433-
no += sz
1434-
1435-
1436-
PHPAPI char *_php3_str_to_str(char *a, int al, char *b, int bl, char *c, int cl,
1437-
int *newlen)
1438-
{
1439-
char *n = NULL, *p, *q;
1440-
int nl = 0;
1441-
int no = 0;
1442-
1443-
/* run through all occurences of b in a */
1444-
for(p = q = a; (p = _php3_memstr(p, b, al - (p - a), bl)); q = p) {
1445-
/* attach everything between the previous occ. and this one */
1446-
ATTCHSTR(q, p - q);
1447-
/* attach the replacement string c */
1448-
ATTCHSTR(c, cl);
1449-
/* jump over string b in a */
1450-
p += bl;
1451-
}
1452-
1453-
/* anything left over ? */
1454-
if((al - (q - a)) > 0) {
1455-
ATTCHSTR(q, al - (q - a));
1456-
}
1457-
1458-
if(newlen) *newlen = nl;
1459-
n[nl] = '\0';
1460-
1461-
return n;
1462-
}
1463-
1464-
#undef ATTCHSTR
1465-
#endif
14661412

14671413
/* {{{ proto string str_replace(string needle, string str, string haystack)
14681414
Replace all occurrences of needle in haystack with str */

0 commit comments

Comments
 (0)