1 .\" Copyright (c) 1985, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
3 .\" Copyright (c) 2002 - 2010 Tony Finch <dot@dotat.at>. All rights reserved.
5 .\" This code is derived from software contributed to Berkeley by
6 .\" Dave Yost. It was rewritten to support ANSI C by Tony Finch.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 .Nm unifdef , unifdefall
39 .Nd remove preprocessor conditionals from code
44 .Op Fl D Ns Ar sym Ns Op = Ns Ar val
46 .Op Fl iD Ns Ar sym Ns Op = Ns Ar val
58 utility selectively processes conditional
61 It removes from a file
63 and any additional text that they specify should be removed,
64 while otherwise leaving the file alone.
69 .Ic #if , #ifdef , #ifndef , #elif , #else ,
73 A directive is only processed
74 if the symbols specified on the command line are sufficient to allow
76 to get a definite value for its control expression.
77 If the result is false,
78 the directive and the following lines under its control are removed.
79 If the result is true,
80 only the directive is removed.
85 directive is passed through unchanged
86 if its controlling symbol is not specified on the command line.
91 control expression that has an unknown value or that
93 cannot parse is passed through unchanged.
100 lines with constant expressions;
101 it can be told to process them by specifying the
103 flag on the command line.
105 It understands a commonly-used subset
106 of the expression syntax for
112 integer values of symbols defined on the command line,
117 .Ic \&! , < , > , <= , >= , == , != , && , || ,
118 and parenthesized expressions.
121 evaluation is used for the
124 if either operand is definitely false then the result is false,
125 even if the value of the other operand is unknown.
129 is definitely true then the result is true.
133 utility does not distinguish between object-like macros
134 (without arguments) and function-like arguments (with arguments).
135 If a macro is not explicitly defined, or is defined with the
137 flag on the command-line, its arguments are ignored.
138 If a macro is explicitly undefined on the command line with the
140 flag, it may not have any arguments since this leads to a syntax error.
144 utility understands just enough about C
145 to know when one of the directives is inactive
148 or affected by a backslash-continued line.
149 It spots unusually-formatted preprocessor directives
150 and knows when the layout is too odd for it to handle.
154 can be used to remove all conditional
156 directives from a file.
161 to get lists of all the controlling symbols
162 and their definitions (or lack thereof),
165 with appropriate arguments to process the file.
167 .Bl -tag -width indent -compact
168 .It Fl D Ns Ar sym Ns = Ns Ar val
169 Specify that a symbol is defined to a given value
170 which is used when evaluating
177 Specify that a symbol is defined to the value 1.
180 Specify that a symbol is undefined.
181 If the same symbol appears in more than one argument,
182 the last occurrence dominates.
185 Replace removed lines with blank lines
186 instead of deleting them.
187 Mutually exclusive with the
192 Compress blank lines around a deleted section.
193 Mutually exclusive with the
201 then the operation of
204 i.e., the lines that would have been removed or blanked
205 are retained and vice versa.
208 Turn on printing of debugging messages.
213 processes its input one line at a time,
214 it cannot remove preprocessor directives that span more than one line.
215 The most common example of this is a directive with a multi-line
216 comment hanging off its right hand end.
220 has to process such a directive,
221 it will complain that the line is too obfuscated.
224 option changes the behaviour so that,
226 such lines are left unprocessed instead of reporting an error.
229 Always treat the result of
233 operators as unknown if either operand is unknown,
234 instead of short-circuiting when unknown operands can't affect the result.
235 This option is for compatibility with older versions of
243 lines with constant expressions.
244 By default, sections controlled by such lines are passed through unchanged
245 because they typically start
247 and are used as a kind of comment to sketch out future or past development.
248 It would be rude to strip them out, just as it would be for normal comments.
253 directives to the output following any deleted lines,
254 so that errors produced when compiling the output file correspond to
255 line numbers in the input file.
258 Write output to the file
260 instead of the standard output.
263 is the same as the input file,
264 the output is written to a temporary file
265 which is renamed into place when
267 completes successfully.
270 Instead of processing the input file as usual,
273 to produce a list of symbols that appear in expressions
277 It is useful in conjunction with the
288 option, but the nesting depth of each symbol is also printed.
289 This is useful for working out the number of possible combinations
290 of interdependent defined/undefined symbols.
293 Disables parsing for C comments
294 and line continuations,
298 .It Fl iD Ns Ar sym Ns Op = Ns Ar val
304 to delimit non-C lines,
306 or code which is under construction,
309 which symbols are used for that purpose so that it will not try to parse
311 and line continuations
314 You can specify ignored symbols with
315 .Fl iD Ns Ar sym Ns Oo = Ns Ar val Oc
319 .Fl D Ns Ar sym Ns Op = Ns Ar val
327 an additional place to look for
330 This option is ignored by
332 for compatibility with
334 and to simplify the implementation of
338 Print version details.
343 utility copies its output to
345 and will take its input from
353 utility works nicely with the
360 utility exits 0 if the output is an exact copy of the input,
361 1 if not, and 2 if in trouble.
365 Too many levels of nesting.
373 Obfuscated preprocessor control line.
377 (with the line number of the most recent unterminated
395 The original implementation was written by
396 .An Dave Yost Aq Dave@Yost.com .
397 .An Tony Finch Aq dot@dotat.at
398 rewrote it to support
401 Expression evaluation is very limited.
403 Preprocessor control lines split across more than one physical line
404 (because of comments or backslash-newline)
405 cannot be handled in every situation.
407 Trigraphs are not recognized.
409 There is no support for symbols with different definitions at
410 different points in the source file.
412 The text-mode and ignore functionality does not correspond to modern