I stumbled upon bug #24281 while running a few test on the current HEAD
for PHP5--it seems to me that it should be sufficient to change a single
line of code to make str_replace() work as expected, but I'm not
familiar enough with the internals to know whether my fix is good or
not...so, here it is. It seems to work for my test case, and for the
test case reported in the bug.
Cheers,
Marco
Index: string.c
RCS file: /repository/php4/ext/standard/string.c,v
retrieving revision 1.391
diff -u -r1.391 string.c
--- string.c 20 Jun 2003 15:41:43 -0000 1.391
+++ string.c 22 Jun 2003 13:06:51 -0000
@@ -3194,7 +3194,7 @@
php_str_replace_in_subject(*search, *replace, subject, return_value, case_sensitivity, (argc > 3) ? &count : NULL);
}
if (argc > 3) {
-
Z_LVAL_PP(zcount) = count;
-
ZVAL_LONG(*zcount, count); }
}
/* }}} */
Take two (this time hopefully clearing the variable before resetting it):
Index: string.c
RCS file: /repository/php4/ext/standard/string.c,v
retrieving revision 1.391
diff -u -r1.391 string.c
--- string.c 20 Jun 2003 15:41:43 -0000 1.391
+++ string.c 22 Jun 2003 13:29:22 -0000
@@ -3194,7 +3194,8 @@
php_str_replace_in_subject(*search, *replace, subject, return_value, case_sensitivity, (argc > 3) ? &count : NULL);
}
if (argc > 3) {
-
Z_LVAL_PP(zcount) = count;
-
zval_dtor(*zcount); -
ZVAL_LONG(*zcount, count); }
}
/* }}} */