summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* maint: run update-copyright for 2014.Gary V. Vaughan2014-11-204-6/+6
| | | | | | Add 2014 to copyright message in all files. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
* modules: huge simplification of module loading without libltdl.Gary V. Vaughan2013-09-211-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Libltdl is huge and slow, and carrying the weight of support for decades old systems. We can do much better using POSIX dlopen and dlsym directly, simplifying and speeding up as we do so. * configure.ac (LT_CONFIG_LTDL_DIR, LTDL_INIT): Remove. (M4_DEFAULT_PRELOAD): Set to ""; we lost preload support along with removing libltdl. * Makefile.am: Don't include ltdl/Makefile.inc. (AM_CPPFLAGS): Manually add current directory to include search paths. * m4/m4private.h (includes): Remove ltdl.h. (INIT_SYMBOL, m4__module_init): Remove. (struct m4_module): Change handle type from lt_dlhandle to void *. * m4/m4module.h (M4INIT_HANDLER): Remove. * m4/module.c (includes): Add dlfcn.h. (m4__module_interface, iface_id, m4__module_init, module_dlerror): Remove. (m4__module_open): Drastically simplified without all the libltdl setup and interface id twiddling. Just call dlopen to get a native handle, and the dlsym to get the init function. (m4_module_import): Similarly wrt dlsym. * m4/path.c (FILE_SUFFIXES): Replace .la and LT_MODULE_EXT with hardcoded ".so". (m4_load_filename): Likewise. * modules/gnu.c: Remove libltdl preprocessor symbol renaming, and use "include_<modulename>" as the single entry point function. * modules/import.c, modules/m4.c, modules/modtest.c, modules/mpeval.c, modules/shadow.c, modules/stdlib.c, modules/time.c, modules/traditional.c: Likewise. * main.c (main): Remove calls to m4__module_init and LTDL_SET_PRELOADED_SYMBOLS. * tests/m4.in: Make sure we always have the modules/.libs and tests/.libs directories at the front of M4PATH so that the tests will find the modules they need to include. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
* modules: simplify module lookup by name.Gary V. Vaughan2013-09-201-2/+2
| | | | | | | | | | | | | * m4/m4private.h (m4:namemap): New field for hash table to lookup module structures by name string. * m4/m4.c (hashfn): Hash function for plain strings. (m4_create): Initialise namemap field to a hash table using hashfn for inserting and looking up keys. * m4/module.c (m4__module_find): Replace the fussy libltdl twiddling with a hash lookup in m4:namemap. Add a new context parameter. Adjust all callers. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
* modules: store loaded modules in context struct.Gary V. Vaughan2013-09-201-7/+7
| | | | | | | | | | | | * m4/m4private.h (struct m4_module): Add a next pointer. (struct m4): Add a module list pointer. * m4/module.c (m4__module_open): Initialise the next pointer and update the list head when a new module is successfully opened. (m4_module_next): Replace the ugly libltdl twiddling with a straight forward module list traversal one-liner! Add a context parameter. Adjust all callers. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
* modules: remove support for module unload and refcount.Gary V. Vaughan2013-09-202-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Module management is horrifically more complex than it needs to be for the simple purpose of providing a means to implement new builtins using C. Fussing about reference counting or needing to maintain and test a facility to unload modules is an easy 600 lines to cut as a start at simplification. * src/main.c (main): Don't call m4__module_exit to unload all modules just prior to exiting the application. * m4/m4private.h (FINISH_SYMBOL, m4_module:refcount) (m4__module_exit, m4_module_refcount): Remove. (m4__module_next): Rename from this... * m4/m4module.h (m4_module_next): ...to this. Adjust all callers. (M4FINISH_HANDLER, m4_module_finish_func, m4_module_makeresident) (m4_module_refcount, m4_module_unload, m4_module_exit): Remove. * m4/m4module.c (m4__module_next): Rename from this... (m4_module_next): ...to this. (module_remove, m4_module_makeresident, m4_module_unload) (m4_module_exit, m4_module_refcount): Remove. * modules/load.c: Remove. (m4modules): Move from here... * modules/gnu.c (m4modules): ...to here. Update all callers. (M4FINISH_HANDLER(gnu)): Remove. * modules/m4.c (M4INIT_HANDLER(m4)): Remove. * modules/modtest.c (M4FINISH_HANDLER(modtest)): Remove. * modules/shadow.c (M4INIT_HANDLER(shadow)): Rewrite to work without refcount. * Makefile.am (pkglib_LTLIBRARIES): Remove modules/load.la. (modules_load_la_LDFLAGS, modules_load_la_LIBADD): Remove. * tests/modules.at: Remove references to load module, and tests of unload builtin. * tests/options.at: Remove obsolute finish hook and module unload trace output. * doc/m4.texi (Unload, Refcount): Remove. (M4modules): Change module reference from load to gnu. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
* maint: either fix or disable failing syntax-check rules.Gary V. Vaughan2013-09-181-2/+2
| | | | | | | | | | | | | | | | | * cfg.mk (local-checks-to-skip): Skip bindtextdomain until I understand it! (old_NEWS_hash): Update. (exclude_file_name_regexp--sc_prohibit_always_true_header_tests) (exclude_file_name_regexp--sc_prohibit_strncpy) (exclude_file_name_regexp--update_copyright): Exclude failing files. * doc/Makefile.am: Remove trailing blank line. * m4/path.c: Remove trailing whitespace. * doc/m4.texi: Fix some errors flagged by syntax checks. * m4/input.c, m4/macro.c, m4/output.c, m4/stackovf.c: Don't use `main ()', which confuses syntax-checks. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
* maint: prefer STREQ/STRNEQ to strcmp contortions.Gary V. Vaughan2013-09-181-2/+2
| | | | | | | | * m4/m4private (STRNEQ): New macro. * m4/path.c (m4_load_filename): Use it. * src/freeze.c (produce_frozen_state): Likewise. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
* maint: update copyright year.Gary V. Vaughan2013-09-184-9/+8
| | | | | | | * all files: Run 'make update-copyright' to add 2013 to list of copyright years. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
* Factor load functionality into include builtin.Gary V. Vaughan2013-09-162-84/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/module.c (m4__module_open): Instead of calling lt_dlopenext right away, use the preload hint first incase path searching has been disabled by POSIXLY_CORRECT. Otherwise fallback to a manual path search to override libltdl's algorithm. * m4/m4module.h: Adjust. * m4/path.c (FILE_SUFFIXES): Order to try suffixes in our path search algorithm. (NO_SUFFIXES): Alternatively, how to to search a path without adding file suffixes. (m4_path_search): Add a new suffixes parameter defaulting to NO_SUFFIXES. Adjust all callers. (m4_load_filename): New generic load function that tries to open a matched file first as a module, and if that fails fall back to a (possibly frozen) m4 input file. (m4_fopen): New function with close on exec functionality. * modules/m4.c (include): Use m4_load_filename to with modules or m4 files. Adjust all callers. * modules/load.c (load): Removed this builtin. * src/main.c: Remove Dynamic loading features section, and M4MODPATH support. (long_options): Remove "load-module", "unload-module" and "module-directory" options. (OPTSTRING): Remove 'M' and 'm' options. (process_file): Use m4_load_filename to support module names on the command line. * tests/generate.awk (new_test): Output AT_CHECK_DYNAMIC_MODULE and AT_CHECK_GMP without relying on the (deleted!) -m option. * Makefile.am (TESTS_ENVIRONMENT): No need for abs_top_builddir any more. * doc/m4.texinfo: Update examples. (Dynamic loading features, Load): Removed. (Command line files): Describe how non-option arguments are treated to try to find a matching macro file or dso. (Include): Describe additional dso loading features if a suitable text file cannot be found. (Modules): Updated. * tests/builtins.at, tests/m4.in, tests/modules.at, tests/options.at, others.at: Adjust test cases and calling conventions to new semantics. * modules/modtest.m4, modules/shadow.m4, modules/stdlib.m4, modules/time.m4, modules/time2.m4: Move from here... * examples/modtest.m4, examples/shadow.m4, examples/stdlib.m4, examples/time.m4, examples/time2.m4: ...to here, to prevent a namespace clash with similarly named loadable modules in the modules directory. * NEWS: Updated. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
* Address remaining 'make syntax-check' findings.Eric Blake2010-01-082-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | * gnulib: Update to latest. * Makefile.am (tests/package.m4): Avoid @@ substitution. (src_m4_LDADD): Link with libiconv. * m4/m4private.h (STREQ): New macro. * m4/resyntax.c (m4_regexp_syntax_encode): Use it. * src/main.c (process_file): Likewise. (includes): Drop unused header. * m4/macro.c (m4_arg_equal): Adjust comment. * m4/syntax.c: Likewise. * m4/system_.h: Avoid useless preprocessor parenthesis. * ltdl/m4/stackovf.m4 (M4_SYS_STACKOVF): Likewise. * src/stackovf.c: Likewise. (setup_stackovf_trap): Mark diagnostics. * modules/mpeval.c (includes): Move quotearg.h inclusion... * modules/evalparse.c (includes): ...to where it is used. * cfg.mk (local-checks-to-skip): Exempt tests that cause spurious failures, but first fix what they were intended to detect. (_makefile_at_at_check_exceptions): Allow an exception. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit 2f6096389e2047a01618419af3f4471735444520)
* Address 'make sc_error_message_uppercase' failures.Eric Blake2010-01-071-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | * m4/output.c (m4_freeze_diversions): Silence false positive. * src/main.c (main): Use 'warning', not 'Warning', in messages. * m4/utility.c (m4_verror_at_line): Likewise. * doc/m4.texinfo (Operation modes, Macro Arguments, Undefine) (Defn, Pushdef, Indir, Builtin, Ifdef, Ifelse, Dumpdef, Trace) (Debuglen, Debugfile, Dnl, Changeresyntax, Standard Modules) (Index macro, Regexp, Substr, Translit, Patsubst, Format, Incr) (Eval, Mkstemp, Syncoutput, Improved forloop) (Improved fatal_error): Adjust expected output. * tests/builtins.at (define, mkdtemp, mkstemp): Likewise. * tests/freeze.at (loading format 1, reloading unknown builtin): Likewise. * tests/macros.at (Arity and defn, 'Arity, defn, and freeze') (pushdef/popdef): Likewise. * tests/null.err: Likewise. * tests/options.at (deprecated options, POSIXLY_CORRECT) (--fatal-warnings, --regexp-syntax, --syncoutput): Likewise. * tests/others.at (nul character, stdin seekable): Likewise. * tests/modules.at (AT_CHECK_M4_MODTEST, modules: text): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* More whitespace cleanup.Eric Blake2010-01-073-130/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * HACKING: Nuke trailing whitespace. * examples/WWW/Makefile: Likewise. * examples/WWW/_footer.htm: Likewise. * examples/WWW/_header.htm: Likewise. * examples/WWW/m4lib/bugs.m4: Likewise. * examples/WWW/m4lib/html.m4: Likewise. * examples/WWW/m4lib/menu.m4: Likewise. * examples/WWW/m4lib/visions.m4: Likewise. * examples/esyscmd.m4: Likewise. * examples/fstab.m4: Avoid space-tab. * examples/patsubst.m4: Likewise. * NEWS: Prefer space over tab for alignment. * THANKS: Likewise. * TODO: Likewise. * bootstrap: Likewise. * configure.ac: Likewise. * ltdl/m4/stackovf.m4: Likewise. * m4/hash.c: Likewise. * m4/hash.h: Likewise. * m4/input.c: Likewise. * m4/m4.c: Likewise. * m4/m4module.h: Likewise. * m4/m4private.h: Likewise. * m4/macro.c: Likewise. * m4/module.c: Likewise. * m4/output.c: Likewise. * m4/path.c: Likewise. * m4/resyntax.c: Likewise. * m4/symtab.c: Likewise. * m4/syntax.c: Likewise. * m4/system_.h: Likewise. * modules/evalparse.c: Likewise. * modules/format.c: Likewise. * modules/gnu.c: Likewise. * modules/import.c: Likewise. * modules/load.c: Likewise. * modules/m4.c: Likewise. * modules/m4.h: Likewise. * modules/modtest.c: Likewise. * modules/mpeval.c: Likewise. * modules/perl.c: Likewise. * modules/shadow.c: Likewise. * modules/stdlib.c: Likewise. * modules/time.c: Likewise. * modules/traditional.c: Likewise. * src/freeze.c: Likewise. * src/main.c: Likewise. * src/stackovf.c: Likewise. * tests/stackovf.test: Likewise. * doc/STYLE: Mention the change. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit b30b61aa1be7659c155272135fa17a8d7528f80e)
* Switch to indentation by space, not tab.Eric Blake2010-01-054-911/+911
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that gnulib has converted and git has better support for ignoring whitespace differences across this commit, we might as well be consistent with other GNU projects. Done with: t=$'\t' git ls-files \ | grep -vE '(^|/)(.*akefile|ChangeLog|HACKING|.*-aux/.*)|\.(am|mk)$' \ | xargs grep -lE "^ *$t" \ | xargs perl -MText::Tabs -ni -le \ '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_' followed by tweaks to pass 'make check' again. * .gitmodules: Convert leading tabs to spaces. * TODO: Likewise. * bootstrap: Likewise. * configure.ac: Likewise. * examples/WWW/m4lib/html.m4: Likewise. * examples/WWW/m4lib/layout.m4: Likewise. * examples/WWW/m4lib/menu.m4: Likewise. * ltdl/m4/debug.m4: Likewise. * ltdl/m4/gmp.m4: Likewise. * ltdl/m4/m4-obstack.m4: Likewise. * ltdl/m4/stackovf.m4: Likewise. * m4/builtin.c: Likewise. * m4/debug.c: Likewise. * m4/hash.c: Likewise. * m4/hash.h: Likewise. * m4/input.c: Likewise. * m4/m4.c: Likewise. * m4/m4module.h: Likewise. * m4/m4private.h: Likewise. * m4/macro.c: Likewise. * m4/module.c: Likewise. * m4/output.c: Likewise. * m4/path.c: Likewise. * m4/resyntax.c: Likewise. * m4/symtab.c: Likewise. * m4/syntax.c: Likewise. * m4/utility.c: Likewise. * modules/evalparse.c: Likewise. * modules/format.c: Likewise. * modules/gnu.c: Likewise. * modules/load.c: Likewise. * modules/m4.c: Likewise. * modules/m4.h: Likewise. * modules/mpeval.c: Likewise. * modules/perl.c: Likewise. * modules/stdlib.c: Likewise. * modules/time.c: Likewise. * src/freeze.c: Likewise. * src/m4.h: Likewise. * src/main.c: Likewise. * src/stackovf.c: Likewise. * tests/builtins.at: Likewise. * tests/freeze.at: Likewise. * tests/generate.awk: Likewise. * tests/modules.at: Likewise. * tests/others.at: Likewise. * tests/stackovf.test: Likewise. * tests/testsuite.at: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit 180b7d19bf95d2abb21bca587a0684eca69679ad)
* Update copyright year.Eric Blake2010-01-054-5/+7
| | | | | | | | All files impacted, via 'make update-copyright'. Additionally: * .gitignore: Ignore backup files. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit 5f42c4dabb6858601abce7b38ca78f4c3069f301)
* Drop .cvsignore and redundant .gitignore files.Eric Blake2009-06-152-28/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * .cvsignore: Delete. We are moving further away from CVS. * build-aux/.cvsignore: Likewise. * doc/.cvsignore: Likewise. * examples/.cvsignore: Likewise. * ltdl/.cvsignore: Likewise. * m4/.cvsignore: Likewise. * modules/.cvsignore: Likewise. * po/.cvsignore: Likewise. * src/.cvsignore: Likewise. * tests/.cvsignore: Likewise. * .gitignore: Consolidate from other files. * build-aux/.gitignore: Delete, now that it is consolidated. * doc/.gitignore: Likewise. * examples/.gitignore: Likewise. * ltdl/.gitignore: Likewise. * m4/.gitignore: Likewise. * modules/.gitignore: Likewise. * po/.gitignore: Likewise. * src/.gitignore: Likewise. * tests/.gitignore: Likewise. * bootstrap: Simplify accordingly. Sync gnulib tree prior to libtoolize, to avoid libtool overwriting config.guess. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit 76b384f1d84225d0412d58999d2becc8936dd645)
* Stage 28c: Warn on embedded NUL in remaining cases.Eric Blake2009-02-112-15/+44
| | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_debug_decode, m4_parse_truth_arg): Add parameter. * m4/macro.c (m4_macro_call): Improve diagnostic. * modules/m4.c (defn): Likewise. * m4/debug.c (m4_debug_decode): Handle embedded NUL. * m4/utility.c (m4_parse_truth_arg): Likewise. * modules/format.c (arg_int, arg_long, arg_double): Likewise. (arg_string): New function. (ARG_INT, ARG_LONG, ARG_STR, ARG_DOUBLE): Update callers. * src/main.c (main): Likewise. * src/freeze.c (reload_frozen_state): Likewise. * modules/gnu.c (debugmode, syncoutput): Likewise. * tests/options.at (--regexp-syntax): Adjust test. * tests/freeze.at (reloading nul): Likewise. * tests/null.m4: Likewise. * tests/null.out: Likewise. * tests/null.err: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Add URLs to --help output.Eric Blake2009-01-241-8/+2
| | | | | | | * src/main.c (usage): Use enhanced version-etc features. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit d499df171ddb2161d1e75055009a9b3d18131591)
* Add debugmode(o) to control dumpdef output location.Eric Blake2008-12-232-1/+4
| | | | | | | | | | | | | | | | | * m4/m4module.h (M4_DEBUG_TRACE_OUTPUT_DUMPDEF): New enumerator. (M4_DEBUG_TRACE_VERBOSE): Update. * m4/debug.c (m4_debug_decode): Support new debug option. * src/freeze.c (produce_debugmode_state): Likewise. * modules/m4.c (dumpdef): When set, force dumpdef to stderr rather than the debug file. * src/main.c (usage): Document it. * doc/m4.texinfo (Debugmode, Dumpdef, Debugging options) (Debugfile): Likewise. * NEWS: Likewise. Based on an autoconf bug report by Paolo Bonzini. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit df6bfeeaac6bdc1ef8e5406c6ac051af2c10d0d8)
* Make --debugfile argument optional.Eric Blake2008-12-231-8/+23
| | | | | | | | | | | | | | * src/main.c (long_options): Make the argument optional, to allow setting debug file back to stderr. (main): Make --debugfile order-dependent. (usage): Document this. * doc/m4.texinfo (Debugging options): Likewise. * NEWS: Likewise. * tests/options.at (--debugfile): Enhance test. (--safer): Adjust to new semantics. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit c59c67993219ec04965b1347b44a7e3d09ff425c)
* Stage 27: Allow embedded NUL in text processing macros.Eric Blake2008-12-021-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | * modules/m4.c (m4_expand_ranges): Don't append extra bytes. (translit): Manage NUL bytes. * modules/format.c (format): Likewise. * modules/gnu.c (substitute, regexp_substitute): Likewise. (m4_resyntax_encode_safe): Add parameter. (regexp, patsubst, renamesyms): Update callers. (regexp_compile): Adjust error message. * modules/evalparse.c (m4_evaluate): Use consistent message. (end_text): New variable. (eval_init_lex): Add parameter. (eval_lex): Detect embedded NUL. * src/freeze.c (reload_frozen_state): Likewise. * doc/m4.texinfo (Format): Update to cover new behavior. (Eval): Mention that result is unquoted. * tests/freeze.at (reloading nul): Enhance test. * tests/null.m4: Likewise. * tests/null.err: Update expected output. * tests/null.out: Likewise. * tests/options.at (--regexp-syntax): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Tweak error message on command line failure.Eric Blake2008-09-252-9/+14
| | | | | | | | | | | | | | | | | | * m4/m4private.h (includes): Use "quotearg.h". * src/main.c (process_file, main): Use nicer quotes for file name in error messages. * m4/input.c (file_clean, m4_push_file): Likewise. * m4/module.c (m4__module_open): Likewise. * src/freeze.c (produce_frozen_state, reload_frozen_state): Likewise. * modules/gnu.c (debugfile): Likewise. * modules/m4.c (undivert, include): Likewise. * tests/others.at (directory, stdin closed): Update tests. * tests/options.at (file names, --debugmode): Likewise. * doc/m4.texinfo (Debugmode): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit 5116db0fcd37e4480062b4819dca17a98a7890d7)
* Typos in source code comments.Ralf Wildenhues2008-09-011-1/+1
| | | | | | | | * modules/m4.c: Fix typos in comments. * m4/input.c: Likewise. * src/main.c: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Allow debugmode control over whether defn(undef) warns.Eric Blake2008-08-232-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * ltdl/m4/gnulib-cache.m4: Import verify module. * m4/m4module.h (M4_DEBUG_TRACE_DEREF, M4_DEBUG_TRACE_INITIAL): New values. (M4_DEBUG_TRACE_VERBOSE, M4_DEBUG_TRACE_DEFAULT): Adjust. * m4/m4.c (m4_create): Start with debugmode = d. * src/main.c (usage): Mention this. (main): Let -E impact debug mode. * m4/utility.c (m4_symbol_value_lookup): Squelch undefined warning if flag is clear. * modules/gnu.c (builtin, inder): Likewise. * m4/debug.c (m4_debug_decode): Parse new mode. * src/freeze.c (produce_debugmode_state): Accomodate new mode. * doc/m4.texinfo (Debugging options): Mention change in the default behavior. (Debugmode): Mention new flag d. (Operation modes): Mention interaction with -E. (Undefine, Defn, Pushdef, Indir, Builtin, Dumpdef): Document and test its effect. * tests/options.at (--debugmode): Update tests. * tests/freeze.at (reloading debugmode): Likewise. * NEWS: Document this. Reported by Ralf Wildenhues; without this patch, M4 1.6+ would be incompatible with Autoconf 2.62. Signed-off-by: Eric Blake <ebb9@byu.net>
* Improve --debugmode behavior.Eric Blake2008-08-222-26/+14
| | | | | | | | | | | | | * m4/m4module.h (m4_debug_decode): Simplify interface. * m4/debug.c (m4_debug_decode): Remove parameter, and handle setting the new value. * modules/gnu.c (debugmode): Adjust caller. * src/freeze.c (reload_frozen_state): Likewise. * src/main.c (main): Likewise. (usage): Fix default for --debug. * doc/m4.texinfo (Debugging options): Add an example. Signed-off-by: Eric Blake <ebb9@byu.net>
* Remove deprecated -N option; fixes a regression from 2006-09-14.Eric Blake2008-08-181-11/+1
| | | | | | | | | | | * src/main.c (DIVERSIONS_OPTION): Delete. (long_options, OPTSTRING, main): Remove -N/--diversions option. * doc/m4.texinfo (Limits control): Remove it from the manual. * NEWS: Mention that it is gone. * tests/options.at (deprecated options): Update test. Signed-off-by: Eric Blake <ebb9@byu.net> (cherry picked from commit b8829779ba82826040f16fe78420f0e5a2fe881e)
* Stage 26: Allow embedded NUL in macro definitions.Eric Blake2008-08-031-2/+2
| | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_arg_len): Add parameter. (M4ARGLEN): Provide default for the parameter. * m4/m4private.h (includes): Share xmemdup0.h among all libm4 files. * m4/macro.c (m4_arg_len): Fail if builtins are not flattened. * m4/syntax.c (includes): Rely on m4private.h for xmemdup0. * m4/symtab.c (includes): Likewise. (m4_symbol_value_copy): Use xmemdup0. * m4/module.c (install_macro_table): Likewise. * src/freeze.c (reload_frozen_state): Likewise. * tests/freeze.at (reloading nul): Enhance test. * tests/null.m4: Likewise. * tests/null.err: Update expected output. * tests/null.out: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 25b: Handle embedded NUL in changesyntax and friends.Eric Blake2008-06-181-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_set_quotes, m4_set_comment, m4_set_syntax): Add parameter. (m4_reset_syntax): New prototype. * m4/syntax.c (add_syntax_set, subtract_syntax_set) (set_syntax_set, m4_set_quotes, m4_set_comment): Add parameter, to handle embedded NUL. (m4_set_syntax): Likewise. Also, split code to reset the table... (m4_reset_syntax): ...into a new function. (m4_syntax_create): Adjust callers. * m4/input.c (match_input, MATCH): Add parameter. (m4__next_token, m4__next_token_is_open): Adjust callers. * modules/m4.h (m4_expand_ranges_func): Add parameter. * modules/m4.c (dumpdef): Handle NUL in dumped quotes. (changequote, changecom, translit, m4_expand_ranges): Track delimiter length. * modules/gnu.c (changesyntax): Handle embedded NUL. * src/freeze.c (reload_frozen_state): Adjust callers. * tests/freeze.at (reloading nul): Enhance test. * tests/null.m4: Likewise. * tests/null.out: Update expected output. * tests/null.err: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 24b: Allow embedded NUL in macro names.Eric Blake2008-06-022-34/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_symtab_apply_func, m4_symbol_lookup) (m4_symbol_pushdef, m4_symbol_define, m4_symbol_popdef) (m4_symbol_rename, m4_symbol_delete): Add length parameter. (m4_string): New type. * ltdl/m4/gnulib-cache.m4: Import xmemdup0 module. * m4/hash.c (m4_hash_string_hash, m4_hash_string_cmp): Account for length. * m4/symtab.c (m4_symtab_delete, m4_symtab_apply, symtab_fetch) (m4__symtab_remove_module_references, symbol_destroy_CB) (m4_symbol_lookup, m4_symbol_pushdef, m4_symbol_define) (m4_symbol_popdef, m4_symbol_rename, m4_set_symbol_name_traced) (m4_symbol_delete): Likewise. * modules/m4.h (struct m4_dump_symbol_data): Adjust type to allow passing length. * m4/macro.c (expand_token): Adjust all callers. * m4/module.c (install_builtin_table, install_macro_table): Likewise. * m4/utility.c (m4_symbol_value_lookup): Likewise. * modules/gnu.c (indir, renamesyms, m4symbols): Likewise. * modules/m4.c (define, undefine, pushdef, popdef) (dumpdef_cmp_CB, dump_symbol_CB, m4_dump_symbols, dumpdef) (traceon, traceoff): Likewise. * src/main.c (main): Likewise. * src/freeze.c (dump_symbol_CB, reload_frozen_state): Likewise. * tests/freeze.at (reloading nul): Augment test. * tests/null.out: Adjust expected output. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 24a: Use full call context in error reporting.Eric Blake2008-06-021-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_error, m4_warn): Change parameter type. (m4_error_at_line, m4_warn_at_line): Delete. (m4_debug_set_output, m4_skip_line, m4_bad_argc, m4_numeric_arg) (m4_parse_truth_arg, m4_symbol_value_lookup): Adjust all clients. * m4/m4private.h (m4__next_token): Likewise. * m4/utility.c (m4_verror_at_line): Alter parameter, and use caller's location if caller is provided. (m4_error, m4_warn): Change parameter type. (m4_error_at_line, m4_warn_at_line): Delete. (m4_bad_argc, m4_numeric_arg, m4_parse_truth_arg) (m4_symbol_value_lookup): Adjust all callers. * m4/debug.c (set_debug_file, m4_debug_set_output): Likewise. * m4/input.c (m4_skip_line, m4__next_token): Likewise. * m4/macro.c (expand_argument, collect_arguments, m4_macro_call) (process_macro): Likewise. * modules/m4.h (m4_make_temp_func): Likewise. * modules/evalparse.c (m4_evaluate): Likewise. * modules/format.c (arg_int, arg_long, arg_double, format): Likewise. * modules/gnu.c (builtin, changeresyntax, changesyntax, debugfile) (debuglen, debugmode, esyscmd, indir, mkdtemp, patsubst, regexp) (renamesyms, syncoutput, regexp_compile, substitute) (regexp_substitute, m4_resyntax_encode_safe): Likewise. * modules/m4.c (define, undefine, pushdef, popdef, ifdef, ifelse) (m4_dump_symbols, defn, syscmd, incr, decr, divert, undivert, dnl) (include, maketemp, mkstemp, m4exit, traceon, traceoff, substr): Likewise. * modules/stdlib.c (setenv, getpwuid, srand): Likewise. * modules/time.c (ctime, gmtime, localtime, mktime, strftime): Likewise. * tests/options.at (--syncoutput): Add test for invalid command-line argument. Split xfailed portion... (--syncoutput and diversions): ...into new test. (unknown option): New test. * tests/freeze.at (reloading unknown builtin): Update expected output. Signed-off-by: Eric Blake <ebb9@byu.net>
* Improve frozen debugmode behavior.Eric Blake2008-05-281-5/+23
| | | | | | | | | | | | * m4/debug.c (m4_debug_decode): Make empty debugmode additive. * src/main.c (main): Interleave -d with files. * tests/options.at (--debugmode): Update test. * tests/freeze.at (reloading debugmode): New test. * doc/m4.texinfo (Debugging options, Debugmode): Document the change. * NEWS: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Improve handling of frozen file errors.Eric Blake2008-05-231-2/+5
| | | | | | | | | | * src/freeze.c (produce_frozen_state): Detect write failures. (reload_frozen_state): Use close_stream. * tests/freeze.at (freezing failure): New test. * THANKS: Update. Reported by Jean-Charles Longuet. Signed-off-by: Eric Blake <ebb9@byu.net>
* In frozen file, split consecutive strings with newline.Eric Blake2008-05-191-25/+73
| | | | | | | | | | | | | | | * src/freeze.c (dump_symbol_CB): Add newline to 'T', 'F'. (produce_frozen_state): Likewise for 'Q', 'C'. (reload_frozen_state): Parse the new layout. [GET_DIRECTIVE]: Fix format 1 regression from 2008-05-13. * tests/freeze.at (loading format 2): Rewrite to new format. (reloading unknown builtin): Likewise. (loading format 1): Make sure backslash-newline is not interpreted. * doc/m4.texinfo (Frozen file format 2): Document the format. * NEWS: Document this change. Signed-off-by: Eric Blake <ebb9@byu.net>
* Fix spelling of René Seindal's name in --version output.Eric Blake2008-05-191-1/+5
| | | | | | | | | * ltdl/m4/gnulib-cache.m4: Import propername module. * src/main.c (AUTHORS): Rewrite in terms of proper_name. * po/Makevars (XGETTEXT_OPTIONS): Detect new functions. * HACKING: Mention new prerequisite of gperf. Signed-off-by: Eric Blake <ebb9@byu.net>
* Allow freezing the trace status of macros.Eric Blake2008-05-171-3/+82
| | | | | | | | | | | | | | * src/freeze.c (produce_symbol_dump): Let undefined traced macros through. (dump_symbol_CB): Also freeze trace state. * tests/freeze.at (reloading traced macros): New test. * doc/m4.texinfo (Using frozen files): Update documentation to mention new state. (Frozen file format 1): Improve synchronization with branch. (Frozen file format 2): Reorder directives, and add `d', `t'. * NEWS: Document this change. Signed-off-by: Eric Blake <ebb9@byu.net>
* Fix frozen file regression in pushdef stacks from 2001-09-01.Eric Blake2008-05-151-41/+71
| | | | | | | | | | | * src/freeze.c (dump_symbol_CB): Push all values on the stack, not just the current definition. (reverse_symbol_value_stack): New helper method. * tests/freeze.at (AT_TEST_FREEZE): New helper macro. (reloading pushdef stack): New test. (reloading unknown builtin): Enhance test. Signed-off-by: Eric Blake <ebb9@byu.net>
* Fix frozen file regression in diversions from 2007-01-21.Eric Blake2008-05-131-28/+4
| | | | | | | | | | | | | * m4/output.c (insert_diversion_helper): Add parameter. (m4_insert_file): Move contents... (insert_file): ...to this new helper, with added parameter. (m4_insert_diversion, m4_undivert_all, m4_freeze_diversions): Update callers. * src/freeze.c (produce_mem_dump): Simplify. (produce_syntax_dump, produce_module_dump): Add parameter. * tests/freeze.at (large diversion): Test for this. Signed-off-by: Eric Blake <ebb9@byu.net>
* Improve error message when frozen file is invalid.Eric Blake2008-05-131-9/+48
| | | | | | | | | | * src/freeze.c (decode_char): Add parameter. Allow \<newline> line continuations. (reload_frozen_state): Track current line. * tests/freeze.at (loading format 1, loading format 2): Update to test this. Signed-off-by: Eric Blake <ebb9@byu.net>
* Detect integer overflow when loading frozen file.Eric Blake2008-05-101-17/+22
| | | | | | | | | * src/freeze.c (reload_frozen_state) [GET_NUMBER]: Rewrite to fail immediately on overflow. * tests/freeze.at (loading format 2): Test this. Reported by Jim Meyering. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 23: allow tracing of indirect macro calls.Eric Blake2008-05-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_input_block): Remove. (m4_call_info): New opaque type. (m4_trace_prepare, m4_arg_info): New prototypes. (m4_macro_call, m4_push_string_finish, m4_input_print): Change prototypes. * m4/m4private.h (struct m4_macro_args): Add info field. (struct m4_call_info): New structure. (m4_arg_info): New accessor. * m4/input.c (m4_input_block): Make typedef local. (m4_push_string_init): Initialize length. (m4_push_string_finish, m4_input_print): Change signature, so that printing can be done before finalization. (struct input_funcs): Add parameter to print_func. (file_print, string_print, composite_print): Adjust accordingly. * m4/macro.c (trace_header, trace_flush, trace_pre, trace_post): Change signatures for stacked trace messages, and for using call context. (trace_prepre): Export and rename... (m4_trace_prepare): ...to this, for use by indir. Alter signature to use call context. (collect_arguments): Alter signature, to manage new field. (expand_macro): Change call context management. Move tracing... (m4_macro_call): ...here. Remove redundant parameter. (m4_arg_argc): New function. (m4_make_argv_ref): Replace unused skip parameter with new trace parameter; manage new field. * modules/gnu.c (builtin, indir): Adjust callers. * src/main.c (usage): Update debugmode flag summary. * tests/null.m4: Enhance test. * tests/null.err: Update expected output. * tests/macros.at (Tracing Hanoi Towers): Likewise. * doc/m4.texinfo (Trace): Mention more about trace formatting. (Debugmode): Enhance description of 'c' and 'x'. Enhance test to cover line numbering details in traces. (Debuglen): Enhance test to cover indir tracing. * NEWS: Mention these changes. Signed-off-by: Eric Blake <ebb9@byu.net>
* Fix testsuite bug when SIGPIPE is ignored.Eric Blake2008-04-171-0/+2
| | | | | | | | | | | | * tests/builtins.at (divert): Consume all of m4's output, to avoid spurious write failure. * src/main.c (main): In batch mode, restore default handling of SIGPIPE. * doc/m4.texinfo (Operation modes): Document SIGPIPE behavior. * THANKS: Update. Reported by Bob Proulx, via his autobuilder. Signed-off-by: Eric Blake <ebb9@byu.net>
* Overhaul inter-version releases to work with git.Eric Blake2008-04-081-2/+1
| | | | | | | | | | | | | | | | | | | | | * configure.ac (version): New variable, which has nicer version contents when using git 1.5.5+, hardcoded to 1.9a otherwise. (TIMESTAMP): Delete, since CVS id expansion died with transition to git. (AM_INIT_AUTOMAKE): Use version to decide gnu vs. gnits. * build-aux/mkstamp: Delete, no longer used. * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Kill, to speed up rebuilds when timestamps don't matter. (MKSTAMP): Delete, no longer used. (EXTRA_DIST): No longer worry about mkstamp. (.version): New rule and distributed file. (doc/m4.1, tests/package.m4): Depend on .version, not configure.ac, for timestamp. * ltdl/m4/gnulib-cache.m4: Import git-version-gen module. * modules/gnu.c (__m4_version__): TIMESTAMP no longer exists. * src/main.c (main): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Consistently cast malloc results, for C++ compilation.Eric Blake2008-03-132-8/+9
| | | | | | | | | | | | | | | | | | * m4/builtin.c (m4_builtin_find_by_name): Add cast. * m4/hash.c (m4_hash_new, m4_get_hash_iterator_next, node_new) (m4_hash_resize, maybe_grow): Likewise. * m4/m4.c (m4_create): Likewise. * m4/macro.c (expand_macro): Likewise. * m4/output.c (m4_tmpname): Likewise. * m4/path.c (search_path_add): Likewise. * m4/symtab.c (m4_symtab_create, m4_symbol_value_create) (symtab_fetch): Likewise. * m4/syntax.c (m4_syntax_create): Likewise. * modules/gnu.c (regexp_compile): Likewise. * src/main.c (main): Likewise. * src/freeze.c (reload_frozen_state): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* * src/main.c (usage): Fix typo.Eric Blake2008-02-191-1/+1
| | | | Signed-off-by: Eric Blake <ebb9@byu.net>
* Avoid some magic numbers.Eric Blake2008-02-181-2/+2
| | | | | | | | | | | | | | | * m4/m4private.h (CHAR_EOF, CHAR_BUILTIN, CHAR_QUOTE, CHAR_ARGV) (CHAR_RETRY): Define in terms of UCHAR_MAX. * m4/syntax.c (m4_syntax_create, set_syntax_set) (reset_syntax_set, check_is_single_quotes) (check_is_single_comments, check_is_macro_escaped) (m4_set_quotes, m4_set_comment): Likewise. * modules/gnu.c (regexp_compile): Likewise. * modules/m4.c (translit): Likewise. * src/freeze.c (produce_syntax_dump): Likewise. Reported by Ralf Wildenhues. Signed-off-by: Eric Blake <ebb9@byu.net>
* Fix security hole introduced 2007-11-23.Eric Blake2008-02-061-1/+5
| | | | | | | | * m4/utility.c (m4_verror_at_line): Properly escape macro names. * src/main.c (main): Manage quoteargs defaults. * doc/m4.texinfo (Indir): Document and test this. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 12b: add m4_string_pair.Eric Blake2008-01-251-18/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_string_pair): New type. (m4_get_syntax_quotes, m4_get_syntax_comments): New prototypes. (m4_symbol_value_print, m4_symbol_print, m4_shipout_string_trunc): Alter signature. * m4/m4private.h (struct m4_string): Delete. (struct m4_syntax_table): Combine quote and comment members. (m4_get_syntax_lquote, m4_get_syntax_rquote, m4_get_syntax_bcomm) (m4_get_syntax_ecomm): Adjust accessors. (m4_get_syntax_quotes, m4_get_syntax_comments): New fast accessors. * m4/symtab.c (m4_symbol_value_print, m4_symbol_print): Alter signatures. * m4/input.c (string_print, composite_print, m4_input_print): All callers updated. * m4/syntax.c (m4_syntax_delete, m4_set_syntax) (check_is_single_quotes, m4_set_quotes, set_quote_age) (m4_get_syntax_lquote, m4_get_syntax_rquote) (m4_get_syntax_quotes, check_is_single_comments, m4_set_comment) (m4_get_syntax_bcomm, m4_get_syntax_ecomm) (m4_get_syntax_comments): Likewise. * m4/macro.c (trace_prepre, trace_pre, m4_push_args): Likewise. * m4/output.c (m4_shipout_string, m4_shipout_string_trunc): Likewise. * modules/m4.c (dumpdef, m4_make_temp): Likewise. * src/freeze.c (produce_frozen_state): Likewise. * tests/freeze.at (reloading unknown builtin): Update test. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 7: use chained input support in input parser.Eric Blake2007-12-111-0/+2
| | | | | | | | | | | | | | | | | | | | * m4/m4private.h (m4__push_symbol): New prototype. (struct m4_symbol_chain): Add const-safety. * m4/symtab.c (m4_symbol_value_print): Simplify. (dump_symbol_CB): Update caller. * m4/input.c (struct m4_input_block): Alter u_c member, first introduced 2006-10-25, but unused until now. (composite_peek, composite_read, composite_unget) (composite_print, init_builtin_token): Rewrite accordingly. (m4_push_wrapup): No longer need trailing NUL. (m4__push_symbol, make_text_link): New functions. (m4_push_string_finish): Use them. * m4/macro.c (m4_push_arg, m4_push_args): Likewise. (expand_macro): Simplify logic of nesting_limit. * src/main.c (main): Likewise. * doc/m4.texinfo (Dumpdef): Augment test. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 6: convert builtins to push arg at a time.Eric Blake2007-12-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_shipout_text): Rename... (m4_divert_text): ...to this, to avoid confusion with m4_shipout_* that does not worry about sync lines. (m4_shipout_string_trunc): New prototype. * m4/output.c (m4_shipout_text): Rename... (m4_divert_text): ...to this. (m4_shipout_string): Move guts... (m4_shipout_string_trunc): ...to this new function. * m4/macro.c (m4_push_arg, m4_push_args): New functions. (expand_token, process_macro): Update callers. * m4/input.c (string_print): Likewise. * modules/m4.c (ifdef, ifelse, shift, substr, translit, divert): Likewise. * modules/gnu.c (patsubst): Likewise. (debuglen): Use SIZE_MAX for unlimited debug length. * src/main.c (main): Likewise. * m4/m4.c (m4_create): Default max_debug_length to SIZE_MAX, not zero. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 5: add notion of quote age.Eric Blake2007-12-072-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/m4module.h (m4_get_symbol_value_quote_age): New prototype. (m4_set_symbol_value_text): Adjust prototype. (m4_has_syntax): Factor out the unsigned char cast. * m4/m4private.h (struct m4_syntax_table): Add syntax_age and quote_age members. (m4__quote_age, m4__safe_quotes): New accessor macros, no need for functions at this point. (struct m4_symbol_value, struct m4_macro_args): Add quote_age member. (m4_set_symbol_value_text): Adjust fast accessor. (m4_get_symbol_value_quote_age): New fast accessor. * m4/symtab.c (m4_set_symbol_value_text): Add parameter. (m4_get_symbol_value_quote_age): New function. (m4_symbol_value_copy): Adjust callers. * m4/macro.c (expand_token): Add parameter, and track quote age. (expand_argument, collect_arguments): Track quote age. (m4_macro_expand_input, process_macro, m4_make_argv_ref) (m4_macro_expand_input): Update callers. (m4_arg_text, m4_arg_len, m4_arg_func): Abort on type mismatch. * m4/input.c: Comment cleanups. (struct m4_input_block): Reduce size. (m4__next_token): Report quote age. (m4_push_builtin, init_builtin_token): Update callers. * m4/utility.c (skip_space): Adjust callers. * m4/module.c (install_macro_table): Likewise. * m4/syntax.c (m4_set_syntax): Initialize and update quote age. (m4_set_quotes, m4_set_comment): Detect no-op changes, and update quote age. (set_quote_age): New helper function. (check_is_single_quotes, check_is_single_comments): Adjust callers. * src/freeze.c (reload_frozen_state): Likewise. * src/main.c (main): Likewise. * modules/m4.c (define, pushdef): No need to set macro text. * tests/builtins.at (changequote, defn): New tests. * examples/wrapfifo.m4: New file. * examples/wraplifo.m4: New file. * Makefile.am (dist_pkgdata_DATA): Distribute new examples. Signed-off-by: Eric Blake <ebb9@byu.net>
* Stage 3b: cache length, rather than computing it, in modules.Eric Blake2007-11-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/hash.c (m4_hash_remove): Avoid double free on remove failure. * m4/output.c (m4_shipout_string): Change semantics of len param. (m4_shipout_int): Use cached length. * m4/input.c (m4_push_string_finish): Likewise. * modules/m4.h (m4_make_temp_func): Add parameter. * m4/macro.c (expand_token, m4_arg_len): Use cached length. (collect_arguments, expand_macro): Alter signature. (trace_format): Don't use out-of-scope buffer. (process_macro): All callers changed. * m4/utility.c (m4_dump_args): Likewise. * m4/symtab.c (m4_symbol_value_print): Likewise. * modules/gnu.c (__file__, __program__, builtin, indir) (m4symbols, mkdtemp, regexp_compile, regexp_substitute, renamesyms, patsubst, regexp, regexp_compile): Likewise. * modules/load.c (m4modules): Likewise. * modules/m4.c (defn, m4wrap, maketemp, m4_make_temp) (numb_obstack, ifdef, ifelse, divert, len, substr): Likewise. * modules/perl.c (perleval): Likewise. * modules/stdlib.c (getcwd, getenv, getlogin, getpwnam, getpwuid) (hostname, uname, setenv): Likewise. * modules/mpeval.c (numb_obstack): Likewise. * src/freeze.c (dump_symbol_CB): Likewise. * doc/m4.texinfo (Renamesyms, Dumpdef, Changesyntax): Adjust test. * tests/builtins.at (mkstemp): Likewise. * tests/others.at (iso8859): XFAIL this test, now that length-based handling allows NUL through part but not all of M4. Signed-off-by: Eric Blake <ebb9@byu.net>