date and time created 88/12/22 13:04:38 by sam
[unix-history] / usr / src / usr.bin / unifdef / unifdef.1
index f1ca391..32e46aa 100644 (file)
-.\" Copyright (c) 1985 Regents of the University of California.
-.\" All rights reserved.  The Berkeley software License Agreement
-.\" specifies the terms and conditions for redistribution.
+.\" Copyright (c) 1985 The Regents of the University of California.
+.\" All rights reserved.
 .\"
 .\"
-.\"    @(#)unifdef.1   6.1 (Berkeley) %G%
+.\" This code is derived from software contributed to Berkeley by
+.\" Dave Yost.
+.\"
+.\" Redistribution and use in source and binary forms are permitted
+.\" provided that the above copyright notice and this paragraph are
+.\" duplicated in all such forms and that any documentation,
+.\" advertising materials, and other materials related to such
+.\" distribution and use acknowledge that the software was developed
+.\" by the University of California, Berkeley.  The name of the
+.\" University may not be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
+.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+.\"
+.\"    @(#)unifdef.1   6.3 (Berkeley) %G%
 .\"
 .TH UNIFDEF 1 ""
 .\"
 .TH UNIFDEF 1 ""
-.UC 6
 .SH NAME
 unifdef \- remove ifdef'ed lines
 .SH SYNOPSIS
 .SH NAME
 unifdef \- remove ifdef'ed lines
 .SH SYNOPSIS
-.B unifdef
+\fBunifdef\fR
 [
 [
-.B \-t
-.B \-l
-.B \-c
-.BI \-D sym
-.BI \-U sym
-.BI \-id sym
-.BI \-iu sym
+\fB\-t\fR
+\fB\-l\fR
+\fB\-c\fR
+\fB\-D\fR\fIsym\fR 
+\fB\-U\fR\fIsym\fR 
+\fB\-iD\fR\fIsym\fR
+\fB\-iD\fR\fIsym\fR
 ] ...  [ file ]
 .SH DESCRIPTION
 ] ...  [ file ]
 .SH DESCRIPTION
-.I Unifdef
-is useful for removing ifdef'ed lines from a file while otherwise leaving the
-file alone.
-.I Unifdef
-is like a stripped-down C preprocessor:
-it is smart enough to deal with the nested ifdefs, comments,
-single and double
-quotes of C syntax so that it can do its job, but it doesn't do any including
-or interpretation of macros.
-Neither does it strip out comments, though it recognizes and ignores them.
+\fIUnifdef\fR is useful for removing ifdef'ed lines
+from a file while otherwise leaving the file alone.
+\fIUnifdef\fR acts on
+#ifdef, #ifndef, #else, and #endif lines,
+and it knows only enough about C
+to know when one of these is inactive
+because it is inside
+a comment,
+or a single or double quote.
+Parsing for quotes is very simplistic:
+when it finds an open quote,
+it ignores everything (except escaped quotes)
+until it finds a close quote, and
+it will not complain if it gets
+to the end of a line and finds no backslash for continuation.
+.PP
+If you want to use \fIunifdef\fR
+for plain text (not C code),
+use the \fB\-t\fR option,
+which disables this parsing for
+C comments and quotes.
+.PP
 You specify which symbols you want defined
 You specify which symbols you want defined
-.BI \-D sym
+(\fB\-D\fR\fIsym\fR)
 or undefined
 or undefined
-.BI \-U sym
+(\fB\-U\fR\fIsym\fR)
 and the lines inside those ifdefs will be copied to the output or removed as
 appropriate.
 The ifdef, ifndef, else, and endif lines associated with
 and the lines inside those ifdefs will be copied to the output or removed as
 appropriate.
 The ifdef, ifndef, else, and endif lines associated with
-.I sym
-will also be removed.
-Ifdefs involving symbols you don't specify are untouched and copied out
+\fIsym\fR will also be removed.
+Ifdefs involving symbols you don't specify
+and ``#if'' control lines
+are untouched and copied out
 along with their associated
 ifdef, else, and endif lines.
 If an ifdef X occurs nested inside another ifdef X, then the
 inside ifdef is treated as if it were an unrecognized symbol.
 along with their associated
 ifdef, else, and endif lines.
 If an ifdef X occurs nested inside another ifdef X, then the
 inside ifdef is treated as if it were an unrecognized symbol.
-If the same symbol appears in more than one argument, only the first
-occurrence is significant.
+If the same symbol appears in more than one argument,
+the last occurrence dominates.
 .PP
 .PP
-The
-.B \-l
-option causes
-.I unifdef
+The \fB\-l\fR option causes \fIunifdef\fR
 to replace removed lines with blank lines
 instead of deleting them.
 .PP
 to replace removed lines with blank lines
 instead of deleting them.
 .PP
-If you use ifdefs to delimit non-C lines, such as comments
+If your C code uses ifdefs to delimit non-C lines,
+such as comments
 or code which is under construction,
 or code which is under construction,
-then you must tell
-.I unifdef
+then you must tell \fIunifdef\fR
 which symbols are used for that purpose so that it won't try to parse
 for quotes and comments
 which symbols are used for that purpose so that it won't try to parse
 for quotes and comments
-in those ifdef'ed lines.
-You specify that you want the lines inside certain ifdefs to be ignored
-but copied out with
-.BI \-id sym
+inside those ifdefs.
+You specify ignored ifdefs with
+\fB\-iD\fR\fIsym\fR
 and
 and
-.BI \-iu sym
+\fB\-iU\fR\fIsym\fR
 similar to
 similar to
-.BI \-D sym
+\fB\-D\fR\fIsym\fR
 and
 and
-.BI \-U sym
+\fB\-U\fR\fIsym\fR
 above.
 .PP
 above.
 .PP
-If you want to use
-.I unifdef
-for plain text (not C code), use the
-.B \-t
-option.
-This makes
-.I unifdef
-refrain from attempting to recognize comments and single and double quotes.
-.PP
-.I Unifdef
-copies its output to
-.I stdout
-and will take its input from
-.I stdin
-if no
-.I file
-argument is given.
-If the
-.B \-c
-argument is specified, then the operation of
-.I unifdef
-is complemented,
+\fIUnifdef\fR copies its output to \fIstdout\fR
+and will take its input from \fIstdin\fR
+if no \fIfile\fR argument is given.
+If the \fB\-c\fR argument is specified,
+then the operation of \fIunifdef\fR is complemented,
 i.e. the lines that would have been removed or blanked
 are retained and vice versa.
 i.e. the lines that would have been removed or blanked
 are retained and vice versa.
+.PP
+\fIUnifdef\fR works nicely with the \fB\-D\fR\fIsym\fR option added
+to \fIdiff\fR(1) as of the 4.1 Berkeley Software Distribution.
 .SH "SEE ALSO"
 diff(1)
 .SH DIAGNOSTICS
 .SH "SEE ALSO"
 diff(1)
 .SH DIAGNOSTICS
-Premature EOF, inappropriate else or endif.
+Inappropriate else or endif.
+.br
+Premature EOF with line numbers of the unterminated #ifdefs.
 .PP
 Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
 .PP
 Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
+.SH AUTHOR
+Dave Yost for The Rand Corporation.
+.br
+Still maintained independently by Dave Yost as of 3/85
 .SH BUGS
 .SH BUGS
-Does not know how to deal with \fIcpp\fP consructs such as
+Should try to deal with ``#if'' lines.
 .br
 .br
-.sp
-.nf
-       #if     defined(X) || defined(Y)
-.sp
-.fi
-.SH AUTHOR
-Dave Yost
+Doesn't work correctly if input contains null characters.