scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

mkerrstr (464B)


      1 #!/bin/sh
      2 
      3 trap 'r=$?; rm -f $$.tmp; exit $r' EXIT HUP INT QUIT TERM
      4 
      5 awk '
      6 /^#define[ \t]*E/{
      7 	str = ""
      8 	for (i = 5; i < NF; i++)
      9 		str = str " " $i
     10 	sub(/^ /, "", str)
     11 	errstr[$2] = str
     12 	if ($3 > max)
     13 		max = $3;
     14 }
     15 
     16 END {
     17 	print "#include <errno.h>\n"
     18 	print "char *const _sys_errlist[] = {"
     19 	for (i in errstr)
     20 		printf "\t%-20.20s = \"%s\",\n", "[" i "]", errstr[i]
     21 
     22 	print "};"
     23 	print "const int _sys_nerr =", max";"
     24 }' $@ > $$.tmp && mv $$.tmp _sys_errlist.c