Browse code

Fixed issue with scmp in uxnasm

neauoire authored on 29/08/2021 18:43:00
Showing 1 changed files
... ...
@@ -46,7 +46,7 @@ static char ops[][4] = {
46 46
 	"ADD", "SUB", "MUL", "DIV", "AND", "ORA", "EOR", "SFT"
47 47
 };
48 48
 
49
-static int   scmp(char *a, char *b, int len) { int i = 0; while(a[i] == b[i] && i < len) if(!a[i++]) return 1; return 0; } /* string compare */
49
+static int   scmp(char *a, char *b, int len) { int i = 0; while(a[i] == b[i]) if(!a[i] || ++i >= len) return 1; return 0; } /* string compare */
50 50
 static int   sihx(char *s) { int i = 0; char c; while((c = s[i++])) if(!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f')) return 0; return i > 1; } /* string is hexadecimal */
51 51
 static int   shex(char *s) { int n = 0, i = 0; char c; while((c = s[i++])) if(c >= '0' && c <= '9') n = n * 16 + (c - '0'); else if(c >= 'a' && c <= 'f') n = n * 16 + 10 + (c - 'a'); return n; } /* string to num */
52 52
 static int   slen(char *s) { int i = 0; while(s[i] && s[++i]) ; return i; } /* string length */
... ...
@@ -85,8 +85,7 @@ findopcode(char *s)
85 85
 	int i;
86 86
 	for(i = 0; i < 0x20; ++i) {
87 87
 		int m = 0;
88
-		char *o = ops[i];
89
-		if(o[0] != s[0] || o[1] != s[1] || o[2] != s[2])
88
+		if(!scmp(ops[i], s, 3))
90 89
 			continue;
91 90
 		while(s[3 + m]) {
92 91
 			if(s[3 + m] == '2')