1 .\" Copyright (c) 1985, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Dave Yost. Support for #if and #elif was added by Tony Finch.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed by the University of
18 .\" California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\" may be used to endorse or promote products derived from this software
21 .\" without specific prior written permission.
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" @(#)unifdef.1 8.2 (Berkeley) 4/1/94
36 .\" $dotat: things/unifdef.1,v 1.43 2003/01/20 11:36:12 fanf2 Exp $
37 .\" $FreeBSD: src/usr.bin/unifdef/unifdef.1,v 1.4.2.9 2003/01/29 21:46:39 fanf Exp $
39 .Dd September 24, 2002
43 .Nm unifdef , unifdefall
44 .Nd remove preprocessor conditionals from code
50 .Fl D Ns Ar sym Ns Op = Ns Ar val
52 .Fl iD Ns Ar sym Ns Op = Ns Ar val
64 utility selectively processes conditional
67 It removes from a file
69 and any additional text that they specify should be removed,
70 while otherwise leaving the file alone.
75 .Ic #if , #ifdef , #ifndef , #elif , #else ,
79 and it understands only the commonly-used subset
80 of the expression syntax for
86 integer values of symbols defined on the command line,
89 operator applied to symbols defined or undefined on the command line,
91 .Ic \&! , < , > , <= , >= , == , != , && , || ,
92 and parenthesized expressions.
93 Anything that it does not understand is passed through unharmed.
98 directives if the symbol is specified on the command line,
99 otherwise they are also passed through unchanged.
100 By default, it ignores
104 lines with constant expressions,
105 or they may be processed by specifying the
107 flag on the command line.
111 utility also understands just enough about C
112 to know when one of the directives is inactive
115 or affected by a backslash-continued line.
116 It spots unusually-formatted preprocessor directives
117 and knows when the layout is too odd to handle.
121 can be used to remove all conditional
123 directives from a file.
128 to get lists of all the controlling symbols
129 and their definitions (or lack thereof),
132 with appropriate arguments to process the file.
135 .Bl -tag -width indent -compact
136 .It Fl D Ns Ar sym Ns Op = Ns Ar val
137 Specify that a symbol is defined,
138 and optionally specify what value to give it
139 for the purpose of handling
146 Specify that a symbol is undefined.
147 If the same symbol appears in more than one argument,
148 the last occurrence dominates.
154 then the operation of
157 i.e., the lines that would have been removed or blanked
158 are retained and vice versa.
163 processes its input one line at a time,
164 it cannot remove preprocessor directives that span more than one line.
165 The most common example of this is a directive with a multi-line
166 comment hanging off its right hand end.
170 has to process such a directive,
171 it will complain that the line is too obfuscated.
174 option changes the behaviour so that,
176 such lines are left unprocessed instead of reporting an error.
183 lines with constant expressions.
184 By default, sections controlled by such lines are passed through unchanged
185 because they typically start
187 and are used as a kind of comment to sketch out future or past development.
188 It would be rude to strip them out, just as it would be for normal comments.
191 Replace removed lines with blank lines
192 instead of deleting them.
195 Instead of processing the input file as usual,
198 to produce a list of symbols that appear in expressions
202 It is useful in conjunction with the
211 Disables parsing for C comments
212 and line continuations,
216 .It Fl iD Ns Ar sym Ns Op = Ns Ar val
222 to delimit non-C lines,
224 or code which is under construction,
227 which symbols are used for that purpose so that it will not try to parse
229 and line continuations
232 One specifies ignored symbols with
233 .Fl iD Ns Ar sym Ns Oo = Ns Ar val Oc
237 .Fl D Ns Ar sym Ns Op = Ns Ar val
245 an additional place to look for
248 This option is ignored by
250 for compatibility with
252 and to simplify the implementation of
258 utility copies its output to
260 and will take its input from
268 utility works nicely with the
278 Too many levels of nesting.
286 Obfuscated preprocessor control line.
290 (with the line number of the most recent unterminated
299 utility exits 0 if the output is an exact copy of the input,
300 1 if not, and 2 if in trouble.
302 Expression evaluation is very limited.
304 Preprocessor control lines split across more than one physical line
305 (because of comments or backslash-newline)
306 cannot be handled in every situation.
308 Trigraphs are not recognized.
310 There is no support for symbols with different definitions at
311 different points in the source file.
313 The text-mode and ignore functionality does not correspond to modern