1.\" Copyright (c) 1985, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Dave Yost. 6.\" 7.\" %sccs.include.redist.roff% 8.\" 9.\" @(#)unifdef.1 8.2 (Berkeley) 04/01/94 10.\" 11.Dd 12.Dt UNIFDEF 1 13.Os BSD 4.3 14.Sh NAME 15.Nm unifdef 16.Nd remove ifdef'ed lines 17.Sh SYNOPSIS 18.Nm unifdef 19.Op Fl clt 20.Oo 21.Fl D Ns Ar sym 22.Fl U Ns Ar sym 23.Fl iD Ns Ar sym 24.Fl iD Ns Ar sym 25.Oc 26.Ar ... 27.Op Ar file 28.Sh DESCRIPTION 29.Nm Unifdef 30is useful for removing ifdef'ed lines 31from a file while otherwise leaving the file alone. 32.Nm Unifdef 33acts on 34#ifdef, #ifndef, #else, and #endif lines, 35and it knows only enough about C 36to know when one of these is inactive 37because it is inside 38a comment, 39or a single or double quote. 40Parsing for quotes is very simplistic: 41when it finds an open quote, 42it ignores everything (except escaped quotes) 43until it finds a close quote, and 44it will not complain if it gets 45to the end of a line and finds no backslash for continuation. 46.Pp 47Available options: 48.Bl -tag -width Ds -compact 49.It Fl D Ns Ar sym 50.It Fl U Ns Ar sym 51Specify which symbols to define or undefine. 52and the lines inside those ifdefs will be copied to the output or removed as 53appropriate. 54The ifdef, ifndef, else, and endif lines associated with 55.Ar sym 56will also be removed. 57Ifdefs involving symbols you don't specify 58and ``#if'' control lines 59are untouched and copied out 60along with their associated 61ifdef, else, and endif lines. 62If an ifdef X occurs nested inside another ifdef X, then the 63inside ifdef is treated as if it were an unrecognized symbol. 64If the same symbol appears in more than one argument, 65the last occurrence dominates. 66.Pp 67.It Fl c 68If the 69.Fl c 70flag is specified, 71then the operation of 72.Nm unifdef 73is complemented, 74i.e. the lines that would have been removed or blanked 75are retained and vice versa. 76.Pp 77.It Fl l 78Replace removed lines with blank lines 79instead of deleting them. 80.It Fl t 81Disables parsing for C comments and quotes, which is useful 82for plain text. 83.Pp 84.It Fl iD Ns Ar sym 85.It Fl iU Ns Ar sym 86Ignore ifdefs. 87If your C code uses ifdefs to delimit non-C lines, 88such as comments 89or code which is under construction, 90then you must tell 91.Nm unifdef 92which symbols are used for that purpose so that it won't try to parse 93for quotes and comments 94inside those ifdefs. 95One specifies ignored ifdefs with 96.Fl iD Ns Ar sym 97and 98.Fl iU Ns Ar sym 99similar to 100.Fl D Ns Ar sym 101and 102.Fl U Ns Ar sym 103above. 104.El 105.Pp 106.Nm Unifdef 107copies its output to 108.Em stdout 109and will take its input from 110.Em stdin 111if no 112.Ar file 113argument is given. 114.Pp 115.Nm Unifdef 116works nicely with the 117.Fl D Ns Ar sym 118option added to 119.Xr diff 1 120as of the 4.1 Berkeley Software Distribution. 121.Sh SEE ALSO 122.Xr diff 1 123.Sh DIAGNOSTICS 124Inappropriate else or endif. 125.br 126Premature 127.Tn EOF 128with line numbers of the unterminated #ifdefs. 129.Pp 130Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble. 131.Sh BUGS 132Should try to deal with ``#if'' lines. 133.Pp 134Doesn't work correctly if input contains null characters. 135.Sh HISTORY 136The 137.Nm 138command appeared in 139.Bx 4.3 . 140