|
|
@@ -3,15 +3,13 @@
|
|
|
echo "/* Generated by $0 */"
|
|
|
needcomma=0
|
|
|
types=
|
|
|
-echo "typedef const char * res_t;"
|
|
|
-echo
|
|
|
while read -r line; do
|
|
|
[ -z "${line%%#*}" ] && continue # skip comments
|
|
|
if [ -z "${line%%:*}" ]; then
|
|
|
- [ ${needcomma} -eq 1 ] && printf ",\n\tNULL\n};\n\n"
|
|
|
+ [ ${needcomma} -eq 1 ] && printf ",\n};\n\n"
|
|
|
type="${line#:}"
|
|
|
[ "${type}" = "end" ] && break
|
|
|
- printf "static res_t res_%s[] = {\n" "${type}"
|
|
|
+ printf "static const char* res_%s[] = {\n" "${type}"
|
|
|
needcomma=0
|
|
|
types="${types}${types:+ }${type}"
|
|
|
else
|
|
|
@@ -21,12 +19,16 @@ while read -r line; do
|
|
|
fi
|
|
|
done
|
|
|
|
|
|
-echo "static res_t *res[] = {"
|
|
|
-printf "\tNULL,\n"
|
|
|
+echo "typedef struct {"
|
|
|
+echo " const char** res;"
|
|
|
+echo " const size_t size;"
|
|
|
+echo "} res_t;"
|
|
|
+echo
|
|
|
+echo "static const res_t res[] = {"
|
|
|
needcomma=0
|
|
|
for type in ${types}; do
|
|
|
[ ${needcomma} -eq 1 ] && printf ",\n"
|
|
|
- printf "\tres_%s" "${type}"
|
|
|
+ printf "\t{res_%s, sizeof(res_%s)/sizeof(res_%s[0])}" "${type}" "${type}" "${type}"
|
|
|
needcomma=1
|
|
|
done
|
|
|
echo
|