ad2c revision 151497
175584Sru#! /bin/sh 275584Sru# 375584Sru# ad2c : Convert app-defaults file to C strings decls. 475584Sru# 575584Sru# George Ferguson, ferguson@cs.rcohester.edu, 12 Nov 1990. 675584Sru# 19 Mar 1991: gf 775584Sru# Made it self-contained. 875584Sru# 6 Jan 1992: mycroft@gnu.ai.mit.edu (Charles Hannum) 975584Sru# Removed use of "-n" and ":read" label since Gnu and 1075584Sru# IBM sed print pattern space on "n" command. Still works 1175584Sru# with Sun sed, of course. 1275584Sru# 7 Jan 1992: matthew@sunpix.East.Sun.COM (Matthew Stier) 1375584Sru# Escape quotes after escaping backslashes. 1475584Sru# 8 Jul 1992: Version 1.6 1575584Sru# Manpage fixes. 1675584Sru# 19 Apr 1993: Version 1.7 1775584Sru# Remove comments that were inside the sed command since 1875584Sru# some versions of sed don't like them. The comments are 1975584Sru# now given here in the header. 2075584Sru# 31 May 2004: Werner Lemberg <wl@gnu.org> 2175584Sru# Force casts to `String'. 2275584Sru# 2375584Sru# Comments on the script by line: 2475584Sru# /^!/d Remove comments 2575584Sru# /^$/d Remove blanks 2675584Sru# s/\\/\\\\/g Escape backslashes... 2775584Sru# s/\\$//g ...except the line continuation ones 2875584Sru# s/"/\\"/g Escape quotes 2975584Sru# s/^/"/ Add leading quote and cast 3075584Sru# : test Establish label for later branch 3175584Sru# /\\$/b slash Branch to label "slash" if line ends in backslash 3275584Sru# s/$/",/ Otherwise add closing quote and comma... 3375584Sru# p ...output the line... 3475584Sru# d ...and clear the pattern space so it's not printed again 3575584Sru# : slash Branch comes here if line ends in backslash 3675584Sru# n Read next line, append to pattern space 3775584Sru# [...] The "d" and "s" commands that follow just delete 3875584Sru# comments and blank lines and escape control sequences 3975584Sru# b test Branch up to see if the line ends in backslash or not 4075584Sru# 4175584Sru 4275584Srused ' 4375584Sru/^!/d 4475584Sru/^$/d 4575584Srus/\\/\\\\/g 4675584Srus/\\$//g 4775584Srus/"/\\"/g 4875584Srus/^/(String)"/ 4975584Sru: test 5075584Sru/\\$/b slash 5175584Srus/$/",/ 5275584Srup 5375584Srud 5475584Sru: slash 5575584Srun 5675584Sru/^!/d 5775584Sru/^$/d 5875584Srus/"/\\"/g 5975584Srus/\\\\/\\/g 6075584Srus/\\n/\\\\n/g 6175584Srus/\\t/\\\\t/g 6275584Srus/\\f/\\\\f/g 6375584Srus/\\b/\\\\b/g 6475584Srub test' "$@" 6575584Sru