summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-11 02:07:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:46 -0500
commit51009f7052fd6c61d70a35ec311358f962c365c9 (patch)
tree8ad75ddcc76e1c6937638f1c8a4e5be153c6a838 /source4
parent598e82e7ad9377138b5a899724083fc5d808a249 (diff)
downloadsamba-51009f7052fd6c61d70a35ec311358f962c365c9.tar.gz
samba-51009f7052fd6c61d70a35ec311358f962c365c9.tar.bz2
samba-51009f7052fd6c61d70a35ec311358f962c365c9.zip
r2901: if we can't load upcase.dat or lowcase.dat then don't waste 256k
making fake tables, instead just do the approximate upper/lower inline with toupper() and tolower(). (This used to be commit 994392d085e87046212191b8f41eba628467c778)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/util_unistr.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/source4/lib/util_unistr.c b/source4/lib/util_unistr.c
index 480fb6c72e..672c7cd2c8 100644
--- a/source4/lib/util_unistr.c
+++ b/source4/lib/util_unistr.c
@@ -32,7 +32,6 @@ load the case handling tables
********************************************************************/
static void load_case_tables(void)
{
- int i;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("load_case_tables");
@@ -42,35 +41,11 @@ static void load_case_tables(void)
upcase_table = map_file(lib_path(mem_ctx, "upcase.dat"), 0x20000);
lowcase_table = map_file(lib_path(mem_ctx, "lowcase.dat"), 0x20000);
talloc_destroy(mem_ctx);
-
- /* we would like Samba to limp along even if these tables are
- not available */
if (upcase_table == NULL) {
- DEBUG(1,("creating lame upcase table\n"));
- upcase_table = talloc_named_const(NULL, 0x20000, "upcase_table");
- if (!upcase_table) {
- smb_panic("No memory for upcase tables");
- }
- for (i=0;i<0x10000;i++) {
- SSVAL(upcase_table, i*2, i);
- }
- for (i=0;i<256;i++) {
- SSVAL(upcase_table, i*2, islower(i)?toupper(i):i);
- }
+ upcase_table = (void *)-1;
}
-
if (lowcase_table == NULL) {
- DEBUG(1,("creating lame lowcase table\n"));
- lowcase_table = talloc_named_const(NULL, 0x20000, "lowcase_table");
- if (!lowcase_table) {
- smb_panic("No memory for lowcase tables");
- }
- for (i=0;i<0x10000;i++) {
- SSVAL(lowcase_table, i*2, i);
- }
- for (i=0;i<256;i++) {
- SSVAL(lowcase_table, i*2, isupper(i)?tolower(i):i);
- }
+ lowcase_table = (void *)-1;
}
}
@@ -88,6 +63,9 @@ codepoint_t toupper_w(codepoint_t val)
if (upcase_table == NULL) {
load_case_tables();
}
+ if (upcase_table == (void *)-1) {
+ return val;
+ }
return SVAL(upcase_table, val*2);
}
@@ -105,6 +83,9 @@ codepoint_t tolower_w(codepoint_t val)
if (lowcase_table == NULL) {
load_case_tables();
}
+ if (lowcase_table == (void *)-1) {
+ return val;
+ }
return SVAL(lowcase_table, val*2);
}