version 1.7, 2000/03/06 03:17:40 |
version 1.8, 2000/03/11 21:40:06 |
|
|
.Ar ... |
.Ar ... |
.Op Ar file |
.Op Ar file |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
.Nm unifdef |
.Nm |
is useful for removing ifdef'ed lines |
is useful for removing ifdef'ed lines |
from a file while otherwise leaving the file alone. |
from a file while otherwise leaving the file alone. |
.Nm unifdef |
.Nm |
acts on |
acts on |
#ifdef, #ifndef, #else, and #endif lines, |
#ifdef, #ifndef, #else, and #endif lines, |
and it knows only enough about C |
and it knows only enough about C |
|
|
to the end of a line and finds no backslash for continuation. |
to the end of a line and finds no backslash for continuation. |
.Pp |
.Pp |
The options are as follows: |
The options are as follows: |
.Bl -tag -width Ds -compact |
.Bl -tag -width Ds |
.It Fl D Ns Ar sym |
.It Xo Fl D Ns Ar sym , |
.It Fl U Ns Ar sym |
.Fl U Ns Ar sym |
|
.Xc |
Specify which symbols to define or undefine, |
Specify which symbols to define or undefine, |
and the lines inside those ifdefs will be copied to the output or removed as |
and the lines inside those ifdefs will be copied to the output or removed as |
appropriate. |
appropriate. |
|
|
.Ar sym |
.Ar sym |
will also be removed. |
will also be removed. |
ifdefs involving symbols you don't specify |
ifdefs involving symbols you don't specify |
and ``#if'' control lines |
and |
are untouched and copied out |
.Dq #if |
|
control lines are untouched and copied out |
along with their associated |
along with their associated |
ifdef, else, and endif lines. |
ifdef, else, and endif lines. |
If an ifdef X occurs nested inside another ifdef X, then the |
If an ifdef X occurs nested inside another ifdef X, then the |
inside ifdef is treated as if it were an unrecognized symbol. |
inside ifdef is treated as if it were an unrecognized symbol. |
If the same symbol appears in more than one argument, |
If the same symbol appears in more than one argument, |
the last occurrence dominates. |
the last occurrence dominates. |
.Pp |
|
.It Fl c |
.It Fl c |
If the |
If the |
.Fl c |
.Fl c |
flag is specified, |
flag is specified, |
then the operation of |
then the operation of |
.Nm unifdef |
.Nm |
is complemented, |
is complemented, |
i.e. the lines that would have been removed or blanked |
i.e., the lines that would have been removed or blanked |
are retained and vice versa. |
are retained and vice versa. |
.Pp |
|
.It Fl l |
.It Fl l |
Replace removed lines with blank lines |
Replace removed lines with blank lines |
instead of deleting them. |
instead of deleting them. |
.Pp |
|
.It Fl t |
.It Fl t |
Disables parsing for C comments and quotes, which is useful |
Disables parsing for C comments and quotes, which is useful |
for plain text. |
for plain text. |
.Pp |
.It Xo Fl iD Ns Ar sym , |
.It Fl iD Ns Ar sym |
.Fl iU Ns Ar sym |
.It Fl iU Ns Ar sym |
.Xc |
Ignore ifdefs. |
Ignore ifdefs. |
If your C code uses ifdefs to delimit non-C lines, |
If your C code uses ifdefs to delimit non-C lines, |
such as comments |
such as comments |
or code which is under construction, |
or code which is under construction, |
then you must tell |
then you must tell |
.Nm unifdef |
.Nm |
which symbols are used for that purpose so that it won't try to parse |
which symbols are used for that purpose so that it won't try to parse |
for quotes and comments |
for quotes and comments |
inside those ifdefs. |
inside those ifdefs. |
|
|
above. |
above. |
.El |
.El |
.Pp |
.Pp |
.Nm unifdef |
.Nm |
copies its output to |
copies its output to |
.Em stdout |
.Em stdout |
and will take its input from |
and will take its input from |
|
|
.Ar file |
.Ar file |
argument is given. |
argument is given. |
.Pp |
.Pp |
.Nm unifdef |
.Nm |
works nicely with the |
works nicely with the |
.Fl D Ns Ar sym |
.Fl D Ns Ar sym |
option added to |
option added to |
.Xr diff 1 |
.Xr diff 1 |
as of the 4.1 Berkeley Software Distribution. |
as of the 4.1 Berkeley Software Distribution. |
.Sh SEE ALSO |
|
.Xr diff 1 |
|
.Sh DIAGNOSTICS |
.Sh DIAGNOSTICS |
Inappropriate else or endif. |
Inappropriate else or endif. |
.br |
.br |
|
|
with line numbers of the unterminated #ifdefs. |
with line numbers of the unterminated #ifdefs. |
.Pp |
.Pp |
Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble. |
Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble. |
|
.Sh SEE ALSO |
|
.Xr diff 1 |
.Sh HISTORY |
.Sh HISTORY |
The |
The |
.Nm |
.Nm |
command appeared in |
command appeared in |
.Bx 4.3 . |
.Bx 4.3 . |
.Sh BUGS |
.Sh BUGS |
Should try to deal with ``#if'' lines. |
Should try to deal with |
|
.Dq #if |
|
lines. |
.Pp |
.Pp |
Doesn't work correctly if input contains null characters. |
Doesn't work correctly if input contains null characters. |