41 lines
697 B
Bash
Executable File
41 lines
697 B
Bash
Executable File
#! /bin/sh
|
|
|
|
test -t 1 && test "$#" -eq 0 && exec > nodenames.h
|
|
|
|
echo "#ifdef DEBUG"
|
|
echo '
|
|
/*
|
|
* Automatically generated by '"$0"'
|
|
* DO NOT EDIT. Do Not "cvs add".
|
|
*/
|
|
'
|
|
|
|
MAX=$(awk < nodes.h '
|
|
/#define/ {
|
|
if ($3 > MAX) MAX = $3
|
|
}
|
|
END { print MAX }
|
|
')
|
|
|
|
echo
|
|
echo "STATIC const char * const NodeNames[${MAX} + 1] = {"
|
|
|
|
grep '^#define' nodes.h | sort -k2n | while read define name number opt_comment
|
|
do
|
|
: ${next:=0}
|
|
while [ "$number" -gt "$next" ]
|
|
do
|
|
echo ' "???",'
|
|
next=$(( next + 1))
|
|
done
|
|
echo ' "'"$name"'",'
|
|
next=$(( number + 1 ))
|
|
done
|
|
|
|
echo "};"
|
|
echo
|
|
echo '#define NODETYPENAME(type) \'
|
|
echo ' ((unsigned)(type) <= '"${MAX}"' ? NodeNames[(type)] : "??OOR??")'
|
|
echo
|
|
echo '#endif'
|