Skip to content

Commit

Permalink
stdlib: Corrected implementation of SDL_wcsncmp.
Browse files Browse the repository at this point in the history
It was a copy/paste of SDL_strcmp, apparently, not SDL_strncmp, so it ignored
the maxlen parameter.

Thanks to Jack Powell for pointing this out!
  • Loading branch information
icculus committed Jul 25, 2020
1 parent c7eb557 commit e410b34
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/stdlib/SDL_string.c
Expand Up @@ -516,13 +516,18 @@ SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
#if defined(HAVE_WCSNCMP)
return wcsncmp(str1, str2, maxlen);
#else
while (*str1 && *str2) {
while (*str1 && *str2 && maxlen) {
if (*str1 != *str2)
break;
++str1;
++str2;
--maxlen;
}
return (int)(*str1 - *str2);
if (!maxlen) {
return 0;
}
return (int) (*str1 - *str2);

#endif /* HAVE_WCSNCMP */
}

Expand Down

0 comments on commit e410b34

Please sign in to comment.