Annotation of src/usr.bin/unifdef/unifdef.1, Revision 1.1
1.1 ! deraadt 1: .\" $NetBSD: unifdef.1,v 1.4 1994/12/07 00:33:48 jtc Exp $
! 2: .\"
! 3: .\" Copyright (c) 1985, 1991, 1993
! 4: .\" The Regents of the University of California. All rights reserved.
! 5: .\"
! 6: .\" This code is derived from software contributed to Berkeley by
! 7: .\" Dave Yost.
! 8: .\"
! 9: .\" Redistribution and use in source and binary forms, with or without
! 10: .\" modification, are permitted provided that the following conditions
! 11: .\" are met:
! 12: .\" 1. Redistributions of source code must retain the above copyright
! 13: .\" notice, this list of conditions and the following disclaimer.
! 14: .\" 2. Redistributions in binary form must reproduce the above copyright
! 15: .\" notice, this list of conditions and the following disclaimer in the
! 16: .\" documentation and/or other materials provided with the distribution.
! 17: .\" 3. All advertising materials mentioning features or use of this software
! 18: .\" must display the following acknowledgement:
! 19: .\" This product includes software developed by the University of
! 20: .\" California, Berkeley and its contributors.
! 21: .\" 4. Neither the name of the University nor the names of its contributors
! 22: .\" may be used to endorse or promote products derived from this software
! 23: .\" without specific prior written permission.
! 24: .\"
! 25: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 26: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 27: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 28: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 29: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 30: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 31: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 32: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 33: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 34: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 35: .\" SUCH DAMAGE.
! 36: .\"
! 37: .\" @(#)unifdef.1 8.2 (Berkeley) 4/1/94
! 38: .\"
! 39: .Dd April 1, 1994
! 40: .Dt UNIFDEF 1
! 41: .Os BSD 4.3
! 42: .Sh NAME
! 43: .Nm unifdef
! 44: .Nd remove ifdef'ed lines
! 45: .Sh SYNOPSIS
! 46: .Nm unifdef
! 47: .Op Fl clt
! 48: .Oo
! 49: .Fl D Ns Ar sym
! 50: .Fl U Ns Ar sym
! 51: .Fl iD Ns Ar sym
! 52: .Fl iD Ns Ar sym
! 53: .Oc
! 54: .Ar ...
! 55: .Op Ar file
! 56: .Sh DESCRIPTION
! 57: .Nm Unifdef
! 58: is useful for removing ifdef'ed lines
! 59: from a file while otherwise leaving the file alone.
! 60: .Nm Unifdef
! 61: acts on
! 62: #ifdef, #ifndef, #else, and #endif lines,
! 63: and it knows only enough about C
! 64: to know when one of these is inactive
! 65: because it is inside
! 66: a comment,
! 67: or a single or double quote.
! 68: Parsing for quotes is very simplistic:
! 69: when it finds an open quote,
! 70: it ignores everything (except escaped quotes)
! 71: until it finds a close quote, and
! 72: it will not complain if it gets
! 73: to the end of a line and finds no backslash for continuation.
! 74: .Pp
! 75: Available options:
! 76: .Bl -tag -width Ds -compact
! 77: .It Fl D Ns Ar sym
! 78: .It Fl U Ns Ar sym
! 79: Specify which symbols to define or undefine.
! 80: and the lines inside those ifdefs will be copied to the output or removed as
! 81: appropriate.
! 82: The ifdef, ifndef, else, and endif lines associated with
! 83: .Ar sym
! 84: will also be removed.
! 85: Ifdefs involving symbols you don't specify
! 86: and ``#if'' control lines
! 87: are untouched and copied out
! 88: along with their associated
! 89: ifdef, else, and endif lines.
! 90: If an ifdef X occurs nested inside another ifdef X, then the
! 91: inside ifdef is treated as if it were an unrecognized symbol.
! 92: If the same symbol appears in more than one argument,
! 93: the last occurrence dominates.
! 94: .Pp
! 95: .It Fl c
! 96: If the
! 97: .Fl c
! 98: flag is specified,
! 99: then the operation of
! 100: .Nm unifdef
! 101: is complemented,
! 102: i.e. the lines that would have been removed or blanked
! 103: are retained and vice versa.
! 104: .Pp
! 105: .It Fl l
! 106: Replace removed lines with blank lines
! 107: instead of deleting them.
! 108: .It Fl t
! 109: Disables parsing for C comments and quotes, which is useful
! 110: for plain text.
! 111: .Pp
! 112: .It Fl iD Ns Ar sym
! 113: .It Fl iU Ns Ar sym
! 114: Ignore ifdefs.
! 115: If your C code uses ifdefs to delimit non-C lines,
! 116: such as comments
! 117: or code which is under construction,
! 118: then you must tell
! 119: .Nm unifdef
! 120: which symbols are used for that purpose so that it won't try to parse
! 121: for quotes and comments
! 122: inside those ifdefs.
! 123: One specifies ignored ifdefs with
! 124: .Fl iD Ns Ar sym
! 125: and
! 126: .Fl iU Ns Ar sym
! 127: similar to
! 128: .Fl D Ns Ar sym
! 129: and
! 130: .Fl U Ns Ar sym
! 131: above.
! 132: .El
! 133: .Pp
! 134: .Nm Unifdef
! 135: copies its output to
! 136: .Em stdout
! 137: and will take its input from
! 138: .Em stdin
! 139: if no
! 140: .Ar file
! 141: argument is given.
! 142: .Pp
! 143: .Nm Unifdef
! 144: works nicely with the
! 145: .Fl D Ns Ar sym
! 146: option added to
! 147: .Xr diff 1
! 148: as of the 4.1 Berkeley Software Distribution.
! 149: .Sh SEE ALSO
! 150: .Xr diff 1
! 151: .Sh DIAGNOSTICS
! 152: Inappropriate else or endif.
! 153: .br
! 154: Premature
! 155: .Tn EOF
! 156: with line numbers of the unterminated #ifdefs.
! 157: .Pp
! 158: Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
! 159: .Sh BUGS
! 160: Should try to deal with ``#if'' lines.
! 161: .Pp
! 162: Doesn't work correctly if input contains null characters.
! 163: .Sh HISTORY
! 164: The
! 165: .Nm
! 166: command appeared in
! 167: .Bx 4.3 .