Commit Graph

81 Commits

Author SHA1 Message Date
Conrad Meyer
61287be181 Re-apply fixed r354847
unifdef(1): Improve worst-case bound on symbol resolution

Use RB_TREE to make some algorithms O(lg N) and O(N lg N) instead of O(N)
and O(N^2).

While here, remove arbitrarily limit on number of macros understood.

Reverts r354877 and r354878, which disabled the (correct) test.

PR:		242095
Reported by:	lwhsu
2019-11-20 19:43:34 +00:00
Conrad Meyer
0877992e6b Revert r354847 for now
It was broken.

PR:		242095
Reported by:	lwhsu
2019-11-20 19:07:22 +00:00
Conrad Meyer
82e14014a3 unifdef(1): Improve worst-case bound on symbol resolution
Use RB_TREE to make some algorithms O(lg N) and O(N lg N) instead of O(N)
and O(N^2).  Because N is typically small and the former linear array also has
great constant factors (as a property of CPU caching), this doesn't provide
material benefit most or all of the time.

While here, remove arbitrarily limit on number of macros understood.
2019-11-19 04:30:23 +00:00
Conrad Meyer
3cbfa41a57 unifdef(1): Kill totally useless header
No functional change.
2019-11-19 03:15:06 +00:00
Conrad Meyer
470182bb6e Link in NetBSD's unifdef(1) tests
Skip one, is it currently fails.
2019-11-18 04:03:11 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Eitan Adler
417bdb60ca Update URLs in usr.bin
- http -> https
- contents have moved locations
- removal of URL if I could not find new location
2017-10-29 08:03:21 +00:00
Tony Finch
383f792e9c Avoid -Wmissing-initializer 2015-12-03 14:32:54 +00:00
Tony Finch
ef4eec8a6d Update to upstream version 2.11
Improved #if expression evaluator and safer modify-in-place.

Obtained from:	http://dotat.at/prog/unifdef
MFC after:	1 week
2015-12-03 14:21:55 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Hans Petter Selasky
39b86a6a6f Update to upstream version 2.10
The most notable new feature is support for definition files.

Obtained from:	http://dotat.at/prog/unifdef
MFC after:	1 week
2015-02-25 21:10:03 +00:00
Simon J. Gerraty
ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Baptiste Daroussin
2b7af31cf5 use .Mt to mark up email addresses consistently (part3)
PR:		191174
Submitted by:	Franco Fichtner  <franco at lastsummer.de>
2014-06-23 08:23:05 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Tony Finch
31f5980bd9 Update to upstream version 2.7
The most notable new feature is support for processing multiple
files in one invocation. There is also support for more make-friendly
exit statuses.

The most notable bug fix is #line directives now include the input
file name.

Obtained from: http://dotat.at/prog/unifdef
2013-03-28 20:33:07 +00:00
David E. O'Brien
64508c55f2 No need to call an external program. 2013-03-13 22:50:14 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Joel Dahl
126b754db4 Remove superfluous paragraph macro. 2012-03-25 09:19:25 +00:00
Ed Schouten
48ef17602b Mark global functions and/or variables in unifdef(1) static where possible.
This allows compilers and static analyzers to more thorough analysis.
2011-11-06 18:50:00 +00:00
Tony Finch
9bbfc2e646 Update to upstrea version 2.5.6.
Detect IO errors properly.
Write #line directives to the correct output stream.

Obtained from:	http://dotat.at/prog/unifdef
2011-01-21 18:10:11 +00:00
Tony Finch
8bd9ecb569 Update to upstream version 2.3
Only significant change is to fix a bu when the output file overwrites
the input when the input is redirected.

Obtained from: http://dotat.at/prog/unifdef
2011-01-18 19:13:03 +00:00
Joel Dahl
ff9923c869 Fix typos. 2010-08-01 09:10:09 +00:00
Tony Finch
3548be4a24 Update to upstream version 2.3
Add -V (display version) and -S (list controlling symbols per #if
with nesting information) options, and improve unifdefall debug output.
Done committing 0 revisions to SVN

Obtained from: http://dotat.at/prog/unifdef
2010-03-12 17:55:29 +00:00
Tony Finch
86eea914a7 Update to upstream version 1.338
Fix a long-standing cpp compatibility bug: The -DFOO argument
(without an explicit value) should define FOO to 1 not to the empty
string.

Add support for CRLF newlines, based on a suggestion from Mark Rushakoff.

Obtained from:	http://dotat.at/prog/unifdef/
2010-02-19 16:54:51 +00:00
Tony Finch
8e23f2a641 Fix portability to 64 bit platforms.
printf("%.*s",i,s) expects an int not a ptrdiff_t

Thanks to bf1783 (at) googlemail.com for the bug report.
2010-01-19 20:35:44 +00:00
Tony Finch
f20a8dd3ac Sync unifdefall with upstream. It no longer relies entirely on $PATH
to find unifdef, in order to support running the test suite before
installing.
2010-01-19 18:18:15 +00:00
Tony Finch
4992d459a5 Add a -o outfile option, which can be used to specify an output file. The
file can safely be the same as the input file.  Idea from IRIX unifdef(1).
This version fixes a bug in the NetBSD unifdef which refuses to
write to a -o outfile which does not exist.

Obtained from: NetBSD
2010-01-19 18:13:54 +00:00
Ed Schouten
b7946da96b Build usr.bin/ with WARNS=6 by default.
Also add some missing $FreeBSD$ to keep svn happy.
2010-01-02 10:27:05 +00:00
Tony Finch
137f2acad4 unifdef: fix invalid array access when nesting limit exceeded
If the number of nested #if blocks exceeds 64, nest() increments
the nesting depth and then reports an error.  The message includes
the line number for the start of the current #if block, which is
read from past the end of the relevant array.

Avoid the out-of-bounds read by reporting the error and exiting
before the nesting depth has a chance to increase.

Submitted by: Jonathan Nieder <jrnieder@gmail.com>
2009-11-27 17:53:49 +00:00
Tony Finch
84a3c48bb4 unifdefall: optimise the loop that builds the unifdef command.
The old code used a shell loop to convert each controlling macro
definition into a command-line argument, reading the macro definitions
file each time. The new code converts the list of controlling macros
into a sed script which can run through the list of macro definitions
in one go.

Add some explanatory comments, since the code is quite meta.

Use {} instead of () for redirecting a group of commands.

Submitted by: Jonathan Nieder <jrnieder@gmail.com>
2009-11-26 19:08:33 +00:00
Tony Finch
8af26c5e86 Remove debugging remnants from unifdefall.
Submitted by:	Jonathan Nieder <jrnieder@gmail.com>
2009-11-26 02:14:08 +00:00
Tony Finch
f6f85e213e 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/
2009-11-25 20:23:18 +00:00
Hiroki Sato
f1675e84a5 Add AUTHORS section[*] and fix HISTORY section.
Requested by:		Dave Yost (original author)[*]
History checked by:	The CSRG Archives
MFC after:		3 days
2008-05-02 16:23:47 +00:00
Tony Finch
6944dcc57a Typo in comment spotted by Hasso Tepper.
Obtained from: DragonFlyBSD
2008-03-02 22:27:49 +00:00
Tony Finch
c1fe255f90 A fix for other ways of triggering joe@'s bug. 2008-02-29 13:19:50 +00:00
Tony Finch
25ce8d30ab Allow #if defined SYM as well as #if defined(SYM). Fix an abort
caused by files that have #endif and no newline on the last line
(reported by joe@). Also fix a benign uninitialized variable bug.
Update and tidy the copyright.
2008-02-29 12:57:14 +00:00
Ruslan Ermilov
f682f10c76 Sync program's usage() with manpage's SYNOPSIS. 2005-05-21 09:55:10 +00:00
Tony Finch
7dded4a50e Sync with upstream:
Allow the user to run unifdef without defining any symbols. This is
useful in conjunction with the -k flag.
Fix a bug in the -s handling code that would have caused out-of-bounds
array accesses.
Add a -n option to insert #line directives in the output.
Ignore comment markers inside string and character literals
(bug reported by Amos Shapira <amos.shapira@netregistry.com.au>).
More accurate copyright notices.
2005-03-08 12:52:00 +00:00
Ruslan Ermilov
6c7216df78 Sort sections. 2005-01-18 13:43:56 +00:00
Ruslan Ermilov
a866e17077 Added the EXIT STATUS section where appropriate. 2005-01-17 07:44:44 +00:00
Tony Finch
2fd339446d Improve expression evaluation debugging output, tidy up the handling of
EOF, and improve the commentary about backslash-newline handling.
2003-07-01 15:30:43 +00:00
Tony Finch
eb801906b8 Various fixes from upstream, including a bug...
Fix the usage synopsis.

Amend the copyright notice to reflect the fact that there's no Berkeley
code left.

Fix a typo in a comment, improve the descriptions of the way we use
some global variables (relevant to the bug below), and note that
division-by-zero has side effects so the current expression evaluator
can't be trivially extended to arithmetic in its current design.

Avoid hitting an abort(); /* bug */ when in "text mode" (i.e.
ignoring comment state) by updating the line parser state properly.

PR:	53907
2003-06-30 14:46:25 +00:00
Tony Finch
2611a92c3a MAINTAINER line moved to MAINTAINERS file. 2003-06-04 10:01:10 +00:00