Commit | Line | Data |
---|---|---|
dc533d04 KB |
1 | .\" Copyright (c) 1985 The Regents of the University of California. |
2 | .\" All rights reserved. | |
6be9699a | 3 | .\" |
dc533d04 KB |
4 | .\" This code is derived from software contributed to Berkeley by |
5 | .\" Dave Yost. | |
6 | .\" | |
0fc6e47b | 7 | .\" %sccs.include.redist.man% |
dc533d04 | 8 | .\" |
0fc6e47b | 9 | .\" @(#)unifdef.1 6.4 (Berkeley) %G% |
6be9699a KM |
10 | .\" |
11 | .TH UNIFDEF 1 "" | |
6be9699a KM |
12 | .SH NAME |
13 | unifdef \- remove ifdef'ed lines | |
14 | .SH SYNOPSIS | |
f42d2b57 | 15 | \fBunifdef\fR |
6be9699a | 16 | [ |
f42d2b57 KB |
17 | \fB\-t\fR |
18 | \fB\-l\fR | |
19 | \fB\-c\fR | |
20 | \fB\-D\fR\fIsym\fR | |
21 | \fB\-U\fR\fIsym\fR | |
22 | \fB\-iD\fR\fIsym\fR | |
23 | \fB\-iD\fR\fIsym\fR | |
6be9699a KM |
24 | ] ... [ file ] |
25 | .SH DESCRIPTION | |
f42d2b57 KB |
26 | \fIUnifdef\fR is useful for removing ifdef'ed lines |
27 | from a file while otherwise leaving the file alone. | |
28 | \fIUnifdef\fR acts on | |
29 | #ifdef, #ifndef, #else, and #endif lines, | |
30 | and it knows only enough about C | |
31 | to know when one of these is inactive | |
32 | because it is inside | |
33 | a comment, | |
34 | or a single or double quote. | |
35 | Parsing for quotes is very simplistic: | |
36 | when it finds an open quote, | |
37 | it ignores everything (except escaped quotes) | |
38 | until it finds a close quote, and | |
39 | it will not complain if it gets | |
40 | to the end of a line and finds no backslash for continuation. | |
41 | .PP | |
42 | If you want to use \fIunifdef\fR | |
43 | for plain text (not C code), | |
44 | use the \fB\-t\fR option, | |
45 | which disables this parsing for | |
46 | C comments and quotes. | |
47 | .PP | |
6be9699a | 48 | You specify which symbols you want defined |
f42d2b57 | 49 | (\fB\-D\fR\fIsym\fR) |
6be9699a | 50 | or undefined |
f42d2b57 | 51 | (\fB\-U\fR\fIsym\fR) |
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 | |
f42d2b57 KB |
55 | \fIsym\fR will also be removed. |
56 | Ifdefs involving symbols you don't specify | |
57 | and ``#if'' control lines | |
58 | are untouched and copied out | |
6be9699a KM |
59 | along with their associated |
60 | ifdef, else, and endif lines. | |
61 | If an ifdef X occurs nested inside another ifdef X, then the | |
62 | inside ifdef is treated as if it were an unrecognized symbol. | |
f42d2b57 KB |
63 | If the same symbol appears in more than one argument, |
64 | the last occurrence dominates. | |
6be9699a | 65 | .PP |
f42d2b57 | 66 | The \fB\-l\fR option causes \fIunifdef\fR |
6be9699a KM |
67 | to replace removed lines with blank lines |
68 | instead of deleting them. | |
69 | .PP | |
f42d2b57 KB |
70 | If your C code uses ifdefs to delimit non-C lines, |
71 | such as comments | |
6be9699a | 72 | or code which is under construction, |
f42d2b57 | 73 | then you must tell \fIunifdef\fR |
6be9699a KM |
74 | which symbols are used for that purpose so that it won't try to parse |
75 | for quotes and comments | |
f42d2b57 KB |
76 | inside those ifdefs. |
77 | You specify ignored ifdefs with | |
78 | \fB\-iD\fR\fIsym\fR | |
6be9699a | 79 | and |
f42d2b57 | 80 | \fB\-iU\fR\fIsym\fR |
6be9699a | 81 | similar to |
f42d2b57 | 82 | \fB\-D\fR\fIsym\fR |
6be9699a | 83 | and |
f42d2b57 | 84 | \fB\-U\fR\fIsym\fR |
6be9699a KM |
85 | above. |
86 | .PP | |
f42d2b57 KB |
87 | \fIUnifdef\fR copies its output to \fIstdout\fR |
88 | and will take its input from \fIstdin\fR | |
89 | if no \fIfile\fR argument is given. | |
90 | If the \fB\-c\fR argument is specified, | |
91 | then the operation of \fIunifdef\fR is complemented, | |
6be9699a KM |
92 | i.e. the lines that would have been removed or blanked |
93 | are retained and vice versa. | |
f42d2b57 KB |
94 | .PP |
95 | \fIUnifdef\fR works nicely with the \fB\-D\fR\fIsym\fR option added | |
96 | to \fIdiff\fR(1) as of the 4.1 Berkeley Software Distribution. | |
6be9699a KM |
97 | .SH "SEE ALSO" |
98 | diff(1) | |
99 | .SH DIAGNOSTICS | |
f42d2b57 KB |
100 | Inappropriate else or endif. |
101 | .br | |
102 | Premature EOF with line numbers of the unterminated #ifdefs. | |
6be9699a KM |
103 | .PP |
104 | Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble. | |
f42d2b57 KB |
105 | .SH AUTHOR |
106 | Dave Yost for The Rand Corporation. | |
107 | .br | |
108 | Still maintained independently by Dave Yost as of 3/85 | |
6be9699a | 109 | .SH BUGS |
f42d2b57 | 110 | Should try to deal with ``#if'' lines. |
6be9699a | 111 | .br |
f42d2b57 | 112 | Doesn't work correctly if input contains null characters. |