Initial import
[samba] / debian / patches / ubuntu-setlocale.patch
1 Index: SAMBA_3_0/source/lib/util_unistr.c
2 ===================================================================
3 --- SAMBA_3_0/source/lib/util_unistr.c  (revision 12521)
4 +++ SAMBA_3_0/source/lib/util_unistr.c  (revision 12522)
5 @@ -51,6 +51,7 @@
6  void load_case_tables(void)
7  {
8         static int initialised;
9 +       char *old_locale = NULL, *saved_locale = NULL;
10         int i;
11  
12         if (initialised) {
13 @@ -61,6 +62,17 @@
14         upcase_table = map_file(data_path("upcase.dat"), 0x20000);
15         lowcase_table = map_file(data_path("lowcase.dat"), 0x20000);
16  
17 +#ifdef HAVE_SETLOCALE
18 +       /* Get the name of the current locale.  */
19 +       old_locale = setlocale(LC_ALL, NULL);
20 +
21 +       /* Save it as it is in static storage. */
22 +       saved_locale = SMB_STRDUP(old_locale);
23 +
24 +       /* We set back the locale to C to get ASCII-compatible toupper/lower functions. */
25 +       setlocale(LC_ALL, "C");
26 +#endif
27 +
28         /* we would like Samba to limp along even if these tables are
29            not available */
30         if (!upcase_table) {
31 @@ -92,6 +104,12 @@
32                         lowcase_table[v] = UCS2_CHAR(isupper(i)?tolower(i):i);
33                 }
34         }
35 +
36 +#ifdef HAVE_SETLOCALE
37 +       /* Restore the old locale. */
38 +       setlocale (LC_ALL, saved_locale);
39 +       SAFE_FREE(saved_locale);
40 +#endif
41  }
42  
43  /*
44 @@ -997,3 +1015,41 @@
45         
46         return dst;
47  }
48 +
49 +/*************************************************************
50 + ascii only toupper - saves the need for smbd to be in C locale.
51 +*************************************************************/
52 +
53 +int toupper_ascii(int c)
54 +{
55 +       smb_ucs2_t uc = toupper_w(UCS2_CHAR(c));
56 +       return UCS2_TO_CHAR(uc);
57 +}
58 +
59 +/*************************************************************
60 + ascii only tolower - saves the need for smbd to be in C locale.
61 +*************************************************************/
62 +
63 +int tolower_ascii(int c)
64 +{
65 +       smb_ucs2_t uc = tolower_w(UCS2_CHAR(c));
66 +       return UCS2_TO_CHAR(uc);
67 +}
68 +
69 +/*************************************************************
70 + ascii only isupper - saves the need for smbd to be in C locale.
71 +*************************************************************/
72 +
73 +int isupper_ascii(int c)
74 +{
75 +       return isupper_w(UCS2_CHAR(c));
76 +}
77 +
78 +/*************************************************************
79 + ascii only islower - saves the need for smbd to be in C locale.
80 +*************************************************************/
81 +
82 +int islower_ascii(int c)
83 +{
84 +       return islower_w(UCS2_CHAR(c));
85 +}
86 Index: SAMBA_3_0/source/lib/charcnv.c
87 ===================================================================
88 --- SAMBA_3_0/source/lib/charcnv.c      (revision 12521)
89 +++ SAMBA_3_0/source/lib/charcnv.c      (revision 12522)
90 @@ -84,15 +84,6 @@
91                 }
92                 ret = ln;
93         }
94 -#ifdef HAVE_SETLOCALE
95 -       /* We set back the locale to C to get ASCII-compatible toupper/lower functions.
96 -          For now we do not need any other POSIX localisations anyway. When we should
97 -          really need localized string functions one day we need to write our own
98 -          ascii_tolower etc.
99 -       */
100 -       setlocale(LC_ALL, "C");
101 - #endif
102 -
103  #endif
104  
105         if (!ret || !*ret) ret = "ASCII";
106 Desc: Back out changes made to 3_0_RELEASE branch that disabled the above hacks
107 ===============================================================================
108 --- SAMBA_3_0/source/include/smb_macros.h       2006-01-25 10:46:39.000000000 +1100
109 +++ SAMBA_3_0/source/include/smb_macros.h       2006-04-10 21:16:13.000000000 +1000
110 @@ -24,14 +24,6 @@
111  #ifndef _SMB_MACROS_H
112  #define _SMB_MACROS_H
113  
114 -/* no ops to help reduce the diff between the current 3.0 and release branch */
115 -
116 -#define toupper_ascii(x)       toupper(x)
117 -#define tolower_ascii(x)       tolower(x)
118 -#define isupper_ascii(x)       isupper(x)
119 -#define islower_ascii(x)       islower(x)
120 -
121 -
122  /* Misc bit macros */
123  #define BOOLSTR(b) ((b) ? "Yes" : "No")
124  #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)