From 51009f7052fd6c61d70a35ec311358f962c365c9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Oct 2004 02:07:30 +0000 Subject: 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) --- source4/lib/util_unistr.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'source4/lib') 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); } -- cgit