diff options
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -2011,18 +2011,18 @@ strhash(st_data_t arg) int st_locale_insensitive_strcasecmp(const char *s1, const char *s2) { - unsigned int c1, c2; + char c1, c2; while (1) { - c1 = (unsigned char)*s1++; - c2 = (unsigned char)*s2++; + c1 = *s1++; + c2 = *s2++; if (c1 == '\0' || c2 == '\0') { if (c1 != '\0') return 1; if (c2 != '\0') return -1; return 0; } - if ((unsigned int)(c1 - 'A') <= ('Z' - 'A')) c1 += 'a' - 'A'; - if ((unsigned int)(c2 - 'A') <= ('Z' - 'A')) c2 += 'a' - 'A'; + if (('A' <= c1) && (c1 <= 'Z')) c1 += 'a' - 'A'; + if (('A' <= c2) && (c2 <= 'Z')) c2 += 'a' - 'A'; if (c1 != c2) { if (c1 > c2) return 1; @@ -2035,18 +2035,18 @@ st_locale_insensitive_strcasecmp(const char *s1, const char *s2) int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n) { - unsigned int c1, c2; + char c1, c2; while (n--) { - c1 = (unsigned char)*s1++; - c2 = (unsigned char)*s2++; + c1 = *s1++; + c2 = *s2++; if (c1 == '\0' || c2 == '\0') { if (c1 != '\0') return 1; if (c2 != '\0') return -1; return 0; } - if ((unsigned int)(c1 - 'A') <= ('Z' - 'A')) c1 += 'a' - 'A'; - if ((unsigned int)(c2 - 'A') <= ('Z' - 'A')) c2 += 'a' - 'A'; + if (('A' <= c1) && (c1 <= 'Z')) c1 += 'a' - 'A'; + if (('A' <= c2) && (c2 <= 'Z')) c2 += 'a' - 'A'; if (c1 != c2) { if (c1 > c2) return 1; |