| 54 | } |
| 55 | |
| 56 | int |
| 57 | strncasecmp(const char *s1, const char *s2, size_t n) |
| 58 | { |
| 59 | |
| 60 | if (n != 0) { |
| 61 | const u_char *us1 = (const u_char *)s1; |
| 62 | const u_char *us2 = (const u_char *)s2; |
| 63 | |
| 64 | do { |
| 65 | if (tolower(*us1) != tolower(*us2)) |
| 66 | return (tolower(*us1) - tolower(*us2)); |
| 67 | if (*us1++ == '\0') |
| 68 | break; |
| 69 | us2++; |
| 70 | } while (--n != 0); |
| 71 | } |
| 72 | return (0); |
| 73 | } |