1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-12 20:58:37 +03:00

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 commit is contained in:
Andrew Tridgell 2004-10-11 02:07:30 +00:00 committed by Gerald (Jerry) Carter
parent 2132d38f9c
commit 994392d085

View File

@ -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);
}