[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-683-g0bfea72

Jeremy Allison jra at samba.org
Sun Dec 16 19:08:31 GMT 2007


The branch, v3-2-test has been updated
       via  0bfea7259e4091c6d914528a0e65fc10d8a56fb8 (commit)
       via  a8948e0727b100945ab730d4d144ccbe219bbc94 (commit)
       via  b6d1d2428866712a550a354732e2386b4f87b67b (commit)
       via  99c59e809ef3c5abcdfb796d50be7c40f7033787 (commit)
      from  ced0c42f055a672f6b4ab6ba809b0f63c83b431e (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 0bfea7259e4091c6d914528a0e65fc10d8a56fb8
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 16 00:25:49 2007 +0100

    get rid of doschar_table[]
    
    If I'm not completely blind, then check_dos_char is *only* used in the case
    when we can't mmap() valid.dat. To me this looks as if we initialize the 65536
    bits in doschar_table[] with check_dos_char_slowly, use it once to initialize
    valid_table[] and *never* use them again. I think there's no point in keeping
    these 8k of modified memory around for an unlikely case (no "valid.dat") and
    even that only to use it exactly once.

commit a8948e0727b100945ab730d4d144ccbe219bbc94
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 16 00:19:42 2007 +0100

    Tiny fixes to init_valid_table()

commit b6d1d2428866712a550a354732e2386b4f87b67b
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 16 00:17:41 2007 +0100

    Make init_doschar_table() static
    
    It's only called directly before init_valid_table() anyway, so move it there.

commit 99c59e809ef3c5abcdfb796d50be7c40f7033787
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 16 00:15:34 2007 +0100

    Make check_dos_char static
    
    It's only called in t_doschar, a pretty bogus test program that is not compiled
    by default

-----------------------------------------------------------------------

Summary of changes:
 source/lib/charcnv.c     |    1 -
 source/lib/util_unistr.c |   60 ++++-----------------------------------------
 2 files changed, 6 insertions(+), 55 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/charcnv.c b/source/lib/charcnv.c
index 2515e6c..8a00b23 100644
--- a/source/lib/charcnv.c
+++ b/source/lib/charcnv.c
@@ -178,7 +178,6 @@ void init_iconv(void)
 		 * codepage changes? */
 		/* XXX: Is the did_reload test too strict? */
 		conv_silent = True;
-		init_doschar_table();
 		init_valid_table();
 		conv_silent = False;
 	}
diff --git a/source/lib/util_unistr.c b/source/lib/util_unistr.c
index 49b0b81..84ee673 100644
--- a/source/lib/util_unistr.c
+++ b/source/lib/util_unistr.c
@@ -35,14 +35,6 @@ static bool lowcase_table_use_unmap;
 static bool valid_table_use_unmap;
 
 /**
- * This table says which Unicode characters are valid dos
- * characters.
- *
- * Each value is just a single bit.
- **/
-static uint8 doschar_table[8192]; /* 65536 characters / 8 bits/byte */
-
-/**
  * Destroy global objects allocated by load_case_tables()
  **/
 void gfree_case_tables(void)
@@ -153,21 +145,6 @@ void load_case_tables(void)
 	TALLOC_FREE(frame);
 }
 
-/*
-  see if a ucs2 character can be mapped correctly to a dos character
-  and mapped back to the same character in ucs2
-*/
-
-int check_dos_char(smb_ucs2_t c)
-{
-	lazy_initialize_conv();
-
-	/* Find the right byte, and right bit within the byte; return
-	 * 1 or 0 */
-	return (doschar_table[(c & 0xffff) / 8] & (1 << (c & 7))) != 0;
-}
-
-
 static int check_dos_char_slowly(smb_ucs2_t c)
 {
 	char buf[10];
@@ -185,33 +162,6 @@ static int check_dos_char_slowly(smb_ucs2_t c)
 	return (c == c2);
 }
 
-
-/**
- * Fill out doschar table the hard way, by examining each character
- **/
-
-void init_doschar_table(void)
-{
-	int i, j, byteval;
-
-	/* For each byte of packed table */
-	
-	for (i = 0; i <= 0xffff; i += 8) {
-		byteval = 0;
-		for (j = 0; j <= 7; j++) {
-			smb_ucs2_t c;
-
-			c = i + j;
-			
-			if (check_dos_char_slowly(c)) {
-				byteval |= 1 << j;
-			}
-		}
-		doschar_table[i/8] = byteval;
-	}
-}
-
-
 /**
  * Load the valid character map table from <tt>valid.dat</tt> or
  * create from the configured codepage.
@@ -245,22 +195,24 @@ void init_valid_table(void)
 	 * It might need to be regenerated if the code page changed.
 	 * We know that we're not using a mapped file, so we can
 	 * free() the old one. */
-	if (valid_table) 
-		SAFE_FREE(valid_table);
+	SAFE_FREE(valid_table);
 
 	/* use free rather than unmap */
 	valid_table_use_unmap = False;
 
 	DEBUG(2,("creating default valid table\n"));
 	valid_table = (uint8 *)SMB_MALLOC(0x10000);
+	SMB_ASSERT(valid_table != NULL);
 	for (i=0;i<128;i++) {
 		valid_table[i] = isalnum(i) || strchr(allowed,i);
 	}
-	
+
+	lazy_initialize_conv();
+
 	for (;i<0x10000;i++) {
 		smb_ucs2_t c;
 		SSVAL(&c, 0, i);
-		valid_table[i] = check_dos_char(c);
+		valid_table[i] = check_dos_char_slowly(c);
 	}
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list