29 Commits

Author SHA1 Message Date
Eric Blake
463db2c7fe Remove redundant examples/stackovf.sh.
* examples/stackovf.sh: Delete, now that checks has better
version.
* examples/Makefile.am (EXTRA_DIST): Don't distribute it.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-07-17 16:49:57 -06:00
Eric Blake
f3fbfb92cc Stage 24: Allow embedded NUL in macro names.
* m4/gnulib-cache.m4: Import xmemdup0 module.
* src/m4.h (define_builtin, push_string_init, push_wrapup_init)
(lookup_symbol): Add parameters.
(struct call_info): Add name_len member.
(struct token_data) [ENABLE_CHANGEWORD]: Add original_len member.
(struct symbol): Add len member.
(TOKEN_DATA_ORIG_LEN, SYMBOL_NAME_LEN): New accessors.
(m4_error_at_line, m4_warn_at_line): Delete.
(m4_error, m4_warn, debug_set_output, skip_line, set_word_regexp)
(bad_argc, evaluate): Adjust parameter type.
* src/m4.c (m4_error_at_line, m4_warn_at_line): Delete.
(m4_verror_at_line, m4_error, m4_warn): Adjust parameter type.
(main): Adjust caller.
* src/symtab.c (profile_strcmp) [DEBUG_SYMTAB]: Rename...
(profile_memcmp): ...and accomodate NUL.
(hash, lookup_symbol): Add parameter to track length.
(symtab_debug, symtab_print_list): Adjust callers.
* src/input.c (push_string_init, push_wrapup_init): Take location
as parameter rather than using global state.
(skip_line, set_word_regexp, next_token): Adjust parameter type.
(peek_input, next_char_1, match_input, lex_debug): Adjust
callers.
* src/macro.c (struct macro_arguments): Delete argv0 and argv0_len
members, now covered by info.
(expand_input, expand_token, expand_argument, collect_arguments)
(expand_macro, arg_text, arg_empty, arg_len, make_argv_ref)
(push_arg, wrap_args): Adjust callers.
* src/builtin.c (define_builtin): Add parameter.
(bad_argc, numeric_arg, mkstemp_helper, substitute): Adjust
parameter type.
(define_user_macro, builtin_init, define_macro, m4_undefine)
(m4_popdef, m4_ifdef, m4_ifelse, dumpdef_cmp, m4_dumpdef)
(m4_builtin, m4_indir, m4_defn, m4_syscmd, m4_esyscmd, m4_eval)
(m4_incr, m4_decr, m4_divert, m4_divnum, m4_undivert, m4_shift)
(m4_changequote, m4_changecom, m4_changeword, include)
(m4_maketemp, m4_mkstemp, m4_errprint, m4___file__, m4___line__)
(m4___program__, m4_m4exit, m4_m4wrap, m4_traceon, m4_traceoff)
(m4_debugmode, m4_debugfile, m4_len, m4_index, m4_substr)
(m4_translit, m4_format, m4_regexp, m4_patsubst): Adjust all
callers.
* src/debug.c (debug_set_file, debug_set_output): Adjust parameter
type.
(trace_flush, trace_prepre, trace_pre): Adjust all callers.
* src/eval.c (logical_or_term, logical_and_term, or_term)
(xor_term, and_term, equality_term, cmp_term, shift_term)
(add_term, mult_term, exp_term, unary_term, simple_term)
(evaluate): Adjust parameter type.
* src/format.c (arg_int, arg_long, arg_double): Likewise.
(expand_format): Adjust caller.
* doc/m4.texinfo (Using frozen files): Test this.
* examples/null.m4: Likewise.
* examples/null.err: Adjust expected output.
* examples/null.out: Likewise.

(cherry picked from commit 6167507cf07ddbc838e14e3d66803b360e63f6f2)

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-06-02 21:31:43 -06:00
Eric Blake
bc4cf0aa6f Stage 23: allow tracing of indirect macro calls.
* src/m4.h (struct call_info): New struct.
(trace_prepre, trace_pre, trace_post, push_string_finish)
(input_print, call_macro): Alter signatures.
(arg_info): New prototype.
(input_block): Delete...
* src/input.c (input_block): ...and make typedef local again.
(push_string_init): Initialize length.
(push_string_finish, input_print): Change signature, so that
printing can be done before finalization.
* src/macro.c (struct macro_arguments): Add info member.
(collect_arguments, make_argv_ref): Manage new field.
(expand_macro): Change call context management.  Move tracing...
(call_macro): ...here, and remove redundant parameter.
(arg_info): New function.
* src/debug.c (trace_format): Delete unused modifiers.
(trace_header, trace_flush, trace_prepre, trace_pre, trace_post):
Change signatures for stacked trace messages, and for using call
context.
* src/builtin.c (m4_builtin, m4_indir): Update callers.
* src/m4.c (usage): Update debugmode flag summary.
* doc/m4.texinfo (Defn): Update examples to match new behavior.
(Trace): Mention new capability of indir.
(Debug Levels): Enhance text for 'c' and 'x', update examples.
(Incompatibilities): Mention risk of parsing trace output.
* examples/null.m4: Enhance test.
* examples/null.err: Update expected output.
* NEWS: Mention these changes.
Reported by Akim Demaille in the autoconf TODO file in 2000.

(cherry picked from commit ec804cba9ceeef7ca863d163eeae3fca669ccd16)

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-05-09 06:12:25 -06:00
Eric Blake
7541b497e8 Improve OS/2+emx build.
* src/m4.h [__EMX__]: OS/2 does not have a Unix-compatible
system(3), no matter what other macros it pre-defined.
* doc/m4.texinfo (Mkstemp): Rework test to avoid globbing failure
on OS/2.
* src/builtin.c (predefined_tab): Ensure all possible system
identifiers are defined, not just the first; the testsuite will
catch if multiple identifiers mistakenly made it through.
* examples/null.m4 (esyscmd): Don't rely on printf to generate NUL
byte.
* examples/null.out (esyscmd): Check for esyscmd success.
* THANKS: Update.
Reported by Elbert Pol.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-04-11 10:05:33 -06:00
Eric Blake
4cc7916e4d Document join, in order to fix bug in m4wrap example.
* examples/join.m4: New file.
* examples/wraplifo2.m4: Likewise.
* examples/Makefile.am (EXTRA_DIST): Add new files.
* doc/m4.texinfo (Improved m4wrap): New node.
(Defn, Location): Enhance tests.
(Shift): Document the composit macro join.
(Incompatibilities): Move documentation of LIFO vs. FIFO...
(M4wrap): ...here, to match improved example.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-03-15 20:20:36 -06:00
Eric Blake
d59ecd1edf Stage 16: cache quotes and improve arg_print.
* src/m4.h (push_wrapup_init, push_wrapup_finish, quote_cache)
(func_print): New prototypes.
(arg_print): Adjust prototype.
* src/builtin.h (func_print): New function.
(define_user_macro): Slight cleanup.
(dump_args): Delete, no longer used.
(m4_errprint): Use arg_print.
(m4_m4wrap): Handle embedded NUL.
* src/debug.c (trace_pre): Use arg_print.
* src/input.c (cached_quote): New variable.
(push_wrapup): Split...
(push_wrapup_init, push_wrapup_finish): ...into these.
(input_print): Use arg_print.
(quote_cache): New function.
(pop_input, next_char_1, append_quote_token, set_quote_age):
Adjust users.
* src/macro.c (arg_text, make_argv_ref_token): Adjust users.
(arg_print): Add parameters.
* examples/null.m4: Test for NUL in m4wrap.
* examples/null.out: Update expected output.
* doc/m4.texinfo (Debug Levels): Test --arglength truncation.

(cherry picked from commit 44740d89961c48b712562dfc650dc0cb57898aa0)

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-21 06:57:06 -07:00
Eric Blake
702a3fe3e8 Add regression test for multi-character quote recursion.
* examples/foreach2.m4: Use $0 rather than spelling out name.
* examples/foreachq2.m4: Likewise.
* examples/forloop2.m4: Likewise.
* examples/hanoi.m4: Likewise.
* examples/trace.m4: Likewise.
* doc/m4.texinfo (Improved forloop): Document advantage of $0.
(Improved foreach): Adjust dump from file.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-16 15:17:08 -07:00
Eric Blake
7319157ccd Stage 15: return argv refs back to collect_arguments.
* src/m4.h (enum token_type): Add TOKEN_ARGV.
(struct token_chain): Add skip_last member to argv link.
(next_token): Update prototype.
* src/input.c (CHAR_ARGV): New placeholder input character.
(peek_input): Add parameter, to pass $@ at once.
(next_char_1, append_quote_token): Handle $@ inside quotes.
(init_argv_token): New function.
(push_token, match_input, next_token, peek_token, lex_debug):
Update callers.
* src/macro.c (expand_input, collect_arguments): Likewise.
(expand_argument): Handle incoming $@ token.
(arg_adjust_refcount, arg_token, arg_text, make_argv_ref_token):
Handle nested $@ refs.
* src/symtab.c (symtab_debug): Update caller.
* examples/null.m4: Document more tests that are needed.  Add
tests for NUL with divert, patsubst, and regexp.
* examples/null.out: Update for new tests.
* doc/m4.texinfo (Syntax): Add test for m4exit and NUL.
* checks/get-them (AWK): Give a default value.
* checks/check-them: Allow tests to invoke child processes with
same include path.  Perform message normalization on stderr.

(cherry picked from commit 1fecefc8b990254aa667a01d12c6c7a2d716df06)

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-02-16 06:36:45 -07:00
Eric Blake
e2b843f0ac Stage 9: share rather than copy single-arg refs.
* m4/gnulib-cache.m4: Import quote and memmem modules.
* src/m4.h (arg_scratch): New prototype.
* src/input.c (INPUT_INLINE_THRESHOLD): New define.
(push_token): Use it to inline short text, and save references to
longer text.
(input_init, next_token): Simplify obstack handling.
* src/macro.c (expand_argument): Likewise.
(expand_macro): Track scratch space.
(arg_scratch): New function.
(make_argv_ref): Use it.
(push_args): Likewise, and simplify comma handling, since most
separators are short enough to be inlined.
* src/builtin.c (builtin_init): Avoid cast.
(m4_errprint, m4_index): Transparently support NUL.
(m4_translit): Use scratch space, rather than leaking memory on
expansion stack.
* doc/m4.texinfo (Syntax): Add new test of embedded NUL.
* checks/get-them: Extract test that uses external files.
* checks/check-them: Run the new test.  Use unified diff if
possible, and force text mode when debugging NUL handling.
* examples/null.m4: New file.
* examples/null.out: Likewise.
* examples/null.err: Likewise.
* examples/Makefile.am (EXTRA_FILES): Distribute these files.
* .gitattributes: Treat new files as text, in spite of embedded
NUL.

(cherry picked from commit a6c94a314afa34958330b719d66c2d4e403a94af)

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-12-20 21:59:17 -07:00
Eric Blake
83e9a157eb Stage 5: add notion of quote age.
* src/input.c: Comment cleanups.
(current_quote_age): New global variable.
(set_quote_age): New helper function.
(input_init, set_word_regexp): Use it.
(set_quotes, set_comment): Likewise, and detect no-op changes.
(quote_age, safe_quotes): New functions.
(next_token): Track quote age.
* src/m4.h (struct token_data): Add quote_age member.
(TOKEN_DATA_QUOTE_AGE, quote_age, safe_quotes): New prototypes.
* src/macro.c (struct macro_arguments): Add quote_age member.
(expand_token): Alter signature and track quote age.
(expand_input, expand_argument): All callers changed.
(collect_arguments, make_argv_ref): Track quote age.
(arg_text, arg_len, arg_func): Detect type mismatch.
* doc/m4.texinfo (Ifelse, Changequote): Add more tests.
(Incompatibilities): Fix typo.
* examples/wraplifo.m4: New file.
* examples/Makefile.am (EXTRA_DIST): Distribute it.

(cherry picked from commit 8b5b3b7a74f452fed795c063965966934a68755d)

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-12-07 07:07:36 -07:00
Eric Blake
86f05e7468 Test more corner cases.
* doc/m4.texinfo (Changecom, Pseudo Arguments): Beef up tests.
(Improved foreach): Document alternate foreachq style.
* examples/foreachq3.m4: New file.
* examples/loop.m4: New file.
* examples/Makefile.am (EXTRA_DIST): Distribute them.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-31 09:58:43 -06:00
Ralf Wildenhues
ca29cce1e8 Fix 'make distcheck'.
* examples/Makefile.am (EXTRA_DIST): Add capitalize2.m4.
2007-10-24 15:43:51 -06:00
Eric Blake
3be7d5f421 Document quoting pitfalls in capitalize.
* doc/m4.texinfo (Patsubst): Use the examples directory.  Also
document shortfall.
(Improved capitalize): New node.
* examples/capitalize.m4: Update to match manual.
* examples/capitalize2.m4: New file.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-10-02 15:58:28 -06:00
Eric Blake
e3b90fb678 Create .gitignore alongside .cvsignore.
* bootstrap (LC_ALL): Set up front.
(version control) Borrow idea from head, to avoid churn in
m4/.*ignore files modified by gnulib-tool.

Signed-off-by: Eric Blake <ebb9@byu.net>
2007-09-24 12:01:18 -06:00
Eric Blake
486fb4ada1 Normalize all GPL license notices.
* GNUmakefile: Update license wording.
* Makefile.am: Likewise.
* Makefile.maint: Likewise.
* bootstrap: Likewise.
* commit: Likewise.
* configure.ac: Likewise.
* checks/Makefile.in: Likewise.
* doc/Makefile.am: Likewise.
* examples/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
* src/builtin.c: Likewise.
* src/debug.c: Likewise.
* src/eval.c: Likewise.
* src/format.c: Likewise.
* src/freeze.c: Likewise.
* src/input.c: Likewise.
* src/m4.c: Likewise.
* src/m4.h: Likewise.
* src/macro.c: Likewise.
* src/output.c: Likewise.
* src/path.c: Likewise.
* src/stackovf.c: Likewise.
* src/symtab.c: Likewise.
2007-09-21 15:51:14 -06:00
Eric Blake
8303375a81 Upgrade to GPL version 3 or later.
* bootstrap: Pick up GPLv3.
* m4/gnulib-cache.m4: Augment with 'gnulib-tool
--local-dir=. --import gpl-3.0'.
* doc/m4.texinfo (Copying This Package): New appendix.
* NEWS: Mention this change.
* README: Mention why some files still claim to be version 2.
* version-etc.c.diff: New file, to make sure --version claims
correct GPL version.  Temporary until gnulib makes move.
* gpl-3.0.texi.diff: New file, to allow inclusion of GPLv3 as
appendix, rather than section, of the manual.
* GNUmakefile: Update to new license.
* Makefile.am: Likewise.
* Makefile.maint: Likewise.
* commit: Likewise.
* configure.ac: Likewise.
* checks/Makefile.in: Likewise.
* doc/Makefile.am: Likewise.
* examples/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
* src/builtin.c: Likewise.
* src/debug.c: Likewise.
* src/eval.c: Likewise.
* src/freeze.c: Likewise.
* src/input.c: Likewise.
* src/m4.c: Likewise.
* src/m4.h: Likewise.
* src/macro.c: Likewise.
* src/output.c:
2007-09-21 15:49:03 -06:00
Eric Blake
9cc247ef5e * examples/Makefile.am (EXTRA_DIST): Distribute recently-added
files.
2007-09-21 15:27:46 -06:00
Eric Blake
0712f6f8cb * doc/m4.texinfo: Trailing '@comment' doesn't format nicely in
TeX, so recognize '@w{ }' instead.  Likewise, @code{_name} at the
end of a TeX line splits incorrectly.
(Foreach, Improved foreach): Write these sections, borrowing ideas
from CVS head and from m4sugar.
* checks/get-them: Accomodate new way to show trailing space in
examples.
* examples/foreach.m4: Make usable in documentation.
* examples/foreachq.m4: New file.
* examples/foreachq2.m4: New file.
* examples/foreach2.m4: New file.
* NEWS: Document the documentation updates.
2007-09-21 15:27:41 -06:00
Eric Blake
37c536d08c * examples/forloop.m4: Simplify.
* examples/forloop2.m4: New file.
* examples/quote.m4: New file.
* doc/m4.texinfo (Loops): Rename to...
(Shift): ...this node.
(Forloop, Foreach, Improved forloop, Improved foreach): New
nodes.
2007-09-21 15:27:40 -06:00
Eric Blake
dab6fefe20 * ChangeLog: Add copyright.
* AUTHORS: Likewise.
* BACKLOG: Likewise.
* README: Likewise.
* THANKS: Likewise.
* TODO: Likewise.
* examples/COPYING: New file, add copyright for all the examples.
* checks/get-them: Put copyright on testsuite files.
2007-09-21 15:05:59 -06:00
Eric Blake
2de4dd5879 Fix 'make check' in VPATH build. All files included by testsuite
now live in a single directory.  Use forloop.m4 in testsuite.
* checks/incl.m4, checks/foo, checks/wrapfifo.m4: Move from
here...
* examples/incl.m4, examples/foo, examples/wrapfifo.m4: ...to
here.
* checks/Makefile.in (DISTFILES): Don't distribute moved files.
* examples/Makefile.am (EXTRA_DIST): Distribute new files.
* checks/check-them: Avoid s/// when filename is in pattern.
* examples/forloop.m4: Fix to match documentation.
* doc/m4.texinfo (Include, Undivert, Incompatibilities): Reflect
new locations.
(Loops, Format): Actually use forloop.m4 in tests.
2007-09-21 15:02:24 -06:00
Eric Blake
b3c92c93d1 Ignore more generated files 2007-09-21 14:37:41 -06:00
Eric Blake
65adb311ce * doc/m4.texinfo (Maketemp): Work even when running 'make check'
in read-only dir.
Use automake.
* Makefile.am: New file.
* doc/Makefile.am: Ditto.
* examples/Makefile.am: Ditto.
* lib/Makefile.am: Ditto.
* src/Makefile.am: Ditto.
* acinclude.m4: New file, renamed from aclocal.m4.
* configure.ac (AM_INIT_AUTOMAKE): Invoke new macro.
(AC_ARG_PROGRAM): Now redundant.
(STACKOVF): Turn into automake conditional.
(AC_CONFIG_COMMANDS): stamp-h is a command, not a file.
* checks/Makefile.in: Converting this dir to automake was not
trivial; for now, just add missing targets demanded by top-level.
* INSTALL: Remove files that are now generated from CVS.
* Makefile.in: Ditto.
* aclocal.m4: Ditto.
* install-sh: Ditto.
* mkinstalldirs: Ditto.
* doc/Makefile.in: Ditto.
* doc/texinfo.tex: Ditto.
* examples/Makefile.in: Ditto.
* lib/Makefile.in: Ditto.
* src/Makefile.in: Ditto.
2007-09-21 14:37:41 -06:00
Eric Blake
e35e8bf751 * src/m4.c (main): Bump copyright year.
* Makefile.in (datarootdir): Define, for autoconf 2.59c.
* doc/Makefile.in (datarootdir): Likewise.
2007-09-21 14:25:43 -06:00
Gary V. Vaughan
7b9f0c38ab Also, some of the files here were never updated from the previous
'675 Mass Ave, Cambridge, MA 02139', so changed those to the
'51 Franklin Street, Fifth Floor, MA 02110-1301' address too.
2007-09-21 14:21:13 -06:00
Gary V. Vaughan
1e35400cf2 Modernise the configury a little to prevent spurious errors from
Autoconf-2.59's autoreconf:

* config.h.in: Renamed to...
* config-h.in: ...this to better support DOS 8.3 file systems.
* acconfig.h: Removed.
* configure.in: Renamed to...
* configure.ac: ...this, and AC_DEFINE used to declare config.h
entry comments.  Slight reorganisation and reformatting.
* aclocal.m4: Use third argument to AC_DEFINE to declare config.h
entry comments.
(AC_INIT): Use a modern 3 argument call.
* Makefile.in, checks/Makefile.in, doc/Makefile.in,
examples/Makefile.in, lib/Makefile.in, src/Makefile.in:
s/PRODUCT/PACKAGE/g.
* Makefile.in (DISTFILES): Removed acconfig.h, configure.in,
config.h.in.  Added configure.ac, config-h.in.
(stamp-h.in): Removed acconfig.h from dependencies.
(configure): Depends on configure.ac, not configure.in.
* doc/Makefile.in (stamp-vti): Ditto.
* src/freeze.c (produce_frozen_state), src/m4.c (main): Adjust for
difference between PRODUCT="m4" and PACKAGE="GNU M4".
* configure: Regenerated.
2007-09-21 13:27:21 -06:00
Gary V. Vaughan
93ad4c046f * Release 1.4.1.
* configure.in (VERSION): Bump to 1.4.1.
* NEWS: Describe 1.4.1's changes.

* aclocal.m4 (fp_PROG_CC_STDC): Use AC_DEFUN, not define, to
pacify Autoconf 2.59.

* doc/m4.texinfo: Insert commas after @xref's that lack them,
to pacify Texinfo 4.7.
* doc/Makefile.in (info): Remove info-1, info-2, info-3.

* src/m4.h, src/debug.c: Use #ifdef __STDC__, not #if __STDC__, to
pacify Sun C compilers.

* src/symtab.c (lookup_symbol): Fix an uninitialized-variable
botch.

* examples/stackovf.sh: Use tempfile if available.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=92629
* src/output.c (m4_insert_file): Do not mix buffered and
unbuffered I/O, as this breaks on the Hurd.  (trivial change)

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=84451
* src/m4.c (main): Fix format vulnerabilities.  (trivial change)

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=84416
* doc/m4.texinfo (Maketemp): Change maketemp to refer to a new,
empty file rather than to a nonexistent file.  This closes a common
security hole.
* src/builtin.c (m4_maketemp): Implement the above, by using
mkstemp rather than mktemp.  (trivial change)

* src/builtin.c (expand_ranges): Added break after trailing dash.
This caused misbehaviors on some systems.
2007-09-21 08:21:45 -06:00
Jeff Bailey
f82834e365 Import of m4-1.4 2007-09-21 07:04:48 -06:00
Jeff Bailey
bd11691d65 Initial revision 2000-02-17 03:03:19 +00:00