mkecstr (599B)
1 #!/bin/sh 2 3 set -e 4 trap 'r=$?;rm -f $$.c;exit $r' EXIT HUP QUIT INT TERM 5 6 awk ' 7 BEGIN {print "#include \"ec.h\"\n"} 8 /^enum ecvals \{/ {print "const char *const ecstr[] = {" 9 inhome = 1} 10 11 inhome && /=/ {sub(/,/, "", $1) 12 printf("\t[%s] = \"", $1) 13 for (i = 5; i <= NF-1; ++i) 14 printf("%s%s", $i, (i == NF-1) ? "\"" : " ") 15 print ","} 16 17 inhome && /^}/ {print "\t0" 18 print "};" 19 inhome = 0}' $@ > $$.c && mv $$.c ecstr.c