Ver Fonte

makeset.sh: Allow empty lists

Issue #97
Bryan Drewery há 10 anos atrás
pai
commit
0cd9392b69
1 ficheiros alterados com 7 adições e 1 exclusões
  1. 7 1
      build/makeset.sh

+ 7 - 1
build/makeset.sh

@@ -2,15 +2,21 @@
 
 echo "/* Generated by $0 */"
 needcomma=0
+printedtype=0
 while read -r line; do
 	[ -z "${line%%#*}" ] && continue # skip comments
+	# :type/:end
 	if [ -n "${line}" -a -z "${line%%:*}" ]; then
-		[ ${needcomma} -eq 1 ] && printf "\"\n\n"
+		# Close out the last type.
+		[ ${printedtype} -eq 1 ] && printf "%c\n\n" '"'
 		type="${line#:}"
 		[ "${type}" = "end" ] && break
 		printf "#define DEFAULT_%s \"%c\n" $(echo "${type}" | tr '[:lower:]' '[:upper:]') '\'
 		needcomma=0
+		printedtype=1
 	else
+	# entry
+		# Comma-separate the last entry.
 		[ ${needcomma} -eq 1 ] && printf ",%c\n" '\'
 		printf "%s" "${line}"
 		needcomma=1