fixed the upper/lower case table generation on big-endian machines
authorHerb Lewis <herb@samba.org>
Wed, 6 Mar 2002 20:38:51 +0000 (20:38 +0000)
committerHerb Lewis <herb@samba.org>
Wed, 6 Mar 2002 20:38:51 +0000 (20:38 +0000)
(tridge, using Herbs console)
(This used to be commit e5d80779a384c9a806fc545032330f760d8c11cb)

source3/lib/util_unistr.c

index 31b557bbfc37e852a775e848ec1d1e892891f69c..45e6e6d87e6818670f188cd2bd287feab9065f39 100644 (file)
@@ -51,15 +51,31 @@ void load_case_tables(void)
        if (!upcase_table) {
                DEBUG(1,("creating lame upcase table\n"));
                upcase_table = malloc(0x20000);
-               for (i=0;i<0x10000;i++) upcase_table[i] = i;
-               for (i=0;i<256;i++) upcase_table[UCS2_CHAR(i)] = UCS2_CHAR(islower(i)?toupper(i):i);
+               for (i=0;i<0x10000;i++) {
+                       smb_ucs2_t v;
+                       SSVAL(&v, 0, i);
+                       upcase_table[v] = i;
+               }
+               for (i=0;i<256;i++) {
+                       smb_ucs2_t v;
+                       SSVAL(&v, 0, UCS2_CHAR(i));
+                       upcase_table[v] = UCS2_CHAR(islower(i)?toupper(i):i);
+               }
        }
 
        if (!lowcase_table) {
                DEBUG(1,("creating lame lowcase table\n"));
                lowcase_table = malloc(0x20000);
-               for (i=0;i<0x10000;i++) lowcase_table[i] = i;
-               for (i=0;i<256;i++) lowcase_table[UCS2_CHAR(i)] = UCS2_CHAR(isupper(i)?tolower(i):i);
+               for (i=0;i<0x10000;i++) {
+                       smb_ucs2_t v;
+                       SSVAL(&v, 0, i);
+                       lowcase_table[v] = i;
+               }
+               for (i=0;i<256;i++) {
+                       smb_ucs2_t v;
+                       SSVAL(&v, 0, UCS2_CHAR(i));
+                       lowcase_table[v] = UCS2_CHAR(isupper(i)?tolower(i):i);
+               }
        }
 }
 
@@ -238,7 +254,7 @@ uint32 buffer2_to_uint32(BUFFER2 *str)
 
 smb_ucs2_t toupper_w(smb_ucs2_t val)
 {
-       return upcase_table[val];
+       return upcase_table[SVAL(&val,0)];
 }
 
 /*******************************************************************
@@ -247,7 +263,8 @@ smb_ucs2_t toupper_w(smb_ucs2_t val)
 
 smb_ucs2_t tolower_w( smb_ucs2_t val )
 {
-       return lowcase_table[val];
+       return lowcase_table[SVAL(&val,0)];
+
 }
 
 /*******************************************************************
@@ -255,7 +272,7 @@ determine if a character is lowercase
 ********************************************************************/
 BOOL islower_w(smb_ucs2_t c)
 {
-       return upcase_table[c] != c;
+       return upcase_table[SVAL(&c,0)] != c;
 }
 
 /*******************************************************************
@@ -263,7 +280,7 @@ determine if a character is uppercase
 ********************************************************************/
 BOOL isupper_w(smb_ucs2_t c)
 {
-       return lowcase_table[c] != c;
+       return lowcase_table[SVAL(&c,0)] != c;
 }
 
 
@@ -272,7 +289,7 @@ determine if a character is valid in a 8.3 name
 ********************************************************************/
 BOOL isvalid83_w(smb_ucs2_t c)
 {
-       return valid_table[c] != 0;
+       return valid_table[SVAL(&c,0)] != 0;
 }
 
 /*******************************************************************