Added --define argument

This commit is contained in:
Yevgen Muntyan 2008-05-26 22:58:20 -05:00
parent 2132e2dc62
commit d8c03256ee

View File

@ -1,5 +1,19 @@
if [ -z "$2" ]; then
echo usage: "$0 <var_name> <file_name>"
define=false
while true; do
case "$1" in
--define)
define=true
shift
;;
*)
break
;;
esac
done
if [ $# != 2 ]; then
echo "usage: $0 [--define] <var_name> <file_name>" > /dev/stderr
exit 1
fi
@ -7,6 +21,13 @@ VARNAME="$1"
INPUT="$2"
echo "/* -*- C -*- */"
echo "static const char $VARNAME [] = \"\""
sed 's/"/\\"/g' "$INPUT" | sed 's/^\(.*\)$/"\1\\n"/' || exit $?
echo ";"
if $define; then
echo "#define $VARNAME \\"
sed 's/"/\\"/g' "$INPUT" | sed 's/^\(.*\)$/"\1\\n"\\/' || exit $?
echo "\"\""
else
echo "static const char $VARNAME [] = \"\""
sed 's/"/\\"/g' "$INPUT" | sed 's/^\(.*\)$/"\1\\n"/' || exit $?
echo ";"
fi