diff --git a/lithos_c/inc/Lth_stdlib.h b/lithos_c/inc/Lth_stdlib.h index 96e5d78..0615b14 100644 --- a/lithos_c/inc/Lth_stdlib.h +++ b/lithos_c/inc/Lth_stdlib.h @@ -43,6 +43,6 @@ void Lth_PrintString(char const *s); // Hash size_t Lth_Hash_char(char const *s); -size_t Lth_Hash_str(__str s); +size_t Lth_Hash_str(char __str_ars const *s); #endif//lithos3__Lth_stdlib_h diff --git a/lithos_c/src/manifest.c b/lithos_c/src/manifest.c index e51e73a..0b04d83 100644 --- a/lithos_c/src/manifest.c +++ b/lithos_c/src/manifest.c @@ -183,7 +183,7 @@ static void ManifestGetInitializer(ManifestState *repr, size_t key) break; case Lth_TOK_Identi: __with(char const *str = Lth_TokenStreamBump(repr->stream)->str;) - if(strcmp(str, "true") == 0) GenValueGetter(Integ, integ, 1); + if(strcmp(str, "true") == 0) GenValueGetter(Integ, integ, 1); else if(strcmp(str, "false") == 0) GenValueGetter(Integ, integ, 0); default: ManifestError(repr, "expected initializer"); diff --git a/lithos_c/src/stdlib.c b/lithos_c/src/stdlib.c index 9212bea..32df7a2 100644 --- a/lithos_c/src/stdlib.c +++ b/lithos_c/src/stdlib.c @@ -17,6 +17,16 @@ #include #include +#define GenStrHash() \ + if(s == NULL) return 0; \ + \ + size_t ret = 0; \ + \ + while(*s) \ + ret = ret * 101 + ((unsigned char)(*s++) & 0xff); \ + \ + return ret + // Extern Functions ----------------------------------------------------------| @@ -132,30 +142,15 @@ void Lth_PrintString(char const *s) // size_t Lth_Hash_char(char const *s) { - if(s == NULL) return 0; - - size_t ret = 0; - - while(*s) - ret = ret * 101 + (unsigned char)(*s++); - - return ret; + GenStrHash(); } // // Lth_Hash_str // -size_t Lth_Hash_str(__str s) +size_t Lth_Hash_str(char __str_ars const *s) { - if(s == NULL) return 0; - - size_t ret = 0; - size_t len = ACS_StrLen(s); - - for(size_t i = 0; i < len; i++) - ret = ret * 101 + (unsigned char)(s[i]); - - return ret; + GenStrHash(); } // EOF