getopt: fix null pointer arithmetic ub
[musl] / src / string / strncasecmp.c
1 #include <strings.h>
2 #include <ctype.h>
3
4 int strncasecmp(const char *_l, const char *_r, size_t n)
5 {
6         const unsigned char *l=(void *)_l, *r=(void *)_r;
7         if (!n--) return 0;
8         for (; *l && *r && n && (*l == *r || tolower(*l) == tolower(*r)); l++, r++, n--);
9         return tolower(*l) - tolower(*r);
10 }
11
12 int __strncasecmp_l(const char *l, const char *r, size_t n, locale_t loc)
13 {
14         return strncasecmp(l, r, n);
15 }
16
17 weak_alias(__strncasecmp_l, strncasecmp_l);