diff options
author | Herb Lewis <herb@samba.org> | 2002-03-06 20:38:51 +0000 |
---|---|---|
committer | Herb Lewis <herb@samba.org> | 2002-03-06 20:38:51 +0000 |
commit | 99c4646a198a6a49a087e22a7d03af495d044ec6 (patch) | |
tree | b8a281fa7f62695371ccbdc58d0c35088c09ea70 /source3 | |
parent | 8e7e1fe9f8b5350d2c36f001a1b7afc11b39af7c (diff) | |
download | samba-99c4646a198a6a49a087e22a7d03af495d044ec6.tar.gz samba-99c4646a198a6a49a087e22a7d03af495d044ec6.tar.bz2 samba-99c4646a198a6a49a087e22a7d03af495d044ec6.zip |
fixed the upper/lower case table generation on big-endian machines
(tridge, using Herbs console)
(This used to be commit e5d80779a384c9a806fc545032330f760d8c11cb)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/util_unistr.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 31b557bbfc..45e6e6d87e 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -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; } /******************************************************************* |