scc

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

mkerrstr (383B)


      1 #!/bin/sh
      2 
      3 trap 'rm -f $$.tmp' 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 }
     13 
     14 END {
     15 	print "#include <errno.h>\n"
     16 	print "char *const _sys_errlist[] = {"
     17 	for (i in errstr)
     18 		printf "\t%-20.20s = \"%s\",\n", "[" i "]", errstr[i]
     19 
     20 	print "};"
     21 }' $@ > $$.tmp && mv $$.tmp _sys_errlist.c