diff options
Diffstat (limited to 'CompilerTools.c')
-rw-r--r-- | CompilerTools.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/CompilerTools.c b/CompilerTools.c index daba8df..d2ff19d 100644 --- a/CompilerTools.c +++ b/CompilerTools.c @@ -192,10 +192,12 @@ void RemoveGListData(GList *list, long size) { char GetGListByte(GList *list) { unsigned char *p; + char r; p = (unsigned char *) (*list->data + list->size); list->size++; - return p[0]; + r = p[0]; + return r; } short GetGListWord(GList *list) { @@ -266,10 +268,9 @@ static short PHash(const unsigned char *str) { unsigned char work; const unsigned char *p; - result = str[0]; - result &= 0xFF; + result = str[0] & 0xFF; p = &str[1]; - if (str[0]) { + if (str[0] & 0xFF) { counter = result; work = 0; while (counter > 0) { @@ -287,21 +288,34 @@ static short PHash(const unsigned char *str) { short CHash(const char *str) { /* not matching :( */ + unsigned char len; short result; // orig r4 unsigned char work; // orig r5 short counter; // orig r3 + // counter,result,work -> r3=work, r4=counter, r5=result + // result,counter,work -> r3=work, r4=result, r5=counter + // work,result,counter -> r3=work, r4=result, r5=counter + // work,counter,result -> r3=work, r4=counter, r5=result + // counter,work,result -> r3=work, r4=counter, r5=result + // result,work,counter -> r3=work, r4=result, r5=counter + // i am: r4 = result, r5 = counter, r3 = work - if (result = strlen(str) & 0xFF) { - counter = result; + len = strlen(str); + result = len; + if (len) { + counter = len; work = 0; while (counter > 0) { work = (work >> 3) | (work << 5); - work = work + *(str++); + work = work + *str; + //work = *(str++) + (unsigned char) ((work >> 3) | (work << 5)); counter--; + str++; } - result = (result << 8) | work; + result = result << 8; + result = result | work; } return result & 0x7FF; |