1 .\" Copyright (c) 1985, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
3 .\" Copyright (c) 2002 - 2005 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: things/unifdef.1,v 1.51 2005/03/08 12:39:01 fanf2 Exp $
36 .Dd September 24, 2002
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
59 utility selectively processes conditional
62 It removes from a file
64 and any additional text that they specify should be removed,
65 while otherwise leaving the file alone.
70 .Ic #if , #ifdef , #ifndef , #elif , #else ,
74 and it understands only the commonly-used subset
75 of the expression syntax for
81 integer values of symbols defined on the command line,
84 operator applied to symbols defined or undefined on the command line,
86 .Ic \&! , < , > , <= , >= , == , != , && , || ,
87 and parenthesized expressions.
88 Anything that it does not understand is passed through unharmed.
93 directives if the symbol is specified on the command line,
94 otherwise they are also passed through unchanged.
95 By default, it ignores
99 lines with constant expressions,
100 or they may be processed by specifying the
102 flag on the command line.
106 utility also understands just enough about C
107 to know when one of the directives is inactive
110 or affected by a backslash-continued line.
111 It spots unusually-formatted preprocessor directives
112 and knows when the layout is too odd to handle.
116 can be used to remove all conditional
118 directives from a file.
123 to get lists of all the controlling symbols
124 and their definitions (or lack thereof),
127 with appropriate arguments to process the file.
131 .Bl -tag -width indent -compact
132 .It Fl D Ns Ar sym Ns Op = Ns Ar val
133 Specify that a symbol is defined,
134 and optionally specify what value to give it
135 for the purpose of handling
142 Specify that a symbol is undefined.
143 If the same symbol appears in more than one argument,
144 the last occurrence dominates.
150 then the operation of
153 i.e., the lines that would have been removed or blanked
154 are retained and vice versa.
157 Turn on printing of degugging messages.
162 processes its input one line at a time,
163 it cannot remove preprocessor directives that span more than one line.
164 The most common example of this is a directive with a multi-line
165 comment hanging off its right hand end.
169 has to process such a directive,
170 it will complain that the line is too obfuscated.
173 option changes the behaviour so that,
175 such lines are left unprocessed instead of reporting an error.
182 lines with constant expressions.
183 By default, sections controlled by such lines are passed through unchanged
184 because they typically start
186 and are used as a kind of comment to sketch out future or past development.
187 It would be rude to strip them out, just as it would be for normal comments.
190 Replace removed lines with blank lines
191 instead of deleting them.
196 directives to the output following any deleted lines,
197 so that errors produced when compiling the output file correspond to
198 line numbers in the input file.
201 Instead of processing the input file as usual,
204 to produce a list of symbols that appear in expressions
208 It is useful in conjunction with the
217 Disables parsing for C comments
218 and line continuations,
222 .It Fl iD Ns Ar sym Ns Op = Ns Ar val
228 to delimit non-C lines,
230 or code which is under construction,
233 which symbols are used for that purpose so that it will not try to parse
235 and line continuations
238 One specifies ignored symbols with
239 .Fl iD Ns Ar sym Ns Oo = Ns Ar val Oc
243 .Fl D Ns Ar sym Ns Op = Ns Ar val
251 an additional place to look for
254 This option is ignored by
256 for compatibility with
258 and to simplify the implementation of
264 utility copies its output to
266 and will take its input from
274 utility works nicely with the
281 utility exits 0 if the output is an exact copy of the input,
282 1 if not, and 2 if in trouble.
286 Too many levels of nesting.
294 Obfuscated preprocessor control line.
298 (with the line number of the most recent unterminated
316 This implementation was originally written by
317 .An Dave Yost Aq Dave@Yost.com .
318 .An Tony Finch Aq dot@dotat.at
319 rewrote it to support
322 Expression evaluation is very limited.
324 Preprocessor control lines split across more than one physical line
325 (because of comments or backslash-newline)
326 cannot be handled in every situation.
328 Trigraphs are not recognized.
330 There is no support for symbols with different definitions at
331 different points in the source file.
333 The text-mode and ignore functionality does not correspond to modern