shithub: scc

Download patch

ref: 8e416b79aff3f1e84d5b6255f3bb3435e3e2352e
parent: 652c56f79e42c277cfa92007aef17b7bfe95a659
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Sep 24 13:13:21 EDT 2017

[as] Remove empty fields of instbl.c

These arrays were empty and was really hard to detect that they
were empty.

--- a/as/target/x86/gen.awk
+++ b/as/target/x86/gen.awk
@@ -40,12 +40,18 @@
 	print "struct op optab[] = {"
 	for (i = 0; i < nvar; i++) {
 		printf "\t{\n" \
-		       "\t\t.bytes = (char []) {%s},\n"\
 		       "\t\t.size = %d,\n"\
-		       "\t\t.format = %s,\n"\
-		       "\t\t.args = (char []) {%s}\n"\
-		       "\t},\n",
-		 opbytes[i], opsize[i], opformat[i], str2args(opargs[i])
+		       "\t\t.format = %s,\n",
+		       opsize[i], opformat[i]
+
+		if (opbytes[i] != "")
+			printf "\t\t.bytes = (char []) {%s},\n", opbytes[i]
+
+		a = str2args(opargs[i])
+		if (a != "")
+			printf "\t\t.args = (char []) {%s}\n", a
+
+		print "\t},"
 	}
 	print "};"
 }
@@ -52,12 +58,11 @@
 
 function str2args(s, args, i, out)
 {
-	split(s, args, /,/)
+	if (split(s, args, /,/) == 0 || args[1] == "none")
+		return ""
 	for (i in args) {
 		a = args[i]
-		if (a == "none") {
-			break
-		} else if (match(a, /^imm8/)) {
+		if (match(a, /^imm8/)) {
 			out = "AIMM8"
 		} else if (match(a, /^imm16/)) {
 			out = "AIMM16"