Added --define argument
This commit is contained in:
parent
2132e2dc62
commit
d8c03256ee
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user