xref: /original-bsd/usr.bin/unifdef/unifdef.1 (revision c3e32dec)
1.\" Copyright (c) 1985, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Dave Yost.
6.\"
7.\" %sccs.include.redist.roff%
8.\"
9.\"     @(#)unifdef.1	8.1 (Berkeley) 06/06/93
10.\"
11.Dd
12.Dt UNIFDEF 1
13.Os BSD 4.3
14.Sh NAME
15.Nm unifdef
16.Nd remove ifdef'ed lines
17.Sh SYNOPSIS
18.Nm unifdef
19.Oo
20.Fl t l c
21.Fl D Ns Ar sym
22.Fl U Ns Ar sym
23.Fl iD Ns Ar sym
24.Fl iD Ns Ar sym
25.Oc
26.Ar ...
27.Op Ar file
28.Sh DESCRIPTION
29.Nm Unifdef
30is useful for removing ifdef'ed lines
31from a file while otherwise leaving the file alone.
32.Nm Unifdef
33acts on
34#ifdef, #ifndef, #else, and #endif lines,
35and it knows only enough about C
36to know when one of these is inactive
37because it is inside
38a comment,
39or a single or double quote.
40Parsing for quotes is very simplistic:
41when it finds an open quote,
42it ignores everything (except escaped quotes)
43until it finds a close quote, and
44it will not complain if it gets
45to the end of a line and finds no backslash for continuation.
46.Pp
47Available options:
48.Bl -tag -width Ds -compact
49.It Fl D Ns Ar sym
50.It Fl U Ns Ar sym
51Specify which symbols to define or undefine.
52and the lines inside those ifdefs will be copied to the output or removed as
53appropriate.
54The ifdef, ifndef, else, and endif lines associated with
55.Ar sym
56will also be removed.
57Ifdefs involving symbols you don't specify
58and ``#if'' control lines
59are untouched and copied out
60along with their associated
61ifdef, else, and endif lines.
62If an ifdef X occurs nested inside another ifdef X, then the
63inside ifdef is treated as if it were an unrecognized symbol.
64If the same symbol appears in more than one argument,
65the last occurrence dominates.
66.Pp
67.It Fl c
68If the
69.Fl c
70flag is specified,
71then the operation of
72.Nm unifdef
73is complemented,
74i.e. the lines that would have been removed or blanked
75are retained and vice versa.
76.Pp
77.It Fl l
78Replace removed lines with blank lines
79instead of deleting them.
80.It Fl t
81Disables parsing for
82C comments and quotes useful for plain text
83(not C code).
84.Pp
85.It Fl iD Ns Ar sym
86.It Fl iU Ns Ar sym
87Ignore ifdefs.
88If your C code uses ifdefs to delimit non-C lines,
89such as comments
90or code which is under construction,
91then you must tell
92.Nm unifdef
93which symbols are used for that purpose so that it won't try to parse
94for quotes and comments
95inside those ifdefs.
96One specifies ignored ifdefs with
97.Fl iD Ns Ar sym
98and
99.Fl iU Ns Ar sym
100similar to
101.Fl D Ns Ar sym
102and
103.Fl U Ns Ar sym
104above.
105.El
106.Pp
107.Nm Unifdef
108copies its output to
109.Em stdout
110and will take its input from
111.Em stdin
112if no
113.Ar file
114argument is given.
115.Pp
116.Nm Unifdef
117works nicely with the
118.Fl D Ns Ar sym
119option added to
120.Xr diff 1
121as of the 4.1 Berkeley Software Distribution.
122.Sh SEE ALSO
123.Xr diff 1
124.Sh DIAGNOSTICS
125Inappropriate else or endif.
126.br
127Premature
128.Tn EOF
129with line numbers of the unterminated #ifdefs.
130.Pp
131Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
132.Sh BUGS
133Should try to deal with ``#if'' lines.
134.Pp
135Doesn't work correctly if input contains null characters.
136.Sh HISTORY
137The
138.Nm
139command appeared in
140.Bx 4.3 .
141