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