Skip to content

Commit

Permalink
Fix a bug in strcasestr
Browse files Browse the repository at this point in the history
It must use strncasecmp, not strncmp
  • Loading branch information
th-otto committed Jul 7, 2024
1 parent 1fcfd35 commit 5e1107c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion string/strcasestr.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ __strcasestr (const char* s, const char* wanted)
firstc = *wanted;
len = strlen (wanted);
for (scan = s;
toupper (*scan) != toupper (firstc) || strncmp(scan, wanted, len) != 0; )
toupper (*scan) != toupper (firstc) || strncasecmp(scan, wanted, len) != 0; )
if (*scan++ == '\0')
return NULL;
return (char*) scan;
Expand Down

0 comments on commit 5e1107c

Please sign in to comment.