tkwww/TkWWW/Tcl/tcl2c
2024-12-01 22:35:17 +09:00

42 lines
1.2 KiB
Tcsh
Executable File

#!/bin/csh
# convert a wish script to an initialized C string
# Modified 10/1/93 by sau@bellcore.com
# Modified 3/31/94 by joe@mit.edu
# Modified 6/8/94 by joe@mit.edu to remove reference to $USER
if ($#argv < 1) then
echo "usage: $0 filename.tcl [c_variable_name]"
exit 1
endif
set root=$1:r
set var=`echo $root |tr . _`"_tcl"
if ($#argv == 2) then
set var="$2"
endif
set file=$1.c
echo "/* this file was machine generated from $1 */" > $file
echo "" >> $file
echo 'char '$var'[] = "\' >>$file
# Transformations applied to each line of the file:
# eliminate blank lines
# eliminate lines that are only comments
# Convert preexisting backslash into double backslash.
# Precede preexisting double quote (") with backslash.
# Add backslash, n, backslash to the end of each line.
sed -e '/^$/d' \
-e '/^[ ]*#/d' \
-e 's/\\/\\\\/g' \
-e 's/"/\\\"/g' \
-e 's/$/\\n\\/' \
$1 >> $file
# Final line of transformed file:
echo ' ";' >> $file