]>
git.saurik.com Git - wxWidgets.git/blob - src/png/scripts/checksym.awk
2 # Check a list of symbols against the master definition
3 # (official) list. Arguments:
5 # awk -f checksym.awk official-def list-to-check
7 # Output is a file in the current directory called 'symbols.new',
8 # stdout holds error messages. Error code indicates success or
11 # NOTE: this is a pure, old fashioned, awk script. It will
16 master=
"" # master file
17 official
[1] =
"" # defined symbols from master file
18 symbol
[1] =
"" # defined symbols from png.h
19 removed
[1] =
"" # removed symbols from png.h
20 lasto =
0 # last ordinal value from png.h
21 mastero =
0 # highest ordinal in master file
22 symbolo =
0 # highest ordinal in png.h
23 missing =
"error"# log an error on missing symbols
26 # Read existing definitions from the master file (the first
27 # file on the command line.) This must be a def file and it
28 # has definition lines (others are ignored) of the form:
35 FILENAME==master
&& NF==
2 && $2~
/^@
/ && $1!~
/^
;/ {
38 if (official
[o
] ==
"") {
40 if (o
> mastero
) mastero = o
43 print master
": duplicated symbol:", official
[o
] ":", $0
45 print master
": bad export line format:", $0
48 FILENAME==master
&& $1==
";missing" && NF==
2{
49 # This allows the master file to control how missing symbols
50 # are handled; symbols that aren't in either the master or
51 # the new file. Valid values are 'ignore', 'warning' and
59 # Read new definitions, these are free form but the lines must
60 # just be symbol definitions. Lines will be commented out for
61 # 'removed' symbols, introduced in png.h using PNG_REMOVED rather
62 # than PNG_EXPORT. Use symbols.dfn or pngwin.dfn to generate the
65 # symbol @ordinal # two fields, exported symbol
66 # ; symbol @ordinal # three fields, removed symbol
67 # ; @ordinal # two fields, the last ordinal
68 NF==
2 && $1 ==
";" && $2 ~
/^@
[1-9][0-9]*$
/ { # last ordinal
70 if (lasto ==
0 || lasto == o
)
73 print "png.h: duplicated last ordinal:", lasto
, o
78 NF==
3 && $1 ==
";" && $3 ~
/^@
[1-9][0-9]*$
/ { # removed symbol
80 if (removed
[o
] ==
"" || removed
[o
] ==
$2) {
82 if (o
> symbolo
) symbolo = o
84 print "png.h: duplicated removed symbol", o
": '" removed
[o
] "' != '" $2 "'"
89 NF==
2 && $2 ~
/^@
[1-9][0-9]*$
/ { # exported symbol
91 if (symbol
[o
] ==
"" || symbol
[o
] ==
$1) {
93 if (o
> symbolo
) symbolo = o
95 print "png.h: duplicated symbol", o
": '" symbol
[o
] "' != '" $1 "'"
100 next # skip all other lines
103 # At the end check for symbols marked as both duplicated and removed
105 if (symbolo
> lasto
) {
106 print "highest symbol ordinal in png.h,", symbolo
", exceeds last ordinal from png.h", lasto
109 if (mastero
> lasto
) {
110 print "highest symbol ordinal in", master
",", mastero
", exceeds last ordinal from png.h", lasto
114 for (o=
1; o
<=lasto
; ++o
) {
115 if (symbol
[o
] ==
"" && removed
[o
] ==
"") {
116 if (unexported ==
0) unexported = o
117 if (official
[o
] ==
"") {
118 # missing in export list too, so ok
119 if (o
< lasto
) continue
122 if (unexported
!= 0) {
123 # Symbols in the .def but not in the new file are errors, but
124 # the 'unexported' symbols aren't in either. By default this
125 # is an error too (see the setting of 'missing' at the start),
126 # but this can be reset on the command line or by stuff in the
127 # file - see the comments above.
128 if (missing
!= "ignore") {
129 if (o
-1 > unexported
)
130 print "png.h:", missing
": missing symbols:", unexported
"-" o
-1
132 print "png.h:", missing
": missing symbol:", unexported
133 if (missing
!= "warning")
138 if (symbol
[o
] != "" && removed
[o
] != "") {
139 print "png.h: symbol", o
, "both exported as '" symbol
[o
] "' and removed as '" removed
[o
] "'"
141 } else if (symbol
[o
] != official
[o
]) {
142 # either the symbol is missing somewhere or it changed
145 print "png.h: symbol", o
, "is exported as '" official
[o
] "' in", master
146 else if (official
[o
] ==
"")
147 print "png.h: exported symbol", o
, "'" symbol
[o
] "' not present in", master
149 print "png.h: exported symbol", o
, "'" symbol
[o
] "' exists as '" official
[o
] "' in", master
152 # Finally generate symbols.new
154 print " " symbol
[o
], "@" o
> "symbols.new"
158 print "*** A new list is in symbols.new ***"