ad2c - convert app-defaults file to C decls
George Ferguson
ferguson at cs.rochester.edu
Thu Nov 15 08:32:41 AEST 1990
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 1 (of 1)."
# Contents: README ad2c ad2c.sed
# Wrapped by ferguson at swan.cs.rochester.edu on Mon Nov 12 13:46:45 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1029 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X
X README for AD2C - convert resource files to C decls
X
X George Ferguson, ferguson at cs.rochester.edu
X
X 12 Nov 1990
X
XDESCRIPTION:
X
X Ad2c is a program which converts X resource files into C
X declarations appropriate for inclusion as fallback resources.
X The program is a sed script which is effectively a finite state
X machine, escaping quotes and backslashes (and newlines where
X necessary), and adding quotes and commas as needed for array
X initialization.
X
XDISCLAIMER:
X
X This software is provided as is with no warranty expressed or implied.
X I hope you find it useful, but I won't be held responsable for
X any damage that may occur from reading, compiling, installing or
X using it.
X
X You are free to use any part of this code for other purposes. It
X would be nice if you could keep my name on some part of whatever the
X final product is.
X
XINSTALLATION:
X
X 1. Edit ad2c to reflect where its script file ad2c.sed is installed.
X
X 2. Make sure ad2c is executable.
END_OF_FILE
if test 1029 -ne `wc -c <'README'`; then
echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'ad2c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'ad2c'\"
else
echo shar: Extracting \"'ad2c'\" \(102 characters\)
sed "s/^X//" >'ad2c' <<'END_OF_FILE'
X#!/bin/csh
X#
X# Convert app-defaults file to C strings decls.
X#
X
Xsed -n -f /u/ferguson/bin/ad2c.sed $*
END_OF_FILE
if test 102 -ne `wc -c <'ad2c'`; then
echo shar: \"'ad2c'\" unpacked with wrong size!
fi
chmod +x 'ad2c'
# end of 'ad2c'
fi
if test -f 'ad2c.sed' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'ad2c.sed'\"
else
echo shar: Extracting \"'ad2c.sed'\" \(470 characters\)
sed "s/^X//" >'ad2c.sed' <<'END_OF_FILE'
X#
X# Convert app-defaults file to C strings decls.
X#
X# Invoke by: sed -n -f ad2c.sed
X#
X: read
X# remove comments
X/^!/d
X# remove blanks
X/^$/d
X# escape quotes
Xs/"/\\"/g
X# escape backslash
Xs/\\/\\\\/g
X# except the line continuation ones
Xs/\\$//g
X# add leading quote
Xs/^/"/
X#
X: test
X/\\$/b slash
Xs/$/",/
Xp
Xn
Xb read
X#
X: slash
Xp
Xn
X# just like "read" only doesn't add leading quote
X/^!/d
X/^$/d
Xs/"/\\"/g
Xs/\\\\/\\/g
Xs/\\n/\\\\n/g
Xs/\\t/\\\\t/g
Xs/\\f/\\\\f/g
Xs/\\b/\\\\b/g
Xb test
END_OF_FILE
if test 470 -ne `wc -c <'ad2c.sed'`; then
echo shar: \"'ad2c.sed'\" unpacked with wrong size!
fi
# end of 'ad2c.sed'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have the archive.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
George Ferguson ARPA: ferguson at cs.rochester.edu
University of Rochester UUCP: {decvax,rutgers}!rochester!ferguson
Rochester NY 14627 VOX: (716) 275-2527
More information about the Alt.sources
mailing list