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
32 .\" @(#)unifdef.1 8.2 (Berkeley) 4/1/94
33 .\" $dotat: unifdef/unifdef.1,v 1.63 2010/02/19 16:41:15 fanf2 Exp $
40 .Nm unifdef , unifdefall
41 .Nd remove preprocessor conditionals from code
46 .Op Fl D Ns Ar sym Ns Op = Ns Ar val
48 .Op Fl iD Ns Ar sym Ns Op = Ns Ar val
60 utility selectively processes conditional
63 It removes from a file
65 and any additional text that they specify should be removed,
66 while otherwise leaving the file alone.
71 .Ic #if , #ifdef , #ifndef , #elif , #else ,
75 A directive is only processed
76 if the symbols specified on the command line are sufficient to allow
78 to get a definite value for its control expression.
79 If the result is false,
80 the directive and the following lines under its control are removed.
81 If the result is true,
82 only the directive is removed.
87 directive is passed through unchanged
88 if its controlling symbol is not specified on the command line.
93 control expression that has an unknown value or that
95 cannot parse is passed through unchanged.
102 lines with constant expressions;
103 it can be told to process them by specifying the
105 flag on the command line.
107 It understands a commonly-used subset
108 of the expression syntax for
114 integer values of symbols defined on the command line,
119 .Ic \&! , < , > , <= , >= , == , != , && , || ,
120 and parenthesized expressions.
123 evaluation is used for the
126 if either operand is definitely false then the result is false,
127 even if the value of the other operand is unknown.
131 is definitely true then the result is true.
135 utility does not distinguish between object-like macros
136 (without arguments) and function-like arguments (with arguments).
137 If a macro is not explicitly defined, or is defined with the
139 flag on the command-line, its arguments are ignored.
140 If a macro is explicitly undefined on the command line with the
142 flag, it may not have any arguments since this leads to a syntax error.
146 utility understands just enough about C
147 to know when one of the directives is inactive
150 or affected by a backslash-continued line.
151 It spots unusually-formatted preprocessor directives
152 and knows when the layout is too odd for it to handle.
156 can be used to remove all conditional
158 directives from a file.
163 to get lists of all the controlling symbols
164 and their definitions (or lack thereof),
167 with appropriate arguments to process the file.
170 .Bl -tag -width indent -compact
171 .It Fl D Ns Ar sym Ns = Ns Ar val
172 Specify that a symbol is defined to a given value
173 which is used when evaluating
180 Specify that a symbol is defined to the value 1.
183 Specify that a symbol is undefined.
184 If the same symbol appears in more than one argument,
185 the last occurrence dominates.
188 Compress blank lines around a deleted section.
189 Mutually exclusive with the
194 Replace removed lines with blank lines
195 instead of deleting them.
196 Mutually exclusive with the
204 then the operation of
207 i.e., the lines that would have been removed or blanked
208 are retained and vice versa.
211 Turn on printing of degugging messages.
216 processes its input one line at a time,
217 it cannot remove preprocessor directives that span more than one line.
218 The most common example of this is a directive with a multi-line
219 comment hanging off its right hand end.
223 has to process such a directive,
224 it will complain that the line is too obfuscated.
227 option changes the behaviour so that,
229 such lines are left unprocessed instead of reporting an error.
232 Always treat the result of
236 operators as unknown if either operand is unknown,
237 instead of short-circuiting when unknown operands can't affect the result.
238 This option is for compatibility with older versions of
246 lines with constant expressions.
247 By default, sections controlled by such lines are passed through unchanged
248 because they typically start
250 and are used as a kind of comment to sketch out future or past development.
251 It would be rude to strip them out, just as it would be for normal comments.
256 directives to the output following any deleted lines,
257 so that errors produced when compiling the output file correspond to
258 line numbers in the input file.
261 Write output to the file
263 instead of the standard output.
266 is the same as the input file,
267 the output is written to a temporary file
268 which is renamed into place when
270 completes successfully.
273 Instead of processing the input file as usual,
276 to produce a list of symbols that appear in expressions
280 It is useful in conjunction with the
289 Disables parsing for C comments
290 and line continuations,
294 .It Fl iD Ns Ar sym Ns Op = Ns Ar val
300 to delimit non-C lines,
302 or code which is under construction,
305 which symbols are used for that purpose so that it will not try to parse
307 and line continuations
310 You can specify ignored symbols with
311 .Fl iD Ns Ar sym Ns Oo = Ns Ar val Oc
315 .Fl D Ns Ar sym Ns Op = Ns Ar val
323 an additional place to look for
326 This option is ignored by
328 for compatibility with
330 and to simplify the implementation of
336 utility copies its output to
338 and will take its input from
346 utility works nicely with the
353 utility exits 0 if the output is an exact copy of the input,
354 1 if not, and 2 if in trouble.
358 Too many levels of nesting.
366 Obfuscated preprocessor control line.
370 (with the line number of the most recent unterminated
388 The original implementation was written by
389 .An Dave Yost Aq Dave@Yost.com .
390 .An Tony Finch Aq dot@dotat.at
391 rewrote it to support
394 Expression evaluation is very limited.
396 Preprocessor control lines split across more than one physical line
397 (because of comments or backslash-newline)
398 cannot be handled in every situation.
400 Trigraphs are not recognized.
402 There is no support for symbols with different definitions at
403 different points in the source file.
405 The text-mode and ignore functionality does not correspond to modern