diff options
author | fanf <fanf@FreeBSD.org> | 2009-11-25 20:23:18 +0000 |
---|---|---|
committer | fanf <fanf@FreeBSD.org> | 2009-11-25 20:23:18 +0000 |
commit | 0960dfee41a0d4a8397a5ae182649588b7deeba8 (patch) | |
tree | ffcdb398b1f42147ff1f433e4bb9d9d0971d0b74 /usr.bin/unifdef/unifdef.1 | |
parent | bf4b9dad83a701b57717da855cd3e9d309f7474a (diff) | |
download | FreeBSD-src-0960dfee41a0d4a8397a5ae182649588b7deeba8.zip FreeBSD-src-0960dfee41a0d4a8397a5ae182649588b7deeba8.tar.gz |
Update unifdef to my upstream version 1.188
Main highlights:
(A) The new -B option compresses blank lines around a deleted section
so that blank lines around "paragraphs" of code don't get doubled.
(B) Lenient evaluation of && and || so that #if expressions can be
evaluated even when some of their sub-expressions cannot be.
(C) The evaluator can now handle macros with arguments.
(D) Portability fixes, especially for unifdefall.
Contributions from:
Ben Hutchings at Solarflare Communications (A and B)
Anders H Kaseorg <andersk@mit.edu> (A and C)
Jonathan Nieder <jrnieder@gmail.com> (D)
Obtained from: http://dotat.at/prog/unifdef/
Diffstat (limited to 'usr.bin/unifdef/unifdef.1')
-rw-r--r-- | usr.bin/unifdef/unifdef.1 | 123 |
1 files changed, 90 insertions, 33 deletions
diff --git a/usr.bin/unifdef/unifdef.1 b/usr.bin/unifdef/unifdef.1 index 12a5438..80ee7ba 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 - 2009 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,7 +30,7 @@ .\" 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.60 2009/11/25 00:11:02 fanf2 Exp $ .\" $FreeBSD$ .\" .Dd September 24, 2002 @@ -41,7 +41,7 @@ .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 @@ -70,46 +70,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,8 +164,7 @@ 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 @@ -143,6 +181,19 @@ 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 +225,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 +247,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 @@ -235,7 +292,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 +370,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 |