4bool StrReplace(
char *String,
const char *Find,
const char *Replace)
8 int FindLen, ReplaceLen;
13 if(!String || !Find || !Replace)
20 if(!String[0] || !Find[0])
27 if(!strstr(String, Find))
33 FindLen = strlen(Find);
34 ReplaceLen = strlen(Replace);
35 if(FindLen >= ReplaceLen)
45 TAP_MemCpy(p, (
void *) Replace, ReplaceLen);
46 strcpy(p + ReplaceLen, p + FindLen);
53 char *TempBuffer, *s, *d;
70 TempBuffer = TAP_MemAlloc(strlen(String) + NrOfOccurences*(ReplaceLen - FindLen) + 1);
80 TAP_MemCpy(d, s, p - s);
82 TAP_MemCpy(d, (
void *) Replace, ReplaceLen);
91 strcpy(String, TempBuffer);
92 TAP_MemFree(TempBuffer);
bool StrReplace(char *String, const char *Find, const char *Replace)