non recursive string_replace

Previous to this commit a replacement that also contains the needle
would cause an endless loop
This commit is contained in:
Sascha Kruse 2012-12-07 05:16:48 +01:00
parent 62ecd76cfe
commit ae21145121

View File

@ -43,12 +43,8 @@ char *string_replace(const char *needle, const char *replacement,
sprintf(tmp + strlen(tmp), "%s%s", replacement, start + strlen(needle)); sprintf(tmp + strlen(tmp), "%s%s", replacement, start + strlen(needle));
free(haystack); free(haystack);
if (strstr(tmp, needle)) {
return string_replace(needle, replacement, tmp);
} else {
return tmp; return tmp;
} }
}
int digit_count(int i) int digit_count(int i)
{ {