Fixed a signed / unsigned issue.

# imagine the case like "\\\xfe" where walk[1] takes a value that is greater
# than 127 in integer...
This commit is contained in:
Moriyoshi Koizumi 2003-02-24 16:29:00 +00:00
parent 73bae37f26
commit f73f94f258
2 changed files with 2 additions and 2 deletions

View file

@ -324,7 +324,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
new_l = strlen(buf) + subs[0].rm_so; /* part before the match */ new_l = strlen(buf) + subs[0].rm_so; /* part before the match */
walk = replace; walk = replace;
while (*walk) { while (*walk) {
if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= ((char) re.re_nsub)) { if ('\\' == *walk && isdigit(walk[1]) && ((unsigned char)walk[1]) - '0' <= re.re_nsub) {
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) { if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) {
new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so; new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so;
} }

View file

@ -324,7 +324,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
new_l = strlen(buf) + subs[0].rm_so; /* part before the match */ new_l = strlen(buf) + subs[0].rm_so; /* part before the match */
walk = replace; walk = replace;
while (*walk) { while (*walk) {
if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= ((char) re.re_nsub)) { if ('\\' == *walk && isdigit(walk[1]) && ((unsigned char)walk[1]) - '0' <= re.re_nsub) {
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) { if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) {
new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so; new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so;
} }