From http://www.jwz.org/xscreensaver/xscreensaver-5.27.tar.gz
[xscreensaver] / utils / ad2c
1 #!/bin/sh
2 #
3 #       ad2c : Convert app-defaults file to C strings decls.
4 #
5 #       George Ferguson, ferguson@cs.rcohester.edu, 12 Nov 1990.
6 #       19 Mar 1991 : gf
7 #               Made it self-contained.
8 #       6 Jan 1992 : mycroft@gnu.ai.mit.edu (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: matthew@sunpix.East.Sun.COM (Matthew Stier)
13 #               Escape quotes after escaping backslashes.
14 #       22 Oct 2004: jwz:
15 #               Convert CR to LF.
16 #
17
18 #sed 's/\r/\n/g' "$@" |
19 perl -npe 's/\r/\n/g' < "$@" |
20 sed '
21 /^!/d
22 /^$/d
23 s/\\/\\\\/g
24 s/\\$//g
25 s/"/\\"/g
26 s/^/"/
27 : test
28 /\\$/b slash
29 s/$/",/
30 p
31 d
32 : slash
33 n
34 /^!/d
35 /^$/d
36 s/"/\\"/g
37 s/\\\\/\\/g
38 s/\\n/\\\\n/g
39 s/\\t/\\\\t/g
40 s/\\f/\\\\f/g
41 s/\\b/\\\\b/g
42 b test'