fix replacing ignorecase with multiple things to replace
This commit is contained in:
parent
ae793ea029
commit
f1ef095a9c
1 changed files with 7 additions and 4 deletions
11
uwufetch.c
11
uwufetch.c
|
@ -173,7 +173,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
for (int i = 0; gpu_model[i][0]; i++)
|
for (int i = 0; gpu_model[i][0]; i++)
|
||||||
{
|
{
|
||||||
uwu_hw(gpu_model[i]);
|
uwu_hw(gpu_model[i]);
|
||||||
}
|
}
|
||||||
uwu_hw(cpu_model);
|
uwu_hw(cpu_model);
|
||||||
uwu_hw(host_model);
|
uwu_hw(host_model);
|
||||||
|
@ -708,11 +708,12 @@ replace("Hello World!", "World", "everyone")
|
||||||
*/
|
*/
|
||||||
void replace(char *original, char *search, char *replacer)
|
void replace(char *original, char *search, char *replacer)
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
|
||||||
char *ch;
|
char *ch;
|
||||||
if (!(ch = strstr(original, search)))
|
if (!(ch = strstr(original, search)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
char buffer[1024];
|
||||||
|
|
||||||
strncpy(buffer, original, ch - original);
|
strncpy(buffer, original, ch - original);
|
||||||
buffer[ch - original] = 0;
|
buffer[ch - original] = 0;
|
||||||
sprintf(buffer + (ch - original), "%s%s", replacer, ch + strlen(search));
|
sprintf(buffer + (ch - original), "%s%s", replacer, ch + strlen(search));
|
||||||
|
@ -724,18 +725,20 @@ void replace(char *original, char *search, char *replacer)
|
||||||
|
|
||||||
void replace_ignorecase(char *original, char *search, char *replacer)
|
void replace_ignorecase(char *original, char *search, char *replacer)
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
|
||||||
char *ch;
|
char *ch;
|
||||||
if (!(ch = strcasestr(original, search)))
|
if (!(ch = strcasestr(original, search)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
char buffer[1024];
|
||||||
|
|
||||||
strncpy(buffer, original, ch - original);
|
strncpy(buffer, original, ch - original);
|
||||||
buffer[ch - original] = 0;
|
buffer[ch - original] = 0;
|
||||||
sprintf(buffer + (ch - original), "%s%s", replacer, ch + strlen(search));
|
sprintf(buffer + (ch - original), "%s%s", replacer, ch + strlen(search));
|
||||||
|
|
||||||
original[0] = 0;
|
original[0] = 0;
|
||||||
strcpy(original, buffer);
|
strcpy(original, buffer);
|
||||||
return replace(original, search, replacer);
|
replace(original, search, replacer);
|
||||||
|
return replace_ignorecase(original, search, replacer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ascii()
|
void print_ascii()
|
||||||
|
|
Loading…
Reference in a new issue