diff --git a/lib/util/charset/charcnv.c b/lib/util/charset/charcnv.c index e9f6ab0..4e46cfc 100644 --- a/lib/util/charset/charcnv.c +++ b/lib/util/charset/charcnv.c @@ -135,21 +135,6 @@ static smb_iconv_t get_conv_handle(struct smb_iconv_convenience *ic, charset_t from, charset_t to) { const char *n1, *n2; - static bool initialised; - - if (initialised == false) { - initialised = true; - -#ifdef LC_ALL - /* we set back the locale to C to get ASCII-compatible - toupper/lower functions. For now we do not need - any other POSIX localisations anyway. When we - should really need localized string functions one - day we need to write our own ascii_tolower etc. - */ - setlocale(LC_ALL, "C"); -#endif - } if (ic->conv_handles[from][to]) { return ic->conv_handles[from][to]; diff --git a/lib/util/charset/codepoints.c b/lib/util/charset/codepoints.c index 8be2051..fe7ea36 100644 --- a/lib/util/charset/codepoints.c +++ b/lib/util/charset/codepoints.c @@ -69,7 +69,9 @@ void load_case_tables(void) _PUBLIC_ codepoint_t toupper_m(codepoint_t val) { if (val < 128) { - return toupper(val); + if (val >= 'a' && val <= 'z') + val -= 32; + return val; } if (upcase_table == NULL) { load_case_tables(); @@ -89,7 +91,9 @@ _PUBLIC_ codepoint_t toupper_m(codepoint_t val) _PUBLIC_ codepoint_t tolower_m(codepoint_t val) { if (val < 128) { - return tolower(val); + if (val >= 'A' && val <= 'Z') + val += 32; + return val; } if (lowcase_table == NULL) { load_case_tables(); diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c index 520ce05..5e5edb7 100644 --- a/lib/util/charset/util_unistr.c +++ b/lib/util/charset/util_unistr.c @@ -542,7 +542,8 @@ _PUBLIC_ void strlower_m(char *s) supported multi-byte character sets are ascii-compatible (ie. they match for the first 128 chars) */ while (*s && !(((uint8_t)*s) & 0x80)) { - *s = tolower((uint8_t)*s); + if (*s >= 'A' && *s <= 'Z') + *s = (*s) + 32; s++; } @@ -581,7 +582,8 @@ _PUBLIC_ void strupper_m(char *s) supported multi-byte character sets are ascii-compatible (ie. they match for the first 128 chars) */ while (*s && !(((uint8_t)*s) & 0x80)) { - *s = toupper((uint8_t)*s); + if (*s >= 'a' && *s <= 'z') + *s = (*s) - 32; s++; }