summaryrefslogtreecommitdiffstats
path: root/usr.bin/unifdef/unifdef.1
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/unifdef/unifdef.1')
-rw-r--r--usr.bin/unifdef/unifdef.1152
1 files changed, 112 insertions, 40 deletions
diff --git a/usr.bin/unifdef/unifdef.1 b/usr.bin/unifdef/unifdef.1
index 12a5438..da7cde8 100644
--- a/usr.bin/unifdef/unifdef.1
+++ b/usr.bin/unifdef/unifdef.1
@@ -1,6 +1,6 @@
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
-.\" Copyright (c) 2002 - 2005 Tony Finch <dot@dotat.at>. All rights reserved.
+.\" Copyright (c) 2002 - 2010 Tony Finch <dot@dotat.at>. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Dave Yost. It was rewritten to support ANSI C by Tony Finch.
@@ -30,10 +30,10 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)unifdef.1 8.2 (Berkeley) 4/1/94
-.\" $dotat: things/unifdef.1,v 1.51 2005/03/08 12:39:01 fanf2 Exp $
+.\" $dotat: unifdef/unifdef.1,v 1.63 2010/02/19 16:41:15 fanf2 Exp $
.\" $FreeBSD$
.\"
-.Dd September 24, 2002
+.Dd January 19, 2010
.Dt UNIFDEF 1
.Os
.Sh NAME
@@ -41,14 +41,15 @@
.Nd remove preprocessor conditionals from code
.Sh SYNOPSIS
.Nm
-.Op Fl cdeklnst
+.Op Fl BbcdeKknst
.Op Fl I Ns Ar path
.Op Fl D Ns Ar sym Ns Op = Ns Ar val
.Op Fl U Ns Ar sym
.Op Fl iD Ns Ar sym Ns Op = Ns Ar val
.Op Fl iU Ns Ar sym
.Ar ...
-.Op Ar file
+.Op Fl o Ar outfile
+.Op Ar infile
.Nm unifdefall
.Op Fl I Ns Ar path
.Ar ...
@@ -70,46 +71,85 @@ utility acts on
.Ic #if , #ifdef , #ifndef , #elif , #else ,
and
.Ic #endif
-lines,
-and it understands only the commonly-used subset
+lines.
+A directive is only processed
+if the symbols specified on the command line are sufficient to allow
+.Nm
+to get a definite value for its control expression.
+If the result is false,
+the directive and the following lines under its control are removed.
+If the result is true,
+only the directive is removed.
+An
+.Ic #ifdef
+or
+.Ic #ifndef
+directive is passed through unchanged
+if its controlling symbol is not specified on the command line.
+Any
+.Ic #if
+or
+.Ic #elif
+control expression that has an unknown value or that
+.Nm
+cannot parse is passed through unchanged.
+By default,
+.Nm
+ignores
+.Ic #if
+and
+.Ic #elif
+lines with constant expressions;
+it can be told to process them by specifying the
+.Fl k
+flag on the command line.
+.Pp
+It understands a commonly-used subset
of the expression syntax for
.Ic #if
and
.Ic #elif
-lines.
-It handles
+lines:
+integer constants,
integer values of symbols defined on the command line,
the
.Fn defined
-operator applied to symbols defined or undefined on the command line,
+operator,
the operators
.Ic \&! , < , > , <= , >= , == , != , && , || ,
and parenthesized expressions.
-Anything that it does not understand is passed through unharmed.
-It only processes
-.Ic #ifdef
-and
-.Ic #ifndef
-directives if the symbol is specified on the command line,
-otherwise they are also passed through unchanged.
-By default, it ignores
-.Ic #if
-and
-.Ic #elif
-lines with constant expressions,
-or they may be processed by specifying the
-.Fl k
-flag on the command line.
+A kind of
+.Dq "short circuit"
+evaluation is used for the
+.Ic &&
+operator:
+if either operand is definitely false then the result is false,
+even if the value of the other operand is unknown.
+Similarly,
+if either operand of
+.Ic ||
+is definitely true then the result is true.
+.Pp
+In most cases, the
+.Nm
+utility does not distinguish between object-like macros
+(without arguments) and function-like arguments (with arguments).
+If a macro is not explicitly defined, or is defined with the
+.Fl D
+flag on the command-line, its arguments are ignored.
+If a macro is explicitly undefined on the command line with the
+.Fl U
+flag, it may not have any arguments since this leads to a syntax error.
.Pp
The
.Nm
-utility also understands just enough about C
+utility understands just enough about C
to know when one of the directives is inactive
because it is inside
a comment,
or affected by a backslash-continued line.
It spots unusually-formatted preprocessor directives
-and knows when the layout is too odd to handle.
+and knows when the layout is too odd for it to handle.
.Pp
A script called
.Nm unifdefall
@@ -125,24 +165,38 @@ and their definitions (or lack thereof),
then invokes
.Nm
with appropriate arguments to process the file.
-.Pp
-Available options:
+.Sh OPTIONS
.Pp
.Bl -tag -width indent -compact
-.It Fl D Ns Ar sym Ns Op = Ns Ar val
-Specify that a symbol is defined,
-and optionally specify what value to give it
-for the purpose of handling
+.It Fl D Ns Ar sym Ns = Ns Ar val
+Specify that a symbol is defined to a given value
+which is used when evaluating
.Ic #if
and
.Ic #elif
-directives.
+control expressions.
+.Pp
+.It Fl D Ns Ar sym
+Specify that a symbol is defined to the value 1.
.Pp
.It Fl U Ns Ar sym
Specify that a symbol is undefined.
If the same symbol appears in more than one argument,
the last occurrence dominates.
.Pp
+.It Fl B
+Compress blank lines around a deleted section.
+Mutually exclusive with the
+.Fl b
+option.
+.Pp
+.It Fl b
+Replace removed lines with blank lines
+instead of deleting them.
+Mutually exclusive with the
+.Fl B
+option.
+.Pp
.It Fl c
If the
.Fl c
@@ -174,6 +228,16 @@ option changes the behaviour so that,
where possible,
such lines are left unprocessed instead of reporting an error.
.Pp
+.It Fl K
+Always treat the result of
+.Ic &&
+and
+.Ic ||
+operators as unknown if either operand is unknown,
+instead of short-circuiting when unknown operands can't affect the result.
+This option is for compatibility with older versions of
+.Nm .
+.Pp
.It Fl k
Process
.Ic #if
@@ -186,10 +250,6 @@ because they typically start
and are used as a kind of comment to sketch out future or past development.
It would be rude to strip them out, just as it would be for normal comments.
.Pp
-.It Fl l
-Replace removed lines with blank lines
-instead of deleting them.
-.Pp
.It Fl n
Add
.Li #line
@@ -197,6 +257,18 @@ directives to the output following any deleted lines,
so that errors produced when compiling the output file correspond to
line numbers in the input file.
.Pp
+.It Fl o Ar outfile
+Write output to the file
+.Ar outfile
+instead of the standard output.
+If
+.Ar outfile
+is the same as the input file,
+the output is written to a temporary file
+which is renamed into place when
+.Nm
+completes successfully.
+.Pp
.It Fl s
Instead of processing the input file as usual,
this option causes
@@ -235,7 +307,7 @@ comments
and line continuations
inside those
.Ic #ifdef Ns s .
-One specifies ignored symbols with
+You can specify ignored symbols with
.Fl iD Ns Ar sym Ns Oo = Ns Ar val Oc
and
.Fl iU Ns Ar sym
@@ -313,7 +385,7 @@ command appeared in
support was added in
.Fx 4.7 .
.Sh AUTHORS
-This implementation was originally written by
+The original implementation was written by
.An Dave Yost Aq Dave@Yost.com .
.An Tony Finch Aq dot@dotat.at
rewrote it to support
OpenPOWER on IntegriCloud