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