diff -urN samba-3.0.22.orig/source/client/smbspool.c samba-3.0.22/source/client/smbspool.c --- samba-3.0.22.orig/source/client/smbspool.c 2006-04-19 17:13:38.403964661 +0200 +++ samba-3.0.22/source/client/smbspool.c 2006-04-19 17:24:31.412585809 +0200 @@ -74,6 +74,8 @@ char null_str[1]; int tries = 0; + load_case_tables(); + null_str[0] = '\0'; /* we expect the URI in argv[0]. Detect the case where it is in argv[1] and cope */ diff -urN samba-3.0.22.orig/source/include/smb_macros.h samba-3.0.22/source/include/smb_macros.h --- samba-3.0.22.orig/source/include/smb_macros.h 2006-04-19 17:13:40.000408662 +0200 +++ samba-3.0.22/source/include/smb_macros.h 2006-04-19 17:17:18.123440094 +0200 @@ -24,14 +24,6 @@ #ifndef _SMB_MACROS_H #define _SMB_MACROS_H -/* no ops to help reduce the diff between the current 3.0 and release branch */ - -#define toupper_ascii(x) toupper(x) -#define tolower_ascii(x) tolower(x) -#define isupper_ascii(x) isupper(x) -#define islower_ascii(x) islower(x) - - /* Misc bit macros */ #define BOOLSTR(b) ((b) ? "Yes" : "No") #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0) diff -urN samba-3.0.22.orig/source/lib/charcnv.c samba-3.0.22/source/lib/charcnv.c --- samba-3.0.22.orig/source/lib/charcnv.c 2006-04-19 17:13:40.094375935 +0200 +++ samba-3.0.22/source/lib/charcnv.c 2006-04-19 17:17:18.113443576 +0200 @@ -84,15 +84,6 @@ } ret = ln; } -#ifdef HAVE_SETLOCALE - /* 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 - #endif if (!ret || !*ret) ret = "ASCII"; diff -urN samba-3.0.22.orig/source/lib/util_unistr.c samba-3.0.22/source/lib/util_unistr.c --- samba-3.0.22.orig/source/lib/util_unistr.c 2006-04-19 17:13:40.210335550 +0200 +++ samba-3.0.22/source/lib/util_unistr.c 2006-04-19 17:17:18.096449495 +0200 @@ -51,6 +51,7 @@ void load_case_tables(void) { static int initialised; + char *old_locale = NULL, *saved_locale = NULL; int i; if (initialised) { @@ -61,6 +62,17 @@ upcase_table = map_file(data_path("upcase.dat"), 0x20000); lowcase_table = map_file(data_path("lowcase.dat"), 0x20000); +#ifdef HAVE_SETLOCALE + /* Get the name of the current locale. */ + old_locale = setlocale(LC_ALL, NULL); + + /* Save it as it is in static storage. */ + saved_locale = SMB_STRDUP(old_locale); + + /* We set back the locale to C to get ASCII-compatible toupper/lower functions. */ + setlocale(LC_ALL, "C"); +#endif + /* we would like Samba to limp along even if these tables are not available */ if (!upcase_table) { @@ -92,6 +104,12 @@ lowcase_table[v] = UCS2_CHAR(isupper(i)?tolower(i):i); } } + +#ifdef HAVE_SETLOCALE + /* Restore the old locale. */ + setlocale (LC_ALL, saved_locale); + SAFE_FREE(saved_locale); +#endif } /* @@ -997,3 +1015,41 @@ return dst; } + +/************************************************************* + ascii only toupper - saves the need for smbd to be in C locale. +*************************************************************/ + +int toupper_ascii(int c) +{ + smb_ucs2_t uc = toupper_w(UCS2_CHAR(c)); + return UCS2_TO_CHAR(uc); +} + +/************************************************************* + ascii only tolower - saves the need for smbd to be in C locale. +*************************************************************/ + +int tolower_ascii(int c) +{ + smb_ucs2_t uc = tolower_w(UCS2_CHAR(c)); + return UCS2_TO_CHAR(uc); +} + +/************************************************************* + ascii only isupper - saves the need for smbd to be in C locale. +*************************************************************/ + +int isupper_ascii(int c) +{ + return isupper_w(UCS2_CHAR(c)); +} + +/************************************************************* + ascii only islower - saves the need for smbd to be in C locale. +*************************************************************/ + +int islower_ascii(int c) +{ + return islower_w(UCS2_CHAR(c)); +}