1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-09 22:38:01 -08:00
Commit Graph

56 Commits

Author SHA1 Message Date
jsg
ce7279d89b remove prototypes with no matching function and externs with no var
partly checked by millert@
2024-05-21 05:00:47 +00:00
bcallah
d2d86e25c8 Add -E flag (make warnings fatal), following the behavior of GNU m4 1.4.9+
Help and direction millert@ espie@ anton@ deraadt@

ok espie@
2017-06-15 13:48:42 +00:00
espie
e2ff9f51c4 adjust to ohash being in libutil now, and to the interface changes.
fix potential integer overflows in memory allocation (mostly for pedagogical
purposes, these are unlikely to overflow in practice)
move the rest of lst.lib stuff into its own directory.
2014-05-12 19:11:19 +00:00
espie
c608d5f4b5 check for integer overflows in custom allocs, okay jca@ 2014-04-28 12:34:11 +00:00
espie
a45fdd0c50 new m4 -g stuff:
- expr(`4**3')
- include(`hey I am not there') keeps going.

work with Baptiste Daroussin, who had the idea but didn't nail all details
right.

okay otto@, miod@
2012-04-12 17:00:11 +00:00
espie
7de0d87763 zap dead stuff
from Michael W. Bombardieri
2011-09-27 07:24:02 +00:00
marco
c17ca14eab Remove stray spaces. No code change. 2010-09-07 19:58:09 +00:00
sthen
092f48df65 Support the -P option from gnu m4, which prefixes builtins with the
string m4_. Feedback from jmc@, Tobias Ulmer, Matthew Dempsky - thanks!
ok espie@
2009-10-14 17:19:47 +00:00
espie
829f43f3ce use unsigned char for buffers, allow differentiating between EOF and y".
okay otto@
2008-08-21 20:59:14 +00:00
espie
8008022cde not yet, committed too much 2008-08-16 12:23:50 +00:00
espie
456f9fcb4d argument parsing should only skip spaces outside of parenthesis.
Inside matching parenthesis, keep spaces as is (use chrsave instead of
pbstr, since there's no way it can be a further macro expansion).
Fixes a long-standing issue with autoconf (   --option -> --option),
matches other m4 than gnum4

okay millert@, fries@
2008-08-16 12:21:46 +00:00
espie
09d1584fde add limited support for format builtin in gnu-m4 mode, because I'm fed
up of patching it away in various autoconf derivatives.

okay miod@
2006-03-20 20:27:45 +00:00
espie
75ebbed72d report function m4errx, that shows app-specific data (filename/linenumber)
before the error message. Use it to simplify code.

okay miod@
2006-03-20 10:55:19 +00:00
espie
0b7a013e1b use stdint.h where appropriate. okay millert@ 2006-01-20 23:10:19 +00:00
espie
739ce1244b finally make our m4 SusV3-compliant.
- changecom and changequote have a simple definition (that matches gnu-m4,
coincidentally, so we no longer need two distinct modes for these)

- off-by-one bug in -s, this finally works.

- reorder main parser loop, so that we can use alphabetic constructs in
quotes/comments.

- rename putback to pushback, this matches comments, and makes more sense.

- more uniform (and updated) description of changequote/changecom.

- new, systematic regression tests of comments/quotes.

- framework to test -s: one perl script to reconstitute `full' files with
all line numbers, so that we can verify the output without needing a
complete match.

okay otto@, fries@
2005-09-06 15:33:21 +00:00
espie
e79fa6877f fix a few minor compatibility issues.
- let eval() handle a base and number of digits, like it's advertized to.
- in gnu-mode, undivert can take file names as arguments.
- in gnu-mode, map can handle reversed charsets.

Suggestions and okay otto@, mostly prompted by looking at the regress
tests in newer gnu-m4.
2005-05-29 18:44:36 +00:00
espie
ad459a2362 let m4wrap handle multiple wraps, both in normal and gnu-mode.
based on Noah Misch's bug report.
okay otto, jmc.
2005-03-02 10:12:15 +00:00
espie
f6169a2c06 Modify xalloc so that it also takes err(3)-like arguments.
Write an xrealloc wrapper that works the same way, and use it as well.

People who feel like it may want to add more explicit error messages to
all the places m4 can fail allocating memory...

okay tedu@
2003-11-17 17:12:10 +00:00
espie
4bc640fdbb Fold trace status into the single hash table that's left.
Inline some macros/functions for speed.
So, this achieves the goal of one single lookup for macro/trace status,
which does speed up m4 in partial tracing situations somewhat.
This does also speed up m4 in large pushdef situations, since it no longer
has to lookup large chains of macros.

okay millert@
2003-06-30 22:13:32 +00:00
espie
7888c33aa2 add a flag for each macro name that records built-in status.
Fold built-in lookup into normal lookup.
okay millert@
2003-06-30 22:11:38 +00:00
espie
ec8803d52b replace old hash structure with open hashing.
make the stack structure of macro definitions explicit.
okay millert@
2003-06-30 22:10:21 +00:00
espie
dde05c5fe1 Make the trace status of a macro an actual argument that gets pushed
in the frame for the macro expansion.

(This will allow one single lookup to grab the macro definition and
the trace status)

okay millert@
2003-06-30 21:47:21 +00:00
espie
3509e8ffae clean up internal lookup interface:
define an interface with explicit define/pushdef/popdef... and use it.
That way, most details of the hashtable are no longer visible.

okay millert@
2003-06-30 21:42:50 +00:00
espie
5ddad5cc6c - store builtin name as definition for builtin macros.
this removes the need for code->name conversion, in exchange for
systematically testing the definition type, since we can no longer
rely on the defn being NULL.

- commonnalize the builtin-detection code, so that we can use it for pushdef
as well with define, so that pushdef handles builtins correctly as well.

okay fries@, millert@.
2003-06-18 21:08:07 +00:00
espie
3ed6d6dce4 switch from linked list to hash table for traced macros.
speeds up recent autoconf somewhat, since it traces a large set
of individual macro.

(more rework of m4 internal interfaces to unify lookup tables in order)

okay fries@
2003-06-12 14:36:43 +00:00
millert
f75387cb26 Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999.  Proofed by myself and Theo.
2003-06-03 02:56:05 +00:00
espie
aec72266de Implement -s.
Triggered by recent FreeBSD changes.

- emits #line directives at every file change (like FreeBSD)
- maintains a synch_lineno variable to verify when the output gets out
of synch with the input, so that it can emit #line to re-synch as well
(unlike FreeBSD)

To do: either handle \end-of-line, or recognize when a macro expansion
is in progress, so that line synch don't perturb cpp on multi-line
expansions.

With this, we should have a fully POSIX-compliant m4.

ok miod@
2002-04-28 14:37:12 +00:00
millert
c72b5b24e1 Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically. 2002-02-16 21:27:05 +00:00
espie
17c7704d2e Prototypes shouldn't mention argument name. 2001-10-10 18:12:00 +00:00
espie
34970243d3 traceon/traceoff built-ins. 2001-09-27 11:40:33 +00:00
espie
dd84b4a63e inline some very common putback/chrsave. Worth roughly 10% 2001-09-19 13:14:18 +00:00
espie
4dac505db8 Tracing facilities. Same style as gnu-m4, because it's mostly used for
autoconf right now.
2001-09-18 14:55:52 +00:00
espie
99f77b33d6 instrumentation for tracing mode: macro expansion 2001-09-18 14:43:22 +00:00
espie
f8b42d480d let defn(builtin) work enough so that
define(`newmacro', defn(builtin))
will work, as it should.
2001-09-18 14:05:14 +00:00
espie
08f7f207a7 One single point for all macros/builtin expansion. 2001-09-18 13:52:58 +00:00
espie
25afcddb1d Handle unlimited diverts for m4 -g.
Problem with autoconf noticed by d@
2000-07-27 17:44:32 +00:00
espie
c91edbbb85 Implement esyscmd 2000-07-24 23:08:24 +00:00
espie
b09132d5cc Make the m4 machine stack dynamically sized.
Fix strspace automatic extension.
The assumption that simply updating the current pointer works is false,
there are cases where previous entries on the stack would absorp vast
amounts of string space, and overload the non-updated entries.

To fix it, we use a shadow copy of the stack, which only records which
entries are pointers within strspace, so that a resize can adjust all
those pointers at once.

Reviewed by millert@
2000-07-02 01:17:00 +00:00
espie
87c5c065f7 Last needed m4 changes to bootstrap autoconf without gnu-m4. 2000-03-18 01:06:55 +00:00
espie
b8161682f0 Add a few builtins for greater compatibility with gnu-m4, and extended
functionality.
* regular expressions,
* line-number reporting
* `meta'-macros, builtin and indir.

Reviewed by pjanzen@, tested by fries@ and a few others.
2000-03-11 15:54:43 +00:00
espie
37b94dd487 There is no need to waste short for holding EOF in the pushback buffer.
Now that the input_file structure is sufficiently fleshed out, just stop
EOF at the putback level, and make sure files at EOF STAY at EOF.
2000-01-15 14:26:00 +00:00
espie
0d3ffe1d03 Use a proper abstract interface for file accesses, so that we can record
the file name and line number.

This yields more meaningful error messages, and the possibility for yet
more.
2000-01-12 17:49:53 +00:00
espie
80cbbe91b6 Don't recognize built-ins in contexts where they don't make sense.
Namely, it doesn't help to try and expand include if it's not followed
by parenthesis and a filename.

This should make applications like sendmail m4 scripts more sturdy for
unquoted machine names that happen to collide with built-ins.

The only drawback is that our m4 may now do intelligent things with scripts
that don't work on other systems.
2000-01-11 14:06:11 +00:00
espie
b81b15b273 Clean up comment/quote recognition a little bit:
- use strlcpy to make clear that the strings are line terminated,
- remove the number of magic constants,
- use assert() for preconditions,
- use puts instead of looping over array of chars...
1999-11-30 22:19:50 +00:00
espie
70a009b1b3 Optimization: cache the hashed value to avoid negative comparisons.
With 2^32 possible hash values, this means that collisions no longer
incur supplementary string compares, which was most of the reason for
STREQ in the first place...
1999-11-20 17:48:59 +00:00
espie
bb34cd6c7e Turn warnings on,
Add missing prototypes,
Make local functions static,
Sort extern.h by file,
Constify all char * that can be,
Copy temp file name so that eval does not modify its arguments.
1999-11-17 15:34:13 +00:00
espie
53f6f6bfbd Style: kill register and indent properly.
Let indx match netbsd flavor, to simplify diffs.
Show how many quotes were not closed.
Increase stack slightly, now that we're no longer bound by argspace.
1999-09-14 08:35:16 +00:00
espie
4a7693888e Implement -I option and M4PATH environment variable 1999-09-14 08:21:32 +00:00
espie
1a15cbca7d Remove STRSPACE limitations.
A bit wasteful, but not too intrusive.

Also remove pushback buffer limitations, as this would be mostly useless
otherwise.

Incidentally, pushback buffer overflow detection in pbstr was wrong.
1999-09-06 13:29:32 +00:00
espie
3f42598db2 Get rid of mktemp in the handling of diversion.
Simply put, mkstemp/unlink/rewind has the proper semantics under Unix,
and so we don't have to keep track about temp file names and remove them.
1999-09-06 13:20:40 +00:00