shithub: scc

Download patch

ref: aa002c2afd8736f8c39684e59754e54be5e997a2
parent: db74516be9356bc40305d3ad683c95ec443a1866
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Apr 17 21:58:53 EDT 2016

[cc2] Remove input dependecy from assign()

This function had a dependency with the input language in how it
was parsing the subop value.

--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -232,29 +232,30 @@
 static void
 assign(char *token, union tokenop u)
 {
-	int c, op = *token++;
+	int subop, op = u.op;
 	Node *np = newnode();
 
-	switch (*token) {
-	case ODIV:
-	case OMOD:
-	case OADD:
-	case OSUB:
-	case OSHL:
-	case OSHR:
-	case OBAND:
-	case OBXOR:
-	case OBOR:
-	case OINC:
-	case ODEC:
-		c = *token++;
+	switch (subop = *++token) {
+	case '/':
+	case '%':
+	case '+':
+	case '-':
+	case 'l':
+	case 'r':
+	case '&':
+	case '|':
+	case '^':
+	case 'i':
+	case 'd':
+		++token;
+		subop = optbl[subop].u.op;
 		break;
 	default:
-		c = 0;
+		subop = 0;
 		break;
 	}
 
-	np->u.subop = c;
+	np->u.subop = subop;
 	np->op = op;
 	np->type = *gettype(token);
 	np->right = pop();