[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.5

1.5     ! aaron       1: .\"    $OpenBSD: unifdef.1,v 1.4 1999/06/05 01:21:45 aaron 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
1.4       aaron      42: .Os
1.1       deraadt    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
1.3       aaron      58: .Nm unifdef
1.1       deraadt    59: is useful for removing ifdef'ed lines
                     60: from a file while otherwise leaving the file alone.
1.3       aaron      61: .Nm unifdef
1.1       deraadt    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
1.5     ! aaron      76: The options are as follows:
1.3       aaron      77: .Pp
1.1       deraadt    78: .Bl -tag -width Ds -compact
                     79: .It Fl D Ns Ar sym
                     80: .It Fl U Ns Ar sym
1.3       aaron      81: Specify which symbols to define or undefine,
1.1       deraadt    82: and the lines inside those ifdefs will be copied to the output or removed as
                     83: appropriate.
                     84: The ifdef, ifndef, else, and endif lines associated with
                     85: .Ar sym
                     86: will also be removed.
1.3       aaron      87: ifdefs involving symbols you don't specify
1.1       deraadt    88: and ``#if'' control lines
                     89: are untouched and copied out
                     90: along with their associated
                     91: ifdef, else, and endif lines.
                     92: If an ifdef X occurs nested inside another ifdef X, then the
                     93: inside ifdef is treated as if it were an unrecognized symbol.
                     94: If the same symbol appears in more than one argument,
                     95: the last occurrence dominates.
                     96: .Pp
                     97: .It Fl c
                     98: If the
                     99: .Fl c
                    100: flag is specified,
                    101: then the operation of
                    102: .Nm unifdef
                    103: is complemented,
                    104: i.e. the lines that would have been removed or blanked
                    105: are retained and vice versa.
                    106: .Pp
                    107: .It Fl l
                    108: Replace removed lines with blank lines
                    109: instead of deleting them.
1.3       aaron     110: .Pp
1.1       deraadt   111: .It Fl t
                    112: Disables parsing for C comments and quotes, which is useful
                    113: for plain text.
                    114: .Pp
                    115: .It Fl iD Ns Ar sym
                    116: .It Fl iU Ns Ar sym
                    117: Ignore ifdefs.
                    118: If your C code uses ifdefs to delimit non-C lines,
                    119: such as comments
                    120: or code which is under construction,
                    121: then you must tell
                    122: .Nm unifdef
                    123: which symbols are used for that purpose so that it won't try to parse
                    124: for quotes and comments
                    125: inside those ifdefs.
                    126: One specifies ignored ifdefs with
                    127: .Fl iD Ns Ar sym
                    128: and
                    129: .Fl iU Ns Ar sym
                    130: similar to
                    131: .Fl D Ns Ar sym
                    132: and
                    133: .Fl U Ns Ar sym
                    134: above.
                    135: .El
                    136: .Pp
1.3       aaron     137: .Nm unifdef
1.1       deraadt   138: copies its output to
                    139: .Em stdout
                    140: and will take its input from
                    141: .Em stdin
                    142: if no
                    143: .Ar file
                    144: argument is given.
                    145: .Pp
1.3       aaron     146: .Nm unifdef
1.1       deraadt   147: works nicely with the
                    148: .Fl D Ns Ar sym
                    149: option added to
                    150: .Xr diff 1
                    151: as of the 4.1 Berkeley Software Distribution.
                    152: .Sh SEE ALSO
                    153: .Xr diff 1
                    154: .Sh DIAGNOSTICS
                    155: Inappropriate else or endif.
                    156: .br
                    157: Premature
                    158: .Tn EOF
                    159: with line numbers of the unterminated #ifdefs.
                    160: .Pp
                    161: Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
                    162: .Sh BUGS
                    163: Should try to deal with ``#if'' lines.
                    164: .Pp
                    165: Doesn't work correctly if input contains null characters.
                    166: .Sh HISTORY
                    167: The
                    168: .Nm
                    169: command appeared in
                    170: .Bx 4.3 .