Changeset 8 for trunk/src/sh_hash.c
- Timestamp:
- Dec 31, 2005, 2:02:03 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_hash.c
r3 r8 71 71 static char * unquote_string (char * str) 72 72 { 73 int i = 0, j, k = 0, len ;74 char * tmp ;73 int i = 0, j, k = 0, len, t1, t2, l2; 74 char * tmp = NULL; 75 75 76 76 SL_ENTER(_("unquote_string")); 77 77 78 if (str == NULL) 79 { 80 SL_RETURN(NULL, _("unquote_string")); 81 } 82 83 len = sl_strlen(str); 84 85 tmp = SH_ALLOC(len + 1); 86 for (j = 0; j <= len; ++j) 87 { 88 if (str[j] == QUOTE_CHAR && j < (len-2)) 89 { 90 if (sh_util_hexchar(str[j+1]) >= 0 && sh_util_hexchar(str[j+2]) >= 0) 91 { 92 i = 16 * sh_util_hexchar(str[j+1]) + sh_util_hexchar(str[j+2]); 93 tmp[k] = i; j += 2; 94 } 95 else 78 if (str != NULL) 79 { 80 len = sl_strlen(str); 81 l2 = len - 2; 82 tmp = SH_ALLOC(len + 1); 83 84 for (j = 0; j <= len; ++j) 85 { 86 if (str[j] != QUOTE_CHAR) 96 87 { 97 88 tmp[k] = str[j]; 98 89 } 99 } 100 else 101 tmp[k] = str[j]; 102 ++k; 90 else if (str[j] == QUOTE_CHAR && j < l2) 91 { 92 t1 = sh_util_hexchar(str[j+1]); 93 t2 = sh_util_hexchar(str[j+2]); 94 if ((t1|t2) >= 0) 95 { 96 i = 16 * t1 + t2; 97 tmp[k] = i; 98 j += 2; 99 } 100 else 101 { 102 tmp[k] = str[j]; 103 } 104 } 105 else 106 tmp[k] = str[j]; 107 ++k; 108 } 103 109 } 104 110 SL_RETURN(tmp, _("unquote_string")); … … 306 312 307 313 /* must fit an int */ 308 #define TABSIZE 2048 314 /* #define TABSIZE 2048 */ 315 #define TABSIZE 65536 309 316 310 317 /* must fit an unsigned short */ … … 386 393 * 387 394 **************************************************************/ 395 388 396 static int hashfunc(char *s) 389 397 { … … 392 400 for ( ; *s; s++) 393 401 n = 31 * n + *s; 394 return n % TABSIZE;402 return n & 0xFFFF;/* % TABSIZE*/; 395 403 } 404 396 405 397 406 int hashreport_missing( char *fullpath, int level) … … 635 644 SL_ENTER(_("hashsearch")); 636 645 637 if ( !s)638 SL_RETURN( NULL, _("hashsearch"));639 640 for (p = tab[hashfunc(s)]; p; p = p->next)641 if ((p->fullpath != NULL) && (0 == strcmp(s, p->fullpath))) 642 SL_RETURN( p, _("hashsearch"));646 if (s) 647 { 648 for (p = tab[hashfunc(s)]; p; p = p->next) 649 if ((p->fullpath != NULL) && (0 == strcmp(s, p->fullpath))) 650 SL_RETURN( p, _("hashsearch")); 651 } 643 652 SL_RETURN( NULL, _("hashsearch")); 644 653 } … … 672 681 { 673 682 if (p && p->fullpath && 674 0 == strcmp(s->fullpath, p->fullpath) && 675 strlen(s->fullpath) == strlen(p->fullpath)) 683 0 == strcmp(s->fullpath, p->fullpath)) 676 684 { 677 685 q = p->next; … … 3064 3072 int hash_remove_tree (char * s) 3065 3073 { 3066 sh_file_t * p;3067 intlen;3068 inti;3074 sh_file_t * p; 3075 size_t len; 3076 unsigned int i; 3069 3077 3070 3078 SL_ENTER(_("hash_remove_tree")); 3071 3079 3072 if (!s )3080 if (!s || *s == '\0') 3073 3081 SL_RETURN ((-1), _("hash_remove_tree")); 3074 else 3075 3082 3083 len = sl_strlen(s); 3076 3084 3077 3085 if (IsInit != 1) … … 3082 3090 for (p = tab[i]; p; p = p->next) 3083 3091 { 3084 if ( sl_strncmp(s, p->fullpath, len) == 0)3092 if (p->fullpath && 0 == strncmp(s, p->fullpath, len)) 3085 3093 { 3086 3094 p->allignore = S_TRUE;
Note:
See TracChangeset
for help on using the changeset viewer.