diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-10-19 21:16:13 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-10-19 21:16:13 +0100 |
commit | d1f153d34b023d81768f6087f67dbfff714bafc9 (patch) | |
tree | a694d470a60655d0cda15a70791fbdb90a2398cf /CompilerTools.c | |
parent | 775b6861666af36d317fb577cf489e2c6377f878 (diff) | |
download | MWCC-d1f153d34b023d81768f6087f67dbfff714bafc9.tar.gz MWCC-d1f153d34b023d81768f6087f67dbfff714bafc9.zip |
let's commit all this before my VM blows up and nukes my work
Diffstat (limited to '')
-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; |