commit ecf29f6e95d44f013c47a2d907eea21b2bb5d934
parent 7efbe8681cbdbfe860296e32fa771f8d204757c1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 26 Dec 2024 22:13:31 +0100
cc2: Improve generror.awk
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/cmd/scc-cc/cc2/generror.awk b/src/cmd/scc-cc/cc2/generror.awk
@@ -1,9 +1,9 @@
/^enum nerrors \{/ {print "char *errlist[] = {"; inhome = 1}
inhome && /E[A-Z]*, / {sub(/,/, "", $1)
- printf("\t[%s] = \"", $1)
- for (i = 3; i <= NF-1; ++i)
- printf("%s%s", $i, (i == NF-1) ? "\"" : " ")
- print ","}
-
+ printf("\t[%s] = ", $1)
+ $1 = $2 = $NF = ""
+ sub(/^ */, "")
+ sub(/ *$/, "")
+ printf("\"%s\",\n", $0)}
inhome && /^}/ {print "};" ; inhome = 0}