first cut at new makefile; file reorg, new depend
[unix-history] / usr / src / usr.bin / unifdef / unifdef.1
CommitLineData
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
23unifdef \- 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
37from a file while otherwise leaving the file alone.
38\fIUnifdef\fR acts on
39#ifdef, #ifndef, #else, and #endif lines,
40and it knows only enough about C
41to know when one of these is inactive
42because it is inside
43a comment,
44or a single or double quote.
45Parsing for quotes is very simplistic:
46when it finds an open quote,
47it ignores everything (except escaped quotes)
48until it finds a close quote, and
49it will not complain if it gets
50to the end of a line and finds no backslash for continuation.
51.PP
52If you want to use \fIunifdef\fR
53for plain text (not C code),
54use the \fB\-t\fR option,
55which disables this parsing for
56C comments and quotes.
57.PP
6be9699a 58You specify which symbols you want defined
f42d2b57 59(\fB\-D\fR\fIsym\fR)
6be9699a 60or undefined
f42d2b57 61(\fB\-U\fR\fIsym\fR)
6be9699a
KM
62and the lines inside those ifdefs will be copied to the output or removed as
63appropriate.
64The ifdef, ifndef, else, and endif lines associated with
f42d2b57
KB
65\fIsym\fR will also be removed.
66Ifdefs involving symbols you don't specify
67and ``#if'' control lines
68are untouched and copied out
6be9699a
KM
69along with their associated
70ifdef, else, and endif lines.
71If an ifdef X occurs nested inside another ifdef X, then the
72inside ifdef is treated as if it were an unrecognized symbol.
f42d2b57
KB
73If the same symbol appears in more than one argument,
74the last occurrence dominates.
6be9699a 75.PP
f42d2b57 76The \fB\-l\fR option causes \fIunifdef\fR
6be9699a
KM
77to replace removed lines with blank lines
78instead of deleting them.
79.PP
f42d2b57
KB
80If your C code uses ifdefs to delimit non-C lines,
81such as comments
6be9699a 82or code which is under construction,
f42d2b57 83then you must tell \fIunifdef\fR
6be9699a
KM
84which symbols are used for that purpose so that it won't try to parse
85for quotes and comments
f42d2b57
KB
86inside those ifdefs.
87You specify ignored ifdefs with
88\fB\-iD\fR\fIsym\fR
6be9699a 89and
f42d2b57 90\fB\-iU\fR\fIsym\fR
6be9699a 91similar to
f42d2b57 92\fB\-D\fR\fIsym\fR
6be9699a 93and
f42d2b57 94\fB\-U\fR\fIsym\fR
6be9699a
KM
95above.
96.PP
f42d2b57
KB
97\fIUnifdef\fR copies its output to \fIstdout\fR
98and will take its input from \fIstdin\fR
99if no \fIfile\fR argument is given.
100If the \fB\-c\fR argument is specified,
101then the operation of \fIunifdef\fR is complemented,
6be9699a
KM
102i.e. the lines that would have been removed or blanked
103are retained and vice versa.
f42d2b57
KB
104.PP
105\fIUnifdef\fR works nicely with the \fB\-D\fR\fIsym\fR option added
106to \fIdiff\fR(1) as of the 4.1 Berkeley Software Distribution.
6be9699a
KM
107.SH "SEE ALSO"
108diff(1)
109.SH DIAGNOSTICS
f42d2b57
KB
110Inappropriate else or endif.
111.br
112Premature EOF with line numbers of the unterminated #ifdefs.
6be9699a
KM
113.PP
114Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
f42d2b57
KB
115.SH AUTHOR
116Dave Yost for The Rand Corporation.
117.br
118Still maintained independently by Dave Yost as of 3/85
6be9699a 119.SH BUGS
f42d2b57 120Should try to deal with ``#if'' lines.
6be9699a 121.br
f42d2b57 122Doesn't work correctly if input contains null characters.