[BACK]Return to unifdef.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / unifdef

Annotation of src/usr.bin/unifdef/unifdef.1, Revision 1.2

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