1151497Sru#! /bin/sh
2151497Sru#
3151497Sru#	ad2c : Convert app-defaults file to C strings decls.
4151497Sru#
5151497Sru#	George Ferguson, ferguson@cs.rcohester.edu, 12 Nov 1990.
6151497Sru#	19 Mar 1991: gf
7151497Sru#		Made it self-contained.
8151497Sru#	6 Jan 1992: mycroft@gnu.ai.mit.edu (Charles Hannum)
9151497Sru#		Removed use of "-n" and ":read" label since Gnu and
10151497Sru#		IBM sed print pattern space on "n" command. Still works
11151497Sru#		with Sun sed, of course.
12151497Sru#	7 Jan 1992: matthew@sunpix.East.Sun.COM (Matthew Stier)
13151497Sru#		Escape quotes after escaping backslashes.
14151497Sru#	8 Jul 1992: Version 1.6
15151497Sru#		Manpage fixes.
16151497Sru#	19 Apr 1993: Version 1.7
17151497Sru#		Remove comments that were inside the sed command since
18151497Sru#		some versions of sed don't like them. The comments are
19151497Sru#		now given here in the header.
20151497Sru#	31 May 2004: Werner Lemberg <wl@gnu.org>
21151497Sru#		Force casts to `String'.
22151497Sru#
23151497Sru# Comments on the script by line:
24151497Sru# /^!/d		Remove comments
25151497Sru# /^$/d		Remove blanks
26151497Sru# s/\\/\\\\/g	Escape backslashes...
27151497Sru# s/\\$//g	...except the line continuation ones
28151497Sru# s/"/\\"/g	Escape quotes
29151497Sru# s/^/"/	Add leading quote and cast
30151497Sru# : test	Establish label for later branch
31151497Sru# /\\$/b slash	Branch to label "slash" if line ends in backslash
32151497Sru# s/$/",/	Otherwise add closing quote and comma...
33151497Sru# p		...output the line...
34151497Sru# d		...and clear the pattern space so it's not printed again
35151497Sru# : slash	Branch comes here if line ends in backslash
36151497Sru# n		Read next line, append to pattern space
37151497Sru# [...]		The "d" and "s" commands that follow just delete
38151497Sru#		comments and blank lines and escape control sequences
39151497Sru# b test	Branch up to see if the line ends in backslash or not
40151497Sru#
41151497Sru
42151497Srused '
43151497Sru/^!/d
44151497Sru/^$/d
45151497Srus/\\/\\\\/g
46151497Srus/\\$//g
47151497Srus/"/\\"/g
48151497Srus/^/(String)"/
49151497Sru: test
50151497Sru/\\$/b slash
51151497Srus/$/",/
52151497Srup
53151497Srud
54151497Sru: slash
55151497Srun
56151497Sru/^!/d
57151497Sru/^$/d
58151497Srus/"/\\"/g
59151497Srus/\\\\/\\/g
60151497Srus/\\n/\\\\n/g
61151497Srus/\\t/\\\\t/g
62151497Srus/\\f/\\\\f/g
63151497Srus/\\b/\\\\b/g
64151497Srub test' "$@"
65