-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsunifdef.1
460 lines (460 loc) · 26.6 KB
/
sunifdef.1
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "sunifdef 1"
.TH sunifdef 1 "strudl.org" "JANUARY 2008" "User Commmands"
.SH "NAME"
sunifdef \- simplify C preprocessor source files
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
sunifdef [\fB\-v\fR | \fB\-\-version\fR]
.PP
sunifdef [\fB\-h\fR | \fB\-\-help\fR]
.PP
sunifdef [\s-1OPTION\s0...] [\fIfiles\fR...]
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\fBsunifdef\fR is a more powerful successor of the FreeBSD \fBunifdef\fR tool. \fBsunifdef\fR is a preprocessor of C or \*(C+ preprocessor source files (or more briefly a preprocessor of C/\*(C+ source files).
.PP
From the commandline arguments it takes a set of assumptions about the symbols to be defined, or undefined, for the \s-1CPP\s0. From the commandline it also takes one or more source files. It parses these source files to pick out conditional preprocessor directives (\fB#if\fR,\fB#ifdef\fR,\fB#ifndef\fR,\fB#else\fR,\fB#elif\fR,\fB#endif\fR). It applies the specified assumptions to these directives in attempt to evaluate them. Directives that cannot be fully evaluated on the basis of the assumptions are simplified as much as possible. Directives that can be fully evaluated are eliminated, and the source text that they control is either retained or deleted in accordance with the evaluation, mimicking the behaviour of the \s-1CPP\s0.
.PP
\&\fBsunifdef\fR also detects \fB#define\fR and \fB#undef\fR directives and checks them for consistency with the specified assumptions. If a \fB#define\fR or \fB#undef\fR directive repeats one of the assumptions it is deleted on output; if it conflicts with any of the assumptions then it may be deleted or replaced with a diagnostic comment or a diagnostic \fB#error\fR, depending on commandline options.
.PP
For each source file, an output file is generated that reflects the simplifications arising from the specified assumptions. The command
.PP
\&\fBsunifdef \-DFOO bar.c\fR
.PP
will write on the standard output a revision of the file \fBbar.c\fR that has been purged as far as possible of preprocessor constructions controlled by the truth-value of \fBdefined(\s-1FOO\s0)\fR. This revision is equivalent to \fBbar.c\fR on the assumption that \fB\s-1FOO\s0\fR is defined. With appropriate options and inputs, you can use a \fBsunifdef\fR command to perform wholesale removal of redundant preprocessor complexities from a C or \*(C+ source tree. See the \fB\s-1EXAMPLES\s0\fR section.
.SH "OPTIONS"
.IX Header "OPTIONS"
.IP "\fB\-h\fR,\fB\-\-help\fR" 4
.IX Item "-h,--help"
Display a usage summary and exit.
.IP "\fB\-v\fR,\fB\-\-version\fR" 4
.IX Item "-v,--version"
Display version information and exit.
.IP "\fB\-s\fR[\fBf\fR|\fBa\fR][\fBl\fR], \fB\-\-symbols\fR [\fBfirst\fR | \fBall\fR][\fB,locate\fR]" 4
.IX Item "-s[f|a][l], --symbols [first | all][,locate]"
Output a list of symbols that are determinative for the truth value of \fB#if\fR conditions.
.Sp
\&\fBf\fR, \fBfirst\fR: List only the first occurrence of the symbol on input.
.Sp
\&\fBa\fR, \fBall\fR: List all occurrences of the symbol on input.
.Sp
\&\fBl\fR, \fBlocate\fR: Report the file and line number of each listed occurrence.
.IP "\fBf\fR\fIargfile\fR, \fB\-\-file\fR \fIargfile\fR" 4
.IX Item "fargfile, --file argfile"
Read (more) arguments from file \fIargfile\fR. Arguments may be written free\-form, separated by whitespace, in \fIargfile\fR. These arguments will be parsed exactly as if they were listed on the commandline at the position of \-\fBf\fR\fIargfile\fR.
.IP "\fB\-D\fR\fImacro\fR[\fB=\fR\fIstring\fR], \fB\-\-define\fR \fImacro\fR[\fB=\fR\fIstring\fR]" 4
.IX Item "-Dmacro[=string], --define macro[=string]"
Assume that \fB#define\fR \fImacro\fR[\fB=\fR\fIstring\fR] is in force for processing the input file(s).
.IP "\fB\-U\fR\fImacro\fR, \fB\-\-undef\fR \fImacro\fR" 4
.IX Item "-Umacro, --undef macro"
Assume that \fB#undef\fR \fImacro\fR is in force for processing the input file(s).
.IP "\fB\-r\fR, \fB\-\-replace\fR" 4
.IX Item "-r, --replace"
Replace each input file with the corresponding output file. \fIYou must specify this option to process multiple input files\fR.
.Sp
The option changes the default behaviour of the command when no input files are specified. In this case, input is acquired from the standard input. If \fB\-r\fR is \fInot\fR specified, then a single input file is read from the standard input. If \fB\-r\fR is specified then the \fInames\fR of the input files are read from the standard input. Note that \fB\-\-recurse\fR implies \fB\-\-replace\fR.
.Sp
If the names of the input files are read from stdin, the filenames are delimited by whitespace unless enclosed in double\-quotes.
.IP "\fB\-R\fR, \fB\-\-recurse\fR" 4
.IX Item "-R, --recurse"
Recurse into directories to find input files. Implies \fB\-\-replace\fR. The input files may include directories with this option: otherwise a directory provokes a non-fatal error.
.Sp
All files within a directory (and within subdirectories) will be selected for input unless the \fB\-\-filter\fR option is given: otherwise all files (including subdirectories) will be selected that match the \fB\-\-filter\fR option.
.Sp
When \fB\-\-recurse\fR is in effect, \fBsunifdef\fR builds a graph of all unique input files once and for all as it parses the filenames that are explicitly supplied and before it processes any of them. New files that may later appear in input directories during execution will not be processed, and files that have disappeared from input directories when they are due to be processed will provoke fatal errors.
.IP "\fB\-F\fR\fIext1\fR[\fB,\fR\fIext2\fR...], \fB\-\-filter\fR \fIext1\fR[\fB,\fR\fIext2\fR...]" 4
.IX Item "-Fext1[,ext2...], --filter ext1[,ext2...]"
Process only input files that have one of the file extensions \fIext1\fR,\fIext2\fR... A file extension may be any terminal segment of a filename that follows a '.'.
.IP "\fB\-B\fR\fIsuffix\fR, \fB\-\-backup\fR \fIsuffix\fR" 4
.IX Item "-Bsuffix, --backup suffix"
Backup each input file before replacing it, the backup file having the same name as the input file with \fIsuffix\fR appended to it.
.IP "\fB\-x\fR[\fBd\fR|\fBc\fR|\fBe\fR], \fB\-\-conflict\fR [\fBdelete\fR | \fBcomment\fR | \fBerror\fR]" 4
.IX Item "-x[d|c|e], --conflict [delete | comment | error]"
Select the action to be taken when a \fB#define\fR or \fB#undef\fR directive is encountered in an input file that conflicts with one of the \fB\-D\fR or \fB\-U\fR assumptions:
.Sp
\&\fBd\fR, \fBdelete\fR: Delete the conflicting directive.
.Sp
\&\fBc\fR, \fBcomment\fR: Replace the conflicting directive with a diagnostic comment (\fBdefault\fR).
.Sp
\&\fBe\fR, \fBerror\fR: Replace the conflicting directive with a diagnostic \fB#error\fR directive.
.IP "\fB\-g\fR[\fBp\fR|\fBi\fR|\fBw\fR|\fBe\fR|\fBa\fR], \fB\-\-gag\fR [\fBprogress\fR | \fBinfo\fR | \fBwarning\fR | \fBerror\fR | \fBabend\fR]" 4
.IX Item "-g[p|i|w|e|a], --gag [progress | info | warning | error | abend]"
Suppress diagnostics no worse than [\fBprogress\fR | \fBinfo\fR | \fBwarning\fR | \fBerror\fR | \fBabend\fR].
.IP "\fB\-gs\fR, \fB\-\-gag summary\fR." 4
.IX Item "-gs, --gag summary."
Suppress summary diagnostics at end of input.
.IP "\fB\-V\fR, \fB\-\-verbose\fR" 4
.IX Item "-V, --verbose"
Output all diagnostics,
.Sp
If neither \fB\-V\fR nor \fB\-g\fR\fIarg\fR is specified defaults are \fB\-gp \-gi \-gs\fR.
.IP "\fB\-n\fR[\fBu\fR|\fBe\fR[\fBd\fR]], \fB\-\-constant\fR [\fBunk\fR | \fBeval\fR[\fB,del\fR]]" 4
.IX Item "-n[u|e[d]], --constant [unk | eval[,del]]"
Select the policy for processing constants in \fB#if\fR directives:
.Sp
\&\fBu\fR, \fBunk\fR: Treat constants as unknowns, i.e. like macros that are not subject to any assumptions (\fBdefault\fR).
.Sp
\&\fBe\fR[\fBd\fR], \fBeval\fR[\fB,del\fR]: Evaluate constants [and optionally eliminate them].
.IP "\fB\-c\fR, \fB\-\-complement\fR" 4
.IX Item "-c, --complement"
Ouput the lines that ought to be dropped and vice versa.
.IP "\fB\-d\fR, \fB\-\-debug\fR" 4
.IX Item "-d, --debug"
Write debugging information to stderr.
.IP "\fB\-k\fR[\fBd\fR|\fBb\fR|\fBc\fR], \fB\-\-discard\fR [\fBdrop\fR | \fBblank\fR | \fBcomment\fR]" 4
.IX Item "-k[d|b|c], --discard [drop | blank | comment]"
Select the policy for discarding lines from output:
.Sp
\&\fBd\fR, \fBdrop\fR: Drop discarded lines.
.Sp
\&\fBb\fR, \fBblank\fR: Blank discarded lines.
.Sp
\&\fBc\fR, \fBcomment\fR: Comment out discarded lines.
.IP "\fB\-K\fR, \fB\-\-keepgoing\fR" 4
.IX Item "-K, --keepgoing"
If a parse error is encountered in an input file, continue processing subsequent input files. An event of severity \fBabend\fR will terminate processing regardless of \fB\-\-keepgoing\fR.
.IP "\fB\-P\fR, \fB\-\-pod\fR" 4
.IX Item "-P, --pod"
Apart from \s-1CPP\s0 directives, input is to be treated as Plain Old Data. C/\*(C+ comments and quotations will not be parsed.
.IP "\fB\-l\fR, \fB\-\-line\fR" 4
.IX Item "-l, --line"
Output #line directives in place of discarded lines to preserve the line numbers of retained lines.
.SH "EXAMPLES"
.IX Header "EXAMPLES"
.IP "\fBsunifdef \-DUNIX \-UWIN32 foo.c\fR" 4
.IX Item "sunifdef -DUNIX -UWIN32 foo.c"
.PD 0
.IP "\fBsunifdef \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 foo.c\fR" 4
.IX Item "sunifdef --define UNIX --undef WIN32 foo.c"
.PD
Simplify the file \fBfoo.c\fR assuming that the symbol \fB\s-1UNIX\s0\fR is defined and the symbol \fB\s-1WIN32\s0\fR is undefined. Write the simplified file to stdout. By default diagnostic messages whose severity is \fIwarning\fR or higher will be output and no summary diagnostics will be output. All diagnostics are written to stderr.
.IP "\fBsunifdef \-DUNIX=1 \-UWIN32 foo.c\fR" 4
.IX Item "sunifdef -DUNIX=1 -UWIN32 foo.c"
.PD 0
.IP "\fBsunifdef \-\-define UNIX=1 \-\-undef \s-1WIN32\s0 foo.c\fR" 4
.IX Item "sunifdef --define UNIX=1 --undef WIN32 foo.c"
.PD
Like the previous example, but the symbol \fB\s-1UNIX\s0\fR is defined as 1.
.IP "\fBsunifdef \-gw \-DUNIX \-UWIN32 foo.c\fR" 4
.IX Item "sunifdef -gw -DUNIX -UWIN32 foo.c"
.PD 0
.IP "\fBsunifdef \-\-gag warn \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 foo.c\fR" 4
.IX Item "sunifdef --gag warn --define UNIX --undef WIN32 foo.c"
.PD
Like the first example, but suppress all diagnostics (\-\-gag) whose severity is warning or lower that would otherwise be written to stderr.
.IP "\fBsunifdef \-gw \-DUNIX \-UWIN32 foo.c\fR" 4
.IX Item "sunifdef -gw -DUNIX -UWIN32 foo.c"
.PD 0
.IP "\fBsunifdef \-\-gag warn \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 foo.c\fR" 4
.IX Item "sunifdef --gag warn --define UNIX --undef WIN32 foo.c"
.PD
Like the first example, but suppress all diagnostics (\fB\-\-gag\fR) whose severity is \fIwarning\fR or lower that would otherwise be written to stderr.
.IP "\fBsunifdef \-gw \-gs \-DUNIX \-UWIN32 foo.c\fR" 4
.IX Item "sunifdef -gw -gs -DUNIX -UWIN32 foo.c"
.PD 0
.IP "\fBsunifdef \-\-gag warn \-gag summary \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 foo.c\fR" 4
.IX Item "sunifdef --gag warn -gag summary --define UNIX --undef WIN32 foo.c"
.PD
Like the previous example, but also suppress all summary diagnostics that would otherwise be written to stderr after processing is finished (\fB\-\-gag summary\fR).
.IP "\fBsunifdef \-V \-DUNIX \-UWIN32 foo.c\fR" 4
.IX Item "sunifdef -V -DUNIX -UWIN32 foo.c"
.PD 0
.IP "\fBsunifdef \-\-verbose \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 foo.c\fR" 4
.IX Item "sunifdef --verbose --define UNIX --undef WIN32 foo.c"
.PD
Like the previous example, but write all diagnostics at all severities to stderr, as well as summary diagnostics (\fB\-\-verbose\fR).
.IP "\fBsunifdef \-DUNIX \-UWIN32 < bar.c\fR" 4
.IX Item "sunifdef -DUNIX -UWIN32 < bar.c"
.PD 0
.IP "\fBsunifdef \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 < bar.c\fR" 4
.IX Item "sunifdef --define UNIX --undef WIN32 < bar.c"
.PD
Like the previous example, but write only the default diagnostics to stderr and read the input file from stdin (in this case redirected from \fIbar.c\fR)
.IP "\fBsunifdef \-r \-DUNIX \-UWIN32 foo.c bar.c\fR" 4
.IX Item "sunifdef -r -DUNIX -UWIN32 foo.c bar.c"
.PD 0
.IP "\fBsunifdef \-\-replace \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 foo.c bar.c\fR" 4
.IX Item "sunifdef --replace --define UNIX --undef WIN32 foo.c bar.c"
.PD
Like the previous example, but \fB\-\-replace\fR causes each input file to be replaced with the corresponding simplified output file. With this option multiple input files \- \fIfoo.c\fR, \fIbar.c\fR \- can be supplied.
.IP "\fBsunifdef \-r \-DUNIX \-UWIN32 < filelist.txt\fR" 4
.IX Item "sunifdef -r -DUNIX -UWIN32 < filelist.txt"
.PD 0
.IP "\fBsunifdef \-\-replace \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 < filelist.txt\fR" 4
.IX Item "sunifdef --replace --define UNIX --undef WIN32 < filelist.txt"
.PD
Like the previous example, but read the list of input filenames from stdin (in this case redirected from \fIfilelist.txt\fR)
.IP "\fBsunifdef \-r \-B.bak \-DUNIX \-UWIN32 < filelist.txt\fR" 4
.IX Item "sunifdef -r -B.bak -DUNIX -UWIN32 < filelist.txt"
.PD 0
.ie n .IP "\fBsunifdef \-\-replace \-\-backup "".bak"" \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 < filelist.txt\fR" 4
.el .IP "\fBsunifdef \-\-replace \-\-backup ``.bak'' \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 < filelist.txt\fR" 4
.IX Item "sunifdef --replace --backup .bak --define UNIX --undef WIN32 < filelist.txt"
.PD
Like the previous example, but create a backup of each input file with the extension \fB.bak\fR (\fB\-\-backup \*(L".bak\*(R"\fR).
.IP "\fBsunifdef \-R \-DUNIX \-UWIN32 foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef -R -DUNIX -UWIN32 foo.c somedir bar.h otherdir"
.PD 0
.IP "\fBsunifdef \-\-recurse \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef --recurse --define UNIX --undef WIN32 foo.c somedir bar.h otherdir"
.PD
The \fB\-\-recurse\fR option implies \fB\-\-replace\fR and causes sunifdef to find additional input files by searching recursively within the directories \fIsomedir\fR and \fIotherdir\fR
.IP "\fBsunifdef \-R \-Fc,h \-DUNIX \-UWIN32 foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef -R -Fc,h -DUNIX -UWIN32 foo.c somedir bar.h otherdir"
.PD 0
.IP "\fBsunifdef \-\-recurse \-\-filter c,h \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef --recurse --filter c,h --define UNIX --undef WIN32 foo.c somedir bar.h otherdir"
.PD
Like the previous example, but select only input files that have one of the extensions \fB.c\fR or \fB.h\fR (\fB\-\-filter c,h\fR).
.IP "\fBsunifdef \-R \-Fc,h \-K \-DUNIX \-UWIN32 foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef -R -Fc,h -K -DUNIX -UWIN32 foo.c somedir bar.h otherdir"
.PD 0
.IP "\fBsunifdef \-\-recurse \-\-filter c,h \-\-keepgoing \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef --recurse --filter c,h --keepgoing --define UNIX --undef WIN32 foo.c somedir bar.h otherdir"
.PD
Like the previous example, but keep going through parse errors (\fB\-\-keepgoing\fR). Processing of the input file in error will be abandoned but subsequent input files will be processed.
.IP "\fBsunifdef \-R \-Fc,h \-sf foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef -R -Fc,h -sf foo.c somedir bar.h otherdir"
.PD 0
.IP "\fBsunifdef \-\-recurse \-\-filter c,h \-\-symbols first foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef --recurse --filter c,h --symbols first foo.c somedir bar.h otherdir"
.PD
Recursively select all the \fI.c\fR and \fI.h\fR files from \fIfoo.c\fR, \fIsomedir\fR, \fIbar.h\fR, \fIotherdir\fR and write on stderr a list of all the symbols that influence the truth-values of \fB#if\fR, \fB#else\fR, \fB#elif\fR conditions. Report only the first occurrence of each symbol.
.IP "\fBsunifdef \-R \-Fc,h \-sfl foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef -R -Fc,h -sfl foo.c somedir bar.h otherdir"
.PD 0
.IP "\fBsunifdef \-\-recurse \-\-filter c,h \-\-symbols first,locate foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef --recurse --filter c,h --symbols first,locate foo.c somedir bar.h otherdir"
.PD
Like the previous example, but report the file and line number of each reported symbol (\fB\-\-symbols first,locate\fR)
.IP "\fBsunifdef \-R \-Fc,h \-sal foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef -R -Fc,h -sal foo.c somedir bar.h otherdir"
.PD 0
.IP "\fBsunifdef \-\-recurse \-\-filter c,h \-\-symbols all,locate foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef --recurse --filter c,h --symbols all,locate foo.c somedir bar.h otherdir"
.PD
Like the previous example, but report all occurrences of the symbols (\fB\-\-symbols first,locate\fR)
.IP "\fBsunifdef \-P \-DUNIX \-UWIN32 data.txt\fR" 4
.IX Item "sunifdef -P -DUNIX -UWIN32 data.txt"
.PD 0
.IP "\fBsunifdef \-\-pod \-\-define \s-1UNIX\s0 \-\-undef \s-1WIN32\s0 data.txt\fR" 4
.IX Item "sunifdef --pod --define UNIX --undef WIN32 data.txt"
.PD
Process the file \fIdata.txt\fR with the assumptions \fB\-\-define \s-1UNIX\s0\fR and \fB\-\-undef \s-1WIN32\s0\fR parsing the text (other than \fB#\fR\-directives) as Plain Old Data, rather than C/\*(C+ source. C/\*(C+ comments and quotations will not be recognised.
.IP "\fBsunifdef \-R \-fargs.txt foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef -R -fargs.txt foo.c somedir bar.h otherdir"
.PD 0
.IP "\fBsunifdef \-R \-\-file args.txt foo.c somedir bar.h otherdir\fR" 4
.IX Item "sunifdef -R --file args.txt foo.c somedir bar.h otherdir"
.PD
Interprolate the contents of the file \fIargs.txt\fR into the commandline, replacing \fB\-\-file args.txt\fR and then execute the resulting command.
.IP "\fBsunifdef \-fargs.txt\fR" 4
.IX Item "sunifdef -fargs.txt"
.PD 0
.IP "\fBsunifdef \-\-file args.txt\fR" 4
.IX Item "sunifdef --file args.txt"
.PD
Substite the contents of the file \fIargs.txt\fR for \fB\-\-file args.txt\fR and then execute the resulting command.
.SH "DIAGNOSTICS"
.IX Header "DIAGNOSTICS"
.ie n .IP "Diagnostics written to stderr are classified by severity. Each diagnostic includes a distinct hexadecimal code of the form ""0xXXXXX"" that encodes its severity. The 5 severities are:" 4
.el .IP "Diagnostics written to stderr are classified by severity. Each diagnostic includes a distinct hexadecimal code of the form \f(CW0xXXXXX\fR that encodes its severity. The 5 severities are:" 4
.IX Item "Diagnostics written to stderr are classified by severity. Each diagnostic includes a distinct hexadecimal code of the form 0xXXXXX that encodes its severity. The 5 severities are:"
.PD 0
.IP "\&" 4
.PD
\&\fBprogress\fR: Progress messages (\f(CW\*(C`0xXXXXX & 0x00800\*(C'\fR is true)
.Sp
\&\fBinfo\fR: Noteworthy information (\f(CW\*(C`0xXXXXX & 0x01000\*(C'\fR is true)
.Sp
\&\fBwarning\fR: Indicating problematic input (\f(CW\*(C`0xXXXXX & 0x02000\*(C'\fR is true)
.Sp
\&\fBerror\fR: Indicating invalid input (\f(CW\*(C`0xXXXXX & 0x04000\*(C'\fR is true)
.Sp
\&\fBabend\fR: Indicating a fatal environment or internal error (\f(CW\*(C`0xXXXXX & 0x08000\*(C'\fR is true)
.ie n .IP "Unless \fB\-\-gag summary\fR is in force, \fBsunifdef\fR can write summary diagnostics at the end of processing. A summary diagnostic has a hexadecimal code \fBS\fR that encodes one of the severities and in addition \fBS\fR ""& 0x10000""\fR is true. Even if \fB\-\-gag summary\fR is not in force, a summary will not be written if its severity is suppressed by one of the specified or default \fB\-\-gag options\fR. Since all summaries have severity \fIinfo\fR or \fIwarning\fR, this means that by default no summaries will appear and to obtain all summaries you must specify \fB\-\-verbose. The summaries include:" 4
.el .IP "Unless \fB\-\-gag summary\fR is in force, \fBsunifdef\fR can write summary diagnostics at the end of processing. A summary diagnostic has a hexadecimal code \fBS\fR that encodes one of the severities and in addition \fBS\fR \f(CW& 0x10000\fR is true. Even if \fB\-\-gag summary\fR is not in force, a summary will not be written if its severity is suppressed by one of the specified or default \fB\-\-gag options\fR. Since all summaries have severity \fIinfo\fR or \fIwarning\fR, this means that by default no summaries will appear and to obtain all summaries you must specify \fB\-\-verbose\fR. The summaries include:" 4
.IX Item "Unless --gag summary is in force, sunifdef can write summary diagnostics at the end of processing. A summary diagnostic has a hexadecimal code S that encodes one of the severities and in addition S & 0x10000 is true. Even if --gag summary is not in force, a summary will not be written if its severity is suppressed by one of the specified or default --gag options. Since all summaries have severity info or warning, this means that by default no summaries will appear and to obtain all summaries you must specify --verbose. The summaries include:"
.PD 0
.IP "\&" 4
.PD
\&\fBinfo\fR: The number of input files that were reached and the number that were not reached (due to abend).
.Sp
\&\fBinfo\fR: The number of input files reached that were abandoned (due to errors).
.IP "If there was no abend or error, then additional summaries are written (unless suppressed) indicating each of the following outcomes that has occurred:" 4
.IX Item "If there was no abend or error, then additional summaries are written (unless suppressed) indicating each of the following outcomes that has occurred:"
.PD 0
.IP "\&" 4
.PD
\&\fBinfo\fR: Input lines were dropped on output.
.Sp
\&\fBinfo\fR: Input lines were changed on output.
.Sp
\&\fBwarning\fR: Input lines were changed to \fB#error\fR directives.
.Sp
\&\fBwarning\fR: Unconditional #error directives were output.
.IP "sunifdef returns a system code \fB\s-1SC\s0\fR of which the low order half of the low order byte is always meaningful:" 4
.IX Item "sunifdef returns a system code SC of which the low order half of the low order byte is always meaningful:"
.PD 0
.IP "\&" 4
.PD
\&\fB\s-1SC\s0\fR \f(CW\*(C`& 1\*(C'\fR: Informational diagnostics accrued.
.Sp
\&\fB\s-1SC\s0\fR \f(CW\*(C`& 2\*(C'\fR: Warnings diagnostics accrued.
.Sp
\&\fB\s-1SC\s0\fR \f(CW\*(C`& 4\*(C'\fR: Error diagnostics accrued. (Input files provoking errors will be unchanged notwithstanding the \fB\-\-replace\fR option.)
.Sp
\&\fB\s-1SC\s0\fR \f(CW\*(C`& 8\*(C'\fR: An abend occurred. Some input files may not have been reached.
.IP "If no error or abend is indicated, then the high order half of the low order byte is also meaningful:" 4
.IX Item "If no error or abend is indicated, then the high order half of the low order byte is also meaningful:"
\&\fB\s-1SC\s0\fR \f(CW\*(C`& 16\*(C'\fR: Input lines were dropped on output.
\&\fB\s-1SC\s0\fR \f(CW\*(C`& 32\*(C'\fR: Input lines were changed on output.
\&\fB\s-1SC\s0\fR \f(CW\*(C`& 64\*(C'\fR: Input lines were changed to #error directives.
\&\fB\s-1SC\s0\fR \f(CW\*(C`& 128\*(C'\fR: Unconditional #error directives were output.
.IP "The system code reflects diagnostics that were provoked even if they were not actually output due to \fB\-\-gag\fR options." 4
.IX Item "The system code reflects diagnostics that were provoked even if they were not actually output due to --gag options."
.SH "BUGS"
.IX Header "BUGS"
The conditional operator \fB?...:...\fR is not parsed.
.PP
Trigraphs are not parsed.
.PP
\&\fB#define\fR and \fB#undef\fR directives that are found to be active are not factored into the evalation of subsequent \fB#if\fR directives.
.PP
Please report bugs to bugs dot sunifdef at strudl dot org
.SH "AUTHOR"
.IX Header "AUTHOR"
Mike Kinghan imk at strudl dot org
.SH "SEE ALSO"
.IX Header "SEE ALSO"
FreeBSD \fB\f(BIunifdef\fB\|(1)\fR