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 $
34 .\" $DragonFly: src/usr.bin/unifdef/unifdef.1,v 1.5 2007/05/17 08:19:02 swildner Exp $
35 .\" $FreeBSD: src/usr.bin/unifdef/unifdef.1,v 1.24 2005/05/21 09:55:09 ru Exp $
37 .Dd September 24, 2002
43 .Nd remove preprocessor conditionals from code
48 .Op Fl D Ns Ar sym Ns Op = Ns Ar val
50 .Op Fl iD Ns Ar sym Ns Op = Ns Ar val
61 utility selectively processes conditional
64 It removes from a file
66 and any additional text that they specify should be removed,
67 while otherwise leaving the file alone.
72 .Ic #if , #ifdef , #ifndef , #elif , #else ,
76 and it understands only the commonly-used subset
77 of the expression syntax for
83 integer values of symbols defined on the command line,
86 operator applied to symbols defined or undefined on the command line,
88 .Ic \&! , < , > , <= , >= , == , != , && , || ,
89 and parenthesized expressions.
90 Anything that it does not understand is passed through unharmed.
95 directives if the symbol is specified on the command line,
96 otherwise they are also passed through unchanged.
97 By default, it ignores
101 lines with constant expressions,
102 or they may be processed by specifying the
104 flag on the command line.
108 utility also understands just enough about C
109 to know when one of the directives is inactive
112 or affected by a backslash-continued line.
113 It spots unusually-formatted preprocessor directives
114 and knows when the layout is too odd to handle.
118 can be used to remove all conditional
120 directives from a file.
125 to get lists of all the controlling symbols
126 and their definitions (or lack thereof),
129 with appropriate arguments to process the file.
133 .Bl -tag -width indent -compact
134 .It Fl D Ns Ar sym Ns Op = Ns Ar val
135 Specify that a symbol is defined,
136 and optionally specify what value to give it
137 for the purpose of handling
144 Specify that a symbol is undefined.
145 If the same symbol appears in more than one argument,
146 the last occurrence dominates.
152 then the operation of
155 i.e., the lines that would have been removed or blanked
156 are retained and vice versa.
159 Turn on printing of debugging messages.
164 processes its input one line at a time,
165 it cannot remove preprocessor directives that span more than one line.
166 The most common example of this is a directive with a multi-line
167 comment hanging off its right hand end.
171 has to process such a directive,
172 it will complain that the line is too obfuscated.
175 option changes the behaviour so that,
177 such lines are left unprocessed instead of reporting an error.
184 lines with constant expressions.
185 By default, sections controlled by such lines are passed through unchanged
186 because they typically start
188 and are used as a kind of comment to sketch out future or past development.
189 It would be rude to strip them out, just as it would be for normal comments.
192 Replace removed lines with blank lines
193 instead of deleting them.
198 directives to the output following any deleted lines,
199 so that errors produced when compiling the output file correspond to
200 line numbers in the input file.
203 Instead of processing the input file as usual,
206 to produce a list of symbols that appear in expressions
210 It is useful in conjunction with the
219 Disables parsing for C comments
220 and line continuations,
224 .It Fl iD Ns Ar sym Ns Op = Ns Ar val
230 to delimit non-C lines,
232 or code which is under construction,
235 which symbols are used for that purpose so that it will not try to parse
237 and line continuations
240 One specifies ignored symbols with
241 .Fl iD Ns Ar sym Ns Oo = Ns Ar val Oc
245 .Fl D Ns Ar sym Ns Op = Ns Ar val
253 an additional place to look for
256 This option is ignored by
258 for compatibility with
260 and to simplify the implementation of
266 utility copies its output to
268 and will take its input from
276 utility works nicely with the
283 utility exits 0 if the output is an exact copy of the input,
284 1 if not, and 2 if in trouble.
288 Too many levels of nesting.
296 Obfuscated preprocessor control line.
300 (with the line number of the most recent unterminated
318 Expression evaluation is very limited.
320 Preprocessor control lines split across more than one physical line
321 (because of comments or backslash-newline)
322 cannot be handled in every situation.
324 Trigraphs are not recognized.
326 There is no support for symbols with different definitions at
327 different points in the source file.
329 The text-mode and ignore functionality does not correspond to modern