| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# ad2c : Convert app-defaults file to C strings decls. |
| 4 |
# |
| 5 |
# George Ferguson, [email protected], 12 Nov 1990. |
| 6 |
# 19 Mar 1991: gf |
| 7 |
# Made it self-contained. |
| 8 |
# 6 Jan 1992: [email protected] (Charles Hannum) |
| 9 |
# Removed use of "-n" and ":read" label since Gnu and |
| 10 |
# IBM sed print pattern space on "n" command. Still works |
| 11 |
# with Sun sed, of course. |
| 12 |
# 7 Jan 1992: [email protected] (Matthew Stier) |
| 13 |
# Escape quotes after escaping backslashes. |
| 14 |
# 8 Jul 1992: Version 1.6 |
| 15 |
# Manpage fixes. |
| 16 |
# 19 Apr 1993: Version 1.7 |
| 17 |
# Remove comments that were inside the sed command since |
| 18 |
# some versions of sed don't like them. The comments are |
| 19 |
# now given here in the header. |
| 20 |
# |
| 21 |
# Comments on the script by line: |
| 22 |
# /^!/d Remove comments |
| 23 |
# /^$/d Remove blanks |
| 24 |
# s/\\/\\\\/g Escape backslashes... |
| 25 |
# s/\\$//g ...except the line continuation ones |
| 26 |
# s/"/\\"/g Escape quotes |
| 27 |
# s/^/"/ Add leading quote |
| 28 |
# : test Establish label for later branch |
| 29 |
# /\\$/b slash Branch to label "slash" if line ends in backslash |
| 30 |
# s/$/",/ Otherwise add closing quote and comma... |
| 31 |
# p ...output the line... |
| 32 |
# d ...and clear the pattern space so it's not printed again |
| 33 |
# : slash Branch comes here if line ends in backslash |
| 34 |
# n Read next line, append to pattern space |
| 35 |
# [...] The "d" and "s" commands that follow just delete |
| 36 |
# comments and blank lines and escape control sequences |
| 37 |
# b test Branch up to see if the line ends in backslash or not |
| 38 |
# |
| 39 |
|
| 40 |
sed ' |
| 41 |
/^!/d |
| 42 |
/^$/d |
| 43 |
s/\\/\\\\/g |
| 44 |
s/\\$//g |
| 45 |
s/"/\\"/g |
| 46 |
s/^/"/ |
| 47 |
: test |
| 48 |
/\\$/b slash |
| 49 |
s/$/",/ |
| 50 |
p |
| 51 |
d |
| 52 |
: slash |
| 53 |
n |
| 54 |
/^!/d |
| 55 |
/^$/d |
| 56 |
s/"/\\"/g |
| 57 |
s/\\\\/\\/g |
| 58 |
s/\\n/\\\\n/g |
| 59 |
s/\\t/\\\\t/g |
| 60 |
s/\\f/\\\\f/g |
| 61 |
s/\\b/\\\\b/g |
| 62 |
b test' "$@" |