File: ad2c

package info (click to toggle)
gridengine 6.2-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 51,532 kB
  • ctags: 51,172
  • sloc: ansic: 418,155; java: 37,080; sh: 22,593; jsp: 7,699; makefile: 5,292; csh: 4,244; xml: 2,901; cpp: 2,086; perl: 1,895; tcl: 1,188; lisp: 669; ruby: 642; yacc: 393; lex: 266
file content (94 lines) | stat: -rwxr-xr-x 2,325 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
#
# ad2c : Convert app-defaults file to C strings decls.
#
# DESCRIPTION
#      Ad2c  converts  X  resource  files  into   C   declarations,
#      appropriate  for  inclusion as fallback resources.
#      It reads from the given files (or stdin if none  are  given)
#      and writes the C declarations to stdout.
# 
# AUTHOR
#      George Ferguson, ferguson@cs.rochester.edu, 12 Nov 1990.
# 
# DISCLAIMER
#      This software is provided as is with no  warranty  expressed
#      or  implied.  I hope you find it useful, but I won't be held
#      responsable for any damage that may occur from reading, com-
#      piling, installing or using it.
# 
#      You are free to use any part of this  code  for  other  pur-
#      poses.  It  would  be nice if you could keep my name on some
#      part of whatever the final product is.
# 
# CHANGE HISTORY
#	19 Mar 1991: gf
#		Made it self-contained.
#	6 Jan 1992: mycroft@gnu.ai.mit.edu (Charles Hannum)
#		Removed use of "-n" and ":read" label since Gnu and
#		IBM sed print pattern space on "n" command. Still works
#		with Sun sed, of course.
#	7 Jan 1992: matthew@sunpix.East.Sun.COM (Matthew Stier)
#		Escape quotes after escaping backslashes.
#	8 Jul 1992: Version 1.6
#       24 Feb 1994: david@ora.com (David Flanagan)
#		convert `!' comments to C-style comments.
#		output blank lines rather than deleting them.
#		this makes the output resemble the input a bit more.
#	30 May 1995: david@ora.com (David Flanagan)
#		an Xmt-specific change to comment out xmtRequires lines,
#		as suggested by Mike McGary.
#


# convert comments

# comment out xmtRequires lines, since we probably will run this script
# on those files too.  Only do this if the line is not \-terminated, since
# the multi-line case is too tricky and rare to bother handling correctly.
# Thanks to Mike McGary for this suggestion.

# ignore blanks

# escape backslash

# except the line continuation ones

# escape quotes

# add leading quote

# just like "read" only does not add leading quote

sed '
/^!$/ {
	s/^!$//
	b
}
/^!/ {
	s|^!\(.*\)|/\*\1 \*/|
	b
}
/xmtRequires:.*[^\\]$/ {
	s|^\(.*\)$|/\* \1 \*/|
	b
}
/^$/b
s/\\/\\\\/g
s/\\$//g
s/"/\\"/g
s/^/"/
: test
/\\$/b slash
s/$/",/
p
d
: slash
n
s/"/\\"/g
s/\\\\/\\/g
s/\\n/\\\\n/g
s/\\t/\\\\t/g
s/\\f/\\\\f/g
s/\\b/\\\\b/g
b test' "$@"