From d1f153d34b023d81768f6087f67dbfff714bafc9 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 19 Oct 2022 21:16:13 +0100 Subject: let's commit all this before my VM blows up and nukes my work --- CompilerTools.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'CompilerTools.c') 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; -- cgit v1.2.3