scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 33cced33c6e25614b230c0d6e53edfba1e36fc9e
parent 4dd8392ce7ff341b5d19cf8a9d1473aa94b9d807
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 21 Apr 2015 15:14:49 +0200

Simplify generror script

awk allows expressions in the patterns.

Diffstat:
Mcc2/generror | 19++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/cc2/generror b/cc2/generror @@ -6,18 +6,15 @@ BEGIN { /^enum nerrors {/ { inhome = 1 } -/E[A-Z]*, / { - if (inhome == 1) { - sub(/,/, "", $1) - printf("\t[%s] = \"", $1) - for (i = 3; i < NF-1; ++i) - printf("%s ", $i) - printf("%s\",\n", $(NF-1)); - } +inhome && /E[A-Z]*, / { + sub(/,/, "", $1) + printf("\t[%s] = \"", $1) + for (i = 3; i < NF-1; ++i) + printf("%s ", $i) + printf("%s\",\n", $(NF-1)); } -/^}/ { - if (inhome) - print "};" +inhome && /^}/ { + print "};" inhome = 0 }