Annotation of src/usr.bin/unifdef/unifdef.1, Revision 1.6
1.6 ! aaron 1: .\" $OpenBSD: unifdef.1,v 1.5 1999/10/17 20:24:33 aaron Exp $
1.1 deraadt 2: .\" $NetBSD: unifdef.1,v 1.4 1994/12/07 00:33:48 jtc Exp $
3: .\"
4: .\" Copyright (c) 1985, 1991, 1993
5: .\" The Regents of the University of California. All rights reserved.
6: .\"
7: .\" This code is derived from software contributed to Berkeley by
8: .\" Dave Yost.
9: .\"
10: .\" Redistribution and use in source and binary forms, with or without
11: .\" modification, are permitted provided that the following conditions
12: .\" are met:
13: .\" 1. Redistributions of source code must retain the above copyright
14: .\" notice, this list of conditions and the following disclaimer.
15: .\" 2. Redistributions in binary form must reproduce the above copyright
16: .\" notice, this list of conditions and the following disclaimer in the
17: .\" documentation and/or other materials provided with the distribution.
18: .\" 3. All advertising materials mentioning features or use of this software
19: .\" must display the following acknowledgement:
20: .\" This product includes software developed by the University of
21: .\" California, Berkeley and its contributors.
22: .\" 4. Neither the name of the University nor the names of its contributors
23: .\" may be used to endorse or promote products derived from this software
24: .\" without specific prior written permission.
25: .\"
26: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36: .\" SUCH DAMAGE.
37: .\"
38: .\" @(#)unifdef.1 8.2 (Berkeley) 4/1/94
39: .\"
40: .Dd April 1, 1994
41: .Dt UNIFDEF 1
1.4 aaron 42: .Os
1.1 deraadt 43: .Sh NAME
44: .Nm unifdef
45: .Nd remove ifdef'ed lines
46: .Sh SYNOPSIS
47: .Nm unifdef
48: .Op Fl clt
49: .Oo
50: .Fl D Ns Ar sym
51: .Fl U Ns Ar sym
52: .Fl iD Ns Ar sym
53: .Fl iD Ns Ar sym
54: .Oc
55: .Ar ...
56: .Op Ar file
57: .Sh DESCRIPTION
1.3 aaron 58: .Nm unifdef
1.1 deraadt 59: is useful for removing ifdef'ed lines
60: from a file while otherwise leaving the file alone.
1.3 aaron 61: .Nm unifdef
1.1 deraadt 62: acts on
63: #ifdef, #ifndef, #else, and #endif lines,
64: and it knows only enough about C
65: to know when one of these is inactive
66: because it is inside
67: a comment,
68: or a single or double quote.
69: Parsing for quotes is very simplistic:
70: when it finds an open quote,
71: it ignores everything (except escaped quotes)
72: until it finds a close quote, and
73: it will not complain if it gets
74: to the end of a line and finds no backslash for continuation.
75: .Pp
1.5 aaron 76: The options are as follows:
1.1 deraadt 77: .Bl -tag -width Ds -compact
78: .It Fl D Ns Ar sym
79: .It Fl U Ns Ar sym
1.3 aaron 80: Specify which symbols to define or undefine,
1.1 deraadt 81: and the lines inside those ifdefs will be copied to the output or removed as
82: appropriate.
83: The ifdef, ifndef, else, and endif lines associated with
84: .Ar sym
85: will also be removed.
1.3 aaron 86: ifdefs involving symbols you don't specify
1.1 deraadt 87: and ``#if'' control lines
88: are untouched and copied out
89: along with their associated
90: ifdef, else, and endif lines.
91: If an ifdef X occurs nested inside another ifdef X, then the
92: inside ifdef is treated as if it were an unrecognized symbol.
93: If the same symbol appears in more than one argument,
94: the last occurrence dominates.
95: .Pp
96: .It Fl c
97: If the
98: .Fl c
99: flag is specified,
100: then the operation of
101: .Nm unifdef
102: is complemented,
103: i.e. the lines that would have been removed or blanked
104: are retained and vice versa.
105: .Pp
106: .It Fl l
107: Replace removed lines with blank lines
108: instead of deleting them.
1.3 aaron 109: .Pp
1.1 deraadt 110: .It Fl t
111: Disables parsing for C comments and quotes, which is useful
112: for plain text.
113: .Pp
114: .It Fl iD Ns Ar sym
115: .It Fl iU Ns Ar sym
116: Ignore ifdefs.
117: If your C code uses ifdefs to delimit non-C lines,
118: such as comments
119: or code which is under construction,
120: then you must tell
121: .Nm unifdef
122: which symbols are used for that purpose so that it won't try to parse
123: for quotes and comments
124: inside those ifdefs.
125: One specifies ignored ifdefs with
126: .Fl iD Ns Ar sym
127: and
128: .Fl iU Ns Ar sym
129: similar to
130: .Fl D Ns Ar sym
131: and
132: .Fl U Ns Ar sym
133: above.
134: .El
135: .Pp
1.3 aaron 136: .Nm unifdef
1.1 deraadt 137: copies its output to
138: .Em stdout
139: and will take its input from
140: .Em stdin
141: if no
142: .Ar file
143: argument is given.
144: .Pp
1.3 aaron 145: .Nm unifdef
1.1 deraadt 146: works nicely with the
147: .Fl D Ns Ar sym
148: option added to
149: .Xr diff 1
150: as of the 4.1 Berkeley Software Distribution.
151: .Sh SEE ALSO
152: .Xr diff 1
153: .Sh DIAGNOSTICS
154: Inappropriate else or endif.
155: .br
156: Premature
157: .Tn EOF
158: with line numbers of the unterminated #ifdefs.
159: .Pp
160: Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
161: .Sh BUGS
162: Should try to deal with ``#if'' lines.
163: .Pp
164: Doesn't work correctly if input contains null characters.
165: .Sh HISTORY
166: The
167: .Nm
168: command appeared in
169: .Bx 4.3 .