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

1.8     ! aaron       1: .\"    $OpenBSD: unifdef.1,v 1.7 2000/03/06 03:17:40 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.8     ! aaron      58: .Nm
1.1       deraadt    59: is useful for removing ifdef'ed lines
                     60: from a file while otherwise leaving the file alone.
1.8     ! aaron      61: .Nm
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.8     ! aaron      77: .Bl -tag -width Ds
        !            78: .It Xo Fl D Ns Ar sym ,
        !            79: .Fl U Ns Ar sym
        !            80: .Xc
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.8     ! aaron      88: and
        !            89: .Dq #if
        !            90: control lines are untouched and copied out
1.1       deraadt    91: along with their associated
                     92: ifdef, else, and endif lines.
                     93: If an ifdef X occurs nested inside another ifdef X, then the
                     94: inside ifdef is treated as if it were an unrecognized symbol.
                     95: If the same symbol appears in more than one argument,
                     96: the last occurrence dominates.
                     97: .It Fl c
                     98: If the
                     99: .Fl c
                    100: flag is specified,
                    101: then the operation of
1.8     ! aaron     102: .Nm
1.1       deraadt   103: is complemented,
1.8     ! aaron     104: i.e., the lines that would have been removed or blanked
1.1       deraadt   105: are retained and vice versa.
                    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.
1.8     ! aaron     112: .It Xo Fl iD Ns Ar sym ,
        !           113: .Fl iU Ns Ar sym
        !           114: .Xc
1.1       deraadt   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
1.8     ! aaron     120: .Nm
1.1       deraadt   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
1.8     ! aaron     135: .Nm
1.1       deraadt   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
1.8     ! aaron     144: .Nm
1.1       deraadt   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 DIAGNOSTICS
                    151: Inappropriate else or endif.
                    152: .br
                    153: Premature
                    154: .Tn EOF
                    155: with line numbers of the unterminated #ifdefs.
                    156: .Pp
                    157: Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
1.8     ! aaron     158: .Sh SEE ALSO
        !           159: .Xr diff 1
1.1       deraadt   160: .Sh HISTORY
                    161: The
                    162: .Nm
                    163: command appeared in
                    164: .Bx 4.3 .
1.7       aaron     165: .Sh BUGS
1.8     ! aaron     166: Should try to deal with
        !           167: .Dq #if
        !           168: lines.
1.7       aaron     169: .Pp
                    170: Doesn't work correctly if input contains null characters.