[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU M4 source repository branch, master, updated. cvs-readonly-259
From: |
Gary V. Vaughan |
Subject: |
[SCM] GNU M4 source repository branch, master, updated. cvs-readonly-259-g076b2ba |
Date: |
Mon, 16 Sep 2013 08:34:22 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU M4 source repository".
http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=076b2ba6c0de5d11cea357954c9a7d7b9e1a9419
The branch, master has been updated
via 076b2ba6c0de5d11cea357954c9a7d7b9e1a9419 (commit)
from 096d5ffe33d14184e64dad2da9741f3d3138763a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 076b2ba6c0de5d11cea357954c9a7d7b9e1a9419
Author: Gary V. Vaughan <address@hidden>
Date: Tue May 6 14:34:08 2008 -0400
Factor load functionality into include builtin.
* 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 <address@hidden>
-----------------------------------------------------------------------
Summary of changes:
Makefile.am | 13 +-
NEWS | 20 +++-
doc/m4.texi | 184 +++++++++++-----------------
{modules => examples}/modtest.m4 | 0
{modules => examples}/shadow.m4 | 0
{modules => examples}/stdlib.m4 | 0
{modules => examples}/time.m4 | 0
{modules => examples}/time2.m4 | 0
m4/m4module.h | 8 +-
m4/module.c | 26 ++++-
m4/path.c | 247 ++++++++++++++++++++++++++++----------
modules/load.c | 11 --
modules/m4.c | 32 ++----
src/freeze.c | 6 +-
src/main.c | 118 ++++++-------------
tests/builtins.at | 10 +-
tests/generate.awk | 4 +-
tests/m4.in | 7 +-
tests/modules.at | 79 ++++++-------
tests/null.err | Bin 3634 -> 3639 bytes
tests/options.at | 8 +-
tests/others.at | 6 +-
22 files changed, 413 insertions(+), 366 deletions(-)
rename {modules => examples}/modtest.m4 (100%)
rename {modules => examples}/shadow.m4 (100%)
rename {modules => examples}/stdlib.m4 (100%)
rename {modules => examples}/time.m4 (100%)
rename {modules => examples}/time2.m4 (100%)
diff --git a/Makefile.am b/Makefile.am
index 1e10f00..39fd0b4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -237,12 +237,6 @@ tests_time_la_LDFLAGS = $(module_ldflags)
$(module_check)
tests_time_la_LIBADD = $(module_libadd)
tests_time_la_SOURCES = modules/time.c
-EXTRA_DIST += \
- modules/modtest.m4 \
- modules/shadow.m4 \
- modules/time.m4 \
- modules/time2.m4 \
- modules/stdlib.m4
## ----- ##
## libm4 ##
@@ -356,6 +350,13 @@ dist_pkgdata_DATA = \
examples/wraplifo.m4 \
examples/wraplifo2.m4
+EXTRA_DIST += \
+ examples/modtest.m4 \
+ examples/shadow.m4 \
+ examples/time.m4 \
+ examples/time2.m4 \
+ examples/stdlib.m4
+
## ----------- ##
## Test suite. ##
## ----------- ##
diff --git a/NEWS b/NEWS
index 142e1e5..1281504 100644
--- a/NEWS
+++ b/NEWS
@@ -65,13 +65,16 @@ promoted to 2.0.
`--trace', allow more control over macro tracing from the command line
between input files.
-*** New `--unload-module' command-line option allows more control over
- dynamic modules from the command line. Also, `-m'/`--load-module' now
- acts between input files.
-
*** New `--warnings' command-line option re-enables warnings, overriding
`-Q'/`--quiet'/`--silent', allowing warnings even when POSIXLY_CORRECT.
+*** When GNU extensions are enabled, any command line arguments that wauld
+ have been interpreted as input file names with previous releases are
+ still searched for as before, but will first attempt to be loaded as
+ compiled modules before falling back on loading as m4 input. In
+ POSIXLY_CORRECT mode, only m4 input files in the current directory can
+ be loaded.
+
** POSIX conformance
*** The `defn' builtin now allows any number of arguments, as POSIX requires.
@@ -85,6 +88,9 @@ promoted to 2.0.
*** The experimental `epatsubst' and `eregexp' builtins have been removed
in favor of a new `changeresyntax' builtin.
+*** The `load' builtin, introduced in previous betas has been removed in
+ lieu of richer `include' and `sinclude' functionality.
+
** New builtins
*** New `changeresyntax' builtin allows programmatic setting of the default
@@ -149,6 +155,12 @@ promoted to 2.0.
*** The `eval' and `mpeval' builtins now support the following new
operators: `>>>', `\', and `,'.
+*** When GNU extensions are enabled, the `include' and `sinclude' builtins
+ continue to search directories one at a time, but will first attempt to
+ load arguments as compiled modules and then as m4 input before moving
+ to the next directory in the search path. In POSIXLY_CORRECT mode,
+ only m4 input in the current directory can be loaded.
+
*** The `maketemp' builtin now always warns that it is obsolete, even in GNU
mode where it uses the same secure algorithm as `mkstemp', because of
the recommendation of POSIX to obsolete `maketemp' as inherently
diff --git a/doc/m4.texi b/doc/m4.texi
index b42a1f4..43ac483 100644
--- a/doc/m4.texi
+++ b/doc/m4.texi
@@ -158,7 +158,6 @@ Introduction and preliminaries
Invoking @code{m4}
* Operation modes:: Command line options for operation modes
-* Dynamic loading features:: Command line options for dynamic loading
* Preprocessor features:: Command line options for preprocessor features
* Limits control:: Command line options for limits control
* Frozen state:: Command line options for frozen state
@@ -238,7 +237,6 @@ Diverting and undiverting output
Extending M4 with dynamic runtime modules
* M4modules:: Listing loaded modules
-* Load:: Loading additional modules
* Unload:: Removing loaded modules
* Refcount:: Tracking module references
* Standard Modules:: Standard bundled modules
@@ -598,7 +596,6 @@ version of @code{m4} introduces an option named
@option{--default}).
@menu
* Operation modes:: Command line options for operation modes
-* Dynamic loading features:: Command line options for dynamic loading
* Preprocessor features:: Command line options for preprocessor features
* Limits control:: Command line options for limits control
* Frozen state:: Command line options for frozen state
@@ -763,36 +760,6 @@ allow overriding @option{--silent}.
@comment -Wno-category...?
@end table
address@hidden Dynamic loading features
address@hidden Command line options for dynamic loading
-
-On platforms that support dynamic libraries, there are some options
-that affect dynamic loading.
-
address@hidden @code
address@hidden -M @var{directory}
address@hidden address@hidden
-Specify an alternate @var{directory} to search for modules. This option
-can be used multiple times to add several different directories to the
-module search path. @xref{Modules}, for more details.
-
address@hidden -m @var{module}
address@hidden address@hidden
-Load @var{module} before parsing more input files. @var{module} is
-searched for in each directory of the module search path, until the
-first match is found or the list is exhausted. @xref{Modules}, for more
-details. By default, the modules @samp{m4}, @samp{traditional}, and
address@hidden are preloaded, although this can be controlled during
-configuration with the @option{--with-modules} option to
address@hidden@value{VERSION}/@/configure}. This option may be given more
-than once, and order with respect to file names is significant.
-
address@hidden address@hidden
-Unload @var{module} before parsing more input files. @xref{Modules},
-for more details. This option may be given more than once, and order
-with respect to file names is significant.
address@hidden table
-
@node Preprocessor features
@section Command line options for preprocessor features
@@ -1081,16 +1048,19 @@ respect to file names. @xref{Trace}, for more details.
@cindex command line, file names on the
@cindex file names, on the command line
The remaining arguments on the command line are taken to be input file
-names. If no names are present, standard input is read. A file
-name of @file{-} is taken to mean standard input. It is
-conventional, but not required, for input files to end in @samp{.m4}.
-
-The input files are read in the sequence given. Standard input can be
-read more than once, so the file name @file{-} may appear multiple times
-on the command line; this makes a difference when input is from a
-terminal or other special file type. It is an error if an input file
-ends in the middle of argument collection, a comment, or a quoted
-string.
+names or module names (@pxref{Modules}). Whether or not any modules
+are loaded from command line arguments, when no actual input file names
+are given, then standard input is read. A file name of @file{-} can be
+used to denote standard input. It is conventional, but not required,
+for input file names to end in @samp{.m4} and for module names to end
+in @samp{.la}. The input files and modules are attended to in the
+sequence given.
+
+Standard input can be read more than once, so the file name @file{-}
+may appear multiple times on the command line; this makes a difference
+when input is from a terminal or other special file type. It is an
+error if an input file ends in the middle of argument collection, a
+comment, or a quoted string.
@comment FIXME - it would be nicer if we let these three things
@comment continue across file boundaries, provided that we warn in
@comment interactive use when switching to stdin in a non-default parse
@@ -1098,10 +1068,9 @@ string.
Various options, such as @option{--define} (@option{-D}), @option{--undefine}
(@option{-U}), @option{--synclines} (@option{-s}), @option{--trace}
-(@option{-t}), @option{--regexp-syntax} (@option{-r}), and
address@hidden (@option{-m}), only take effect after processing
-input from any file names that occur earlier on the command line. For
-example, assume the file @file{foo} contains:
+(@option{-t}), and @option{--regexp-syntax} (@option{-r}), only take
+effect after processing input from any file names that occur earlier
+on the command line. For example, assume the file @file{foo} contains:
@comment file: foo
@example
@@ -1119,6 +1088,14 @@ $ @kbd{m4 -Dbar=hello foo -Dbar=world foo}
@result{}world
@end example
address@hidden command line, module names on the
address@hidden module names, on the command line
+The use of loadable runtime modules in any sense is a @acronym{GNU} M4
+extension, so if @option{-G} is also passed or if the @env{POSIXLY_CORRECT}
+environment variable is set, even otherwise valid module names will be
+treated as though they were input file names (and no doubt cause havoc as
+M4 tries to scan and expand the contents as if it were written in @code{m4}).
+
If none of the input files invoked @code{m4exit} (@pxref{M4exit}), the
exit status of @code{m4} will be 0 for success, 1 for general failure
(such as problems with reading an input file), and 63 for version
@@ -5980,12 +5957,12 @@ m4wrap(`define(`bar',
')m4wrap(defn(`divnum'))m4wrap(`)bar
@code{m4} allows you to include named files at any point in the input.
@menu
-* Include:: Including named files
+* Include:: Including named files and modules
* Search Path:: Searching for include files
@end menu
@node Include
address@hidden Including named files
address@hidden Including named files and modules
There are two builtin macros in @code{m4} for including files:
@@ -6010,10 +5987,10 @@ parameters.
@comment status: 1
@example
include(`n')
address@hidden:stdin:1: include: cannot open 'n': No such file or directory
address@hidden:stdin:1: include: cannot open file 'n': No such file or directory
@result{}
include()
address@hidden:stdin:2: include: cannot open '': No such file or directory
address@hidden:stdin:2: include: cannot open file '': No such file or directory
@result{}
sinclude(`n')
@result{}
@@ -6071,15 +6048,32 @@ This is `bar': >>bar<<
This use of @code{include} is not trivial, though, as files can contain
quotes, commas, and parentheses, which can interfere with the way the
address@hidden parser works. @acronym{GNU} @code{m4} seamlessly concatenates
address@hidden parser works. @acronym{GNU} M4 seamlessly concatenates
the file contents with the next character, even if the included file
ended in the middle of a comment, string, or macro call. These
conditions are only treated as end of file errors if specified as input
files on the command line.
-In @acronym{GNU} @code{m4}, an alternative method of reading files is
+In @acronym{GNU} M4, an alternative method of reading files is
using @code{undivert} (@pxref{Undivert}) on a named file.
+In addition, as a @acronym{GNU} M4 extension, if the included file can
+not be found exactly as given, various standard suffixes are appended.
+If the included file name is absolute (a full path from the root directory
+is given) then additional search directories are not examined, although
+suffixes will be tried if the file is not found exactly as given.
+For each directory that is searched (according to the absolute directory
+give in the file name, or else by directories listed in @env{M4PATH} and
+given with the @option{-I} and @option{-B} options), first the unchanged
+file name is tried, and then again with the suffixes @samp{.m4f} and
address@hidden
+
+Furthermore, if no matching file has yet been found, before moving on to
+the next directory, @samp{.la} and the usual binary module suffix for
+the host platform (usually @samp{.so}) are also tried. Matching with one
+of those suffixes will attempt to load the matched file as a dynamic
+module. @xref{Modules}, for more details.
+
@node Search Path
@section Searching for include files
@@ -6511,10 +6505,11 @@ Starting with release 2.0, M4 uses Libtool's
@code{libltdl} facilities
to move all of M4's builtins out to pluggable modules. Unless compile
time options are set to change the default build, the installed M4 2.0
binary is virtually identical to 1.4.x, supporting the same builtins.
-However, an optional module can be loaded into the running M4 interpreter
-to provide a new @code{load} builtin. This facilitates runtime
-extension of the M4 builtin macro list using compiled C code linked
-against a new shared library, typically named @file{libm4.so}.
+However, additional modules can be loaded into the running M4 interpreter
+as it is started up at the command line, or during normal expansion of
+macros. This facilitates runtime extension of the M4 builtin macro
+list using compiled C code linked against a new shared library,
+typically named @file{libm4.so}.
For example, you might want to add a @code{setenv} builtin to M4, to
use before invoking @code{esyscmd}. We might write a @file{setenv.c}
@@ -6554,7 +6549,7 @@ M4 code:
@comment ignore
@example
-$ @kbd{M4MODPATH=`pwd` m4 --load-module=setenv}
+$ @kbd{m4 setenv}
setenv(`PATH', `/sbin:/bin:/usr/sbin:/usr/bin')
@result{}
esyscmd(`ifconfig -a')dnl
@@ -6562,12 +6557,12 @@ esyscmd(`ifconfig -a')dnl
@end example
Or instead of loading the module from the M4 invocation, you can use
-the new @code{load} builtin:
+the @code{include} builtin:
@comment ignore
@example
-$ @kbd{M4MODPATH=`pwd` m4 --load-module=load}
-load(`setenv')
+$ @kbd{m4}
+include(`setenv')
@result{}
setenv(`PATH', `/sbin:/bin:/usr/sbin:/usr/bin')
@result{}
@@ -6576,7 +6571,7 @@ setenv(`PATH', `/sbin:/bin:/usr/sbin:/usr/bin')
Also, at build time, you can choose which modules to build into
the core (so that they will be available without dynamic loading).
SUSv3 M4 functionality is contained in the module @samp{m4}, @acronym{GNU}
-extensions in the module @samp{gnu}, the @code{load} builtin in the
+extensions in the module @samp{gnu}, additional module builtins in the
module @samp{load} and so on.
We hinted earlier that the @code{m4} and @code{gnu} modules are
@@ -6584,10 +6579,10 @@ preloaded into the installed M4 binary, but it is
possible to install
a @emph{thinner} binary; for example, omitting the @acronym{GNU}
extensions by configuring the distribution with @kbd{./configure
--with-modules=m4}. For a binary built with that option to understand
-code that uses @acronym{GNU} extensions, you must then run @kbd{m4
---load-module=gnu}. It is also possible to build a @emph{fatter}
-binary with additional modules preloaded: adding, say, the @code{load}
-builtin using @kbd{./configure --with-modules="m4 gnu load"}.
+code that uses @acronym{GNU} extensions, you must then run @kbd{m4 gnu}.
+It is also possible to build a @emph{fatter} binary with additional
+modules preloaded: adding, say, the @code{load} module usingr
+ @kbd{./configure --with-modules="m4 gnu load"}.
@acronym{GNU} M4 now has a facility for defining additional builtins without
recompiling the sources. In actual fact, all of the builtins provided
@@ -6603,7 +6598,6 @@ two modes of startup.
@menu
* M4modules:: Listing loaded modules
-* Load:: Loading additional modules
* Unload:: Removing loaded modules
* Refcount:: Tracking module references
* Standard Modules:: Standard bundled modules
@@ -6620,43 +6614,13 @@ position depends on when the module was @emph{first}
loaded.
@end deffn
For example, if @acronym{GNU} @code{m4} is started with the
address@hidden load} option to load the module @samp{load} and make this
-builtin available, @code{m4modules} will yield the following:
-
address@hidden options: -m load
address@hidden
-$ @kbd{m4 -m load}
-m4modules
address@hidden,gnu,m4
address@hidden example
-
address@hidden Load
address@hidden Loading additional modules
-
address@hidden {Builtin (load)} load (@var{module-name})
address@hidden will be searched for along the module search path
-(@pxref{Standard Modules}) and loaded if found. Loading a module
-consists of running its initialization function (if any) and then adding
-any macros it provides to the internal table.
address@hidden module, @code{m4modules} will yield the following:
-The macro @code{load} is recognized only with parameters.
address@hidden deffn
-
-Once the @code{load} module has successfully loaded, use of the
address@hidden macro is entirely equivalent to the @option{-m} command line
-option.
-
address@hidden The -mmpeval/--unload=mpeval pair allows the testsuite to skip
this
address@hidden test if mpeval was not configured for usage.
address@hidden options: -m load -m mpeval --unload-module=mpeval
address@hidden options: load -
@example
-$ @kbd{m4 -m load}
+$ @kbd{m4 load -}
m4modules
@result{}load,gnu,m4
-load(`mpeval')
address@hidden
-m4modules
address@hidden,load,gnu,m4
@end example
@node Unload
@@ -6672,9 +6636,9 @@ running the module's finalization method (if any).
The macro @code{unload} is recognized only with parameters.
@end deffn
address@hidden options: -m mpeval -m load
address@hidden options: mpeval load -
@example
-$ @kbd{m4 -m mpeval -m load}
+$ @kbd{m4 mpeval load -}
m4modules
@result{}load,mpeval,gnu,m4
unload(`mpeval')
@@ -6697,16 +6661,16 @@ The macro @code{refcount} is recognized only with
parameters.
This example demonstrates tracking the reference count of the gnu
module.
address@hidden options: -m load
address@hidden options: load -
@example
-$ @kbd{m4 -m load}
+$ @kbd{m4 load -}
m4modules
@result{}load,gnu,m4
refcount(`gnu')
@result{}1
m4modules
@result{}load,gnu,m4
-load(`gnu')
+include(`gnu')
@result{}
refcount(`gnu')
@result{}2
@@ -6771,7 +6735,7 @@ Expands to the empty string, as an indication that the
@end deffn
@item load
-This module supplies the builtins required to use modules from within a
+This module supplies the builtins for advanced use of modules from within a
@acronym{GNU} @code{m4} program. @xref{Modules}, for more details. The
module also defines the following macro:
@@ -7923,9 +7887,9 @@ The macro @code{mpeval} is recognized only with
parameters.
For the most part, using @code{mpeval} is similar to using @code{eval}:
address@hidden options: -m mpeval
address@hidden options: mpeval -
@example
-$ @kbd{m4 -m mpeval}
+$ @kbd{m4 mpeval -}
mpeval(`(1 << 70) + 2 ** 68 * 3', `16')
@result{}700000000000000000
`0r24:'mpeval(`0r36:zYx', `24', `5')
@@ -7950,9 +7914,9 @@ value of the argument that ended evaluation, rather than
collapsing to
even in @acronym{POSIX} mode, since @code{mpeval} does not have to
conform to the @acronym{POSIX} rules for @code{eval}.
address@hidden options: -m mpeval
address@hidden options: mpeval -
@example
-$ @kbd{m4 -m mpeval}
+$ @kbd{m4 mpeval -}
mpeval(`2 / 4')
@result{}0
mpeval(`2 \ 4')
diff --git a/modules/modtest.m4 b/examples/modtest.m4
similarity index 100%
rename from modules/modtest.m4
rename to examples/modtest.m4
diff --git a/modules/shadow.m4 b/examples/shadow.m4
similarity index 100%
rename from modules/shadow.m4
rename to examples/shadow.m4
diff --git a/modules/stdlib.m4 b/examples/stdlib.m4
similarity index 100%
rename from modules/stdlib.m4
rename to examples/stdlib.m4
diff --git a/modules/time.m4 b/examples/time.m4
similarity index 100%
rename from modules/time.m4
rename to examples/time.m4
diff --git a/modules/time2.m4 b/examples/time2.m4
similarity index 100%
rename from modules/time2.m4
rename to examples/time2.m4
diff --git a/m4/m4module.h b/m4/m4module.h
index fa245ec..e6d348a 100644
--- a/m4/m4module.h
+++ b/m4/m4module.h
@@ -554,9 +554,11 @@ extern void m4_undivert_all (m4 *);
/* --- PATH MANAGEMENT --- */
-extern void m4_include_env_init (m4 *);
-extern void m4_add_include_directory (m4 *, const char *, bool);
-extern FILE * m4_path_search (m4 *, const char *, char **);
+extern void m4_add_include_directory (m4 *, const char *, bool);
+extern bool m4_load_filename (m4 *, const m4_call_info *,
+ const char *, m4_obstack *, bool);
+extern char * m4_path_search (m4 *, const char *, const char **);
+extern FILE * m4_fopen (m4 *, const char *, const char *);
diff --git a/m4/module.c b/m4/module.c
index b8ce8d2..6a05479 100644
--- a/m4/module.c
+++ b/m4/module.c
@@ -390,13 +390,33 @@ compare_builtin_CB (const void *a, const void *b)
m4_module *
m4__module_open (m4 *context, const char *name, m4_obstack *obs)
{
- lt_dlhandle handle = lt_dlopenext (name);
- m4_module * module = NULL;
- m4_module_init_func * init_func = NULL;
+ static const char * suffixes[] = { "", ".la", LT_MODULE_EXT, NULL };
+ char * filepath = NULL;
+ lt_dlhandle handle = NULL;
+ lt_dladvise advise = NULL;
+ m4_module * module = NULL;
+ m4_module_init_func * init_func = NULL;
assert (context);
assert (iface_id); /* need to have called m4__module_init */
+ /* Try opening as a preloaded module initially incase path searching
+ has been disabled by POSIXLY_CORRECT... */
+ if (!lt_dladvise_init (&advise) && !lt_dladvise_preload (&advise))
+ handle = lt_dlopenadvise (name, advise);
+ lt_dladvise_destroy (&advise);
+
+ /* ...otherwise resort to a path search anyway. */
+ if (!handle)
+ {
+ filepath = m4_path_search (context, name, suffixes);
+ if (filepath)
+ {
+ handle = lt_dlopenext (filepath);
+ free (filepath);
+ }
+ }
+
if (handle)
{
const lt_dlinfo *info = lt_dlgetinfo (handle);
diff --git a/m4/path.c b/m4/path.c
index 8ba1caa..2c6796f 100644
--- a/m4/path.c
+++ b/m4/path.c
@@ -23,7 +23,10 @@
#include <config.h>
+#include <stdio.h>
#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include "m4private.h"
@@ -33,8 +36,24 @@
/* Define this to see runtime debug info. Implied by DEBUG. */
/*#define DEBUG_INCL */
+static const char *FILE_SUFFIXES[] = {
+ "",
+ ".m4f",
+ ".m4",
+ ".la",
+ LT_MODULE_EXT,
+ NULL
+};
+
+static const char *NO_SUFFIXES[] = { "", NULL };
+
static void search_path_add (m4__search_path_info *, const char *, bool);
static void search_path_env_init (m4__search_path_info *, char *, bool);
+static void include_env_init (m4 *context);
+
+#ifdef DEBUG_INCL
+static void include_dump (m4 *context);
+#endif
/*
@@ -91,11 +110,8 @@ search_path_env_init (m4__search_path_info *info, char
*path, bool isabs)
while (path_end);
}
-
-/* Functions for normal input path search */
-
-void
-m4_include_env_init (m4 *context)
+static void
+include_env_init (m4 *context)
{
char *m4path;
@@ -109,6 +125,10 @@ m4_include_env_init (m4 *context)
free (m4path);
}
+
+
+/* Functions for normal input path search */
+
void
m4_add_include_directory (m4 *context, const char *dir, bool prepend)
{
@@ -123,113 +143,214 @@ m4_add_include_directory (m4 *context, const char *dir,
bool prepend)
#endif
}
-/* Attempt to open FILE; if it opens, verify that it is not a
- directory, and ensure it does not leak across execs. */
-static FILE *
-m4_fopen (m4 *context, const char *file, const char *mode)
-{
- FILE *fp = fopen (file, "r");
- if (fp)
- {
- struct stat st;
- int fd = fileno (fp);
- if (fstat (fd, &st) == 0 && S_ISDIR (st.st_mode))
- {
- fclose (fp);
- errno = EISDIR;
- return NULL;
- }
- if (set_cloexec_flag (fileno (fp), true) != 0)
- m4_error (context, 0, errno, NULL,
- _("cannot protect input file across forks"));
- }
- return fp;
-}
-/* Search for FILE according to -B options, `.', -I options, then
+/* Search for FILENAME according to -B options, `.', -I options, then
M4PATH environment. If successful, return the open file, and if
RESULT is not NULL, set *RESULT to a malloc'd string that
represents the file found with respect to the current working
directory. Otherwise, return NULL, and errno reflects the failure
from searching `.' (regardless of what else was searched). */
-
-FILE *
-m4_path_search (m4 *context, const char *file, char **expanded_name)
+char *
+m4_path_search (m4 *context, const char *filename, const char **suffixes)
{
- FILE *fp;
m4__search_path *incl;
- char *name; /* buffer for constructed name */
- int e = 0;
-
- if (expanded_name != NULL)
- *expanded_name = NULL;
+ char *filepath; /* buffer for constructed name */
+ size_t max_suffix_len = 0;
+ int i, e = 0;
/* Reject empty file. */
- if (*file == '\0')
+ if (*filename == '\0')
{
errno = ENOENT;
return NULL;
}
+ /* Use no suffixes by default. */
+ if (suffixes == NULL)
+ suffixes = NO_SUFFIXES;
+
+ /* Find the longest suffix, so that we will always allocate enough
+ memory for a filename with suffix. */
+ for (i = 0; suffixes && suffixes[i]; ++i)
+ {
+ size_t len = strlen (suffixes[i]);
+ if (len > max_suffix_len)
+ max_suffix_len = len;
+ }
+
/* If file is absolute, or if we are not searching a path, a single
lookup will do the trick. */
- if (IS_ABSOLUTE_FILE_NAME (file) || m4_get_posixly_correct_opt (context))
+ if (IS_ABSOLUTE_FILE_NAME (filename))
{
- fp = m4_fopen (context, file, "r");
- if (fp != NULL)
+ size_t mem = strlen (filename);
+
+ /* Try appending each of the suffixes we were given. */
+ filepath = strncpy (xmalloc (mem + max_suffix_len +1), filename, mem);
+ for (i = 0; suffixes && suffixes[i]; ++i)
{
- if (expanded_name != NULL)
- *expanded_name = xstrdup (file);
- return fp;
+ strcpy (filepath + mem, suffixes[i]);
+ if (access (filepath, R_OK) == 0)
+ return filepath;
+
+ /* If search fails, we'll use the error we got from the first
+ access (usually with no suffix). */
+ if (i == 0)
+ e = errno;
}
+ free (filepath);
+
+ /* No such file. */
+ errno = e;
return NULL;
}
for (incl = m4__get_search_path (context)->list;
incl != NULL; incl = incl->next)
{
- name = file_name_concat (incl->dir, file, NULL);
+ char *pathname = file_name_concat (incl->dir, filename, NULL);
+ size_t mem = strlen (pathname);
#ifdef DEBUG_INCL
- xfprintf (stderr, "path_search (%s) -- trying %s\n", file, name);
+ xfprintf (stderr, "path_search (%s) -- trying %s\n", filename, pathname);
#endif
- fp = m4_fopen (context, name, "r");
- if (fp != NULL)
+ if (access (pathname, R_OK) == 0)
{
m4_debug_message (context, M4_DEBUG_TRACE_PATH,
_("path search for %s found %s"),
- quotearg_style (locale_quoting_style, file),
- quotearg_n_style (1, locale_quoting_style, name));
- if (expanded_name != NULL)
- *expanded_name = name;
- else
- free (name);
- return fp;
+ quotearg_style (locale_quoting_style, filename),
+ quotearg_n_style (1, locale_quoting_style,
pathname));
+ return pathname;
}
else if (!incl->len)
- /* Capture errno only when searching `.'. */
- e = errno;
- free (name);
+ /* Capture errno only when searching `.'. */
+ e = errno;
+
+ filepath = strncpy (xmalloc (mem + max_suffix_len +1), pathname, mem);
+ free (pathname);
+
+ for (i = 0; suffixes && suffixes[i]; ++i)
+ {
+ strcpy (filepath + mem, suffixes[i]);
+ if (access (filepath, R_OK) == 0)
+ return filepath;
+ }
+ free (filepath);
}
errno = e;
return NULL;
}
+
+/* Attempt to open FILE; if it opens, verify that it is not a
+ directory, and ensure it does not leak across execs. */
+FILE *
+m4_fopen (m4 *context, const char *file, const char *mode)
+{
+ FILE *fp = NULL;
+
+ if (file)
+ {
+ struct stat st;
+ int fd;
+
+ fp = fopen (file, mode);
+ fd = fileno (fp);
+
+ if (fstat (fd, &st) == 0 && S_ISDIR (st.st_mode))
+ {
+ fclose (fp);
+ errno = EISDIR;
+ return NULL;
+ }
+ if (set_cloexec_flag (fileno (fp), true) != 0)
+ m4_error (context, 0, errno, NULL,
+ _("cannot protect input file across forks"));
+ }
+ return fp;
+}
+
+
+/* Generic load function. Push the input file or load the module named
+ FILENAME, if it can be found in the search path. Complain
+ about inaccesible files iff SILENT is false. */
+bool
+m4_load_filename (m4 *context, const m4_call_info *caller,
+ const char *filename, m4_obstack *obs, bool silent)
+{
+ char *filepath = NULL;
+ char *suffix = NULL;
+ bool new_input = false;
+
+ if (m4_get_posixly_correct_opt (context))
+ {
+ if (access (filename, R_OK) == 0)
+ filepath = xstrdup (filename);
+ }
+ else
+ filepath = m4_path_search (context, filename, FILE_SUFFIXES);
+
+ if (filepath)
+ suffix = strrchr (filepath, '.');
+
+ if (!m4_get_posixly_correct_opt (context)
+ && suffix
+ && (!strcmp (suffix, LT_MODULE_EXT) || !strcmp (suffix, ".la")))
+ {
+ m4_module_load (context, filepath, obs);
+ }
+ else
+ {
+ FILE *fp = NULL;
+
+ if (filepath)
+ fp = m4_fopen (context, filepath, "r");
+
+ if (fp == NULL)
+ {
+ if (!silent)
+ m4_error (context, 0, errno, caller, _("cannot open file '%s'"),
+ filename);
+ free (filepath);
+ return false;
+ }
+
+ m4_push_file (context, fp, filepath, true);
+ new_input = true;
+ }
+ free (filepath);
+
+ return new_input;
+}
+
+
void
m4__include_init (m4 *context)
{
- m4__search_path_info *info = m4__get_search_path (context);
+ include_env_init (context);
- assert (info);
- search_path_add (info, "", false);
+ {
+ m4__search_path_info *info = m4__get_search_path (context);
+
+ /* If M4PATH was not set, then search just the current directory by
+ default. */
+ assert (info);
+ if (info->list_end == NULL)
+ search_path_add (info, "", false);
+ }
+
+#ifdef DEBUG_INCL
+ fputs ("initial include search path...\n", stderr);
+ include_dump (context);
+#endif
}
+
#ifdef DEBUG_INCL
-static void M4_GNUC_UNUSED
+static void
include_dump (m4 *context)
{
m4__search_path *incl;
@@ -237,7 +358,7 @@ include_dump (m4 *context)
fputs ("include_dump:\n", stderr);
for (incl = m4__get_search_path (context)->list;
incl != NULL; incl = incl->next)
- xfprintf (stderr, "\t%s\n", incl->dir);
+ xfprintf (stderr, "\t'%s'\n", incl->dir);
}
#endif /* DEBUG_INCL */
diff --git a/modules/load.c b/modules/load.c
index 1a61037..7702acf 100644
--- a/modules/load.c
+++ b/modules/load.c
@@ -35,7 +35,6 @@
function macros blind side minargs maxargs */
#define builtin_functions \
- BUILTIN (load, false, true, false, 1, 1 ) \
BUILTIN (m4modules, false, false, false, 0, 0 ) \
BUILTIN (refcount, false, true, false, 1, 1 ) \
BUILTIN (unload, false, true, false, 1, 1 ) \
@@ -117,16 +116,6 @@ M4BUILTIN_HANDLER (refcount)
}
/**
- * load(MODULE-NAME)
- **/
-M4BUILTIN_HANDLER (load)
-{
- /* Load the named module and install the builtins and macros
- exported by that module. */
- m4_module_load (context, M4ARG(1), obs);
-}
-
-/**
* unload(MODULE-NAME)
**/
M4BUILTIN_HANDLER (unload)
diff --git a/modules/m4.c b/modules/m4.c
index 9091d81..305fb76 100644
--- a/modules/m4.c
+++ b/modules/m4.c
@@ -98,8 +98,8 @@ extern void m4_make_temp (m4 *, m4_obstack *, const
m4_call_info *,
typedef intmax_t number;
typedef uintmax_t unumber;
-static void include (m4 *context, int argc, m4_macro_args *argv,
- bool silent);
+static void include (m4 *context, m4_obstack *obs, size_t argc,
+ m4_macro_args *argv, bool silent);
static int dumpdef_cmp_CB (const void *s1, const void *s2);
static void * dump_symbol_CB (m4_symbol_table *, const char *, size_t,
m4_symbol *symbol, void *userdata);
@@ -603,7 +603,10 @@ M4BUILTIN_HANDLER (undivert)
quotearg_style_mem (locale_quoting_style, str, len));
else
{
- FILE *fp = m4_path_search (context, str, NULL);
+ char *filepath = m4_path_search (context, str, NULL);
+ FILE *fp = m4_fopen (context, filepath, "r");
+
+ free (filepath);
if (fp != NULL)
{
m4_insert_file (context, fp);
@@ -660,14 +663,9 @@ M4BUILTIN_HANDLER (changecom)
and "sinclude". This differs from bringing back diversions, in that
the input is scanned before being copied to the output. */
-/* Generic include function. Include the file given by the first
- argument, if it exists. Complain about inaccessible files iff
- SILENT is false. */
static void
-include (m4 *context, int argc, m4_macro_args *argv, bool silent)
+include (m4 *context, m4_obstack *obs, size_t argc, m4_macro_args *argv, bool
silent)
{
- FILE *fp;
- char *name = NULL;
const m4_call_info *me = m4_arg_info (argv);
const char *arg = M4ARG (1);
size_t len = M4ARGLEN (1);
@@ -675,29 +673,19 @@ include (m4 *context, int argc, m4_macro_args *argv, bool
silent)
if (strlen (arg) != len)
m4_warn (context, 0, me, _("argument %s truncated"),
quotearg_style_mem (locale_quoting_style, arg, len));
- fp = m4_path_search (context, arg, &name);
- if (fp == NULL)
- {
- if (!silent)
- m4_error (context, 0, errno, m4_arg_info (argv), _("cannot open %s"),
- quotearg_style (locale_quoting_style, arg));
- return;
- }
-
- m4_push_file (context, fp, name, true);
- free (name);
+ m4_load_filename (context, me, arg, obs, silent);
}
/* Include a file, complaining in case of errors. */
M4BUILTIN_HANDLER (include)
{
- include (context, argc, argv, false);
+ include (context, obs, argc, argv, false);
}
/* Include a file, ignoring errors. */
M4BUILTIN_HANDLER (sinclude)
{
- include (context, argc, argv, true);
+ include (context, obs, argc, argv, true);
}
diff --git a/src/freeze.c b/src/freeze.c
index 38fb67a..965f0d4 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -449,7 +449,8 @@ decode_char (m4 *context, FILE *in, bool *advance_line)
void
reload_frozen_state (m4 *context, const char *name)
{
- FILE *file;
+ FILE *file = NULL;
+ char *filepath;
int version;
int character;
int operation;
@@ -565,7 +566,8 @@ reload_frozen_state (m4 *context, const char *name)
} \
while (character == '\n')
- file = m4_path_search (context, name, (char **)NULL);
+ filepath = m4_path_search (context, name, NULL);
+ file = m4_fopen (context, filepath, "r");
if (file == NULL)
m4_error (context, EXIT_FAILURE, errno, NULL, _("cannot open %s"),
quotearg_style (locale_quoting_style, name));
diff --git a/src/main.c b/src/main.c
index 240e241..9bbd5b9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -109,14 +109,6 @@ SPEC is any one of:\n\
GREP, POSIX_AWK, POSIX_EGREP, MINIMAL, MINIMAL_BASIC, SED.\n\
"), stdout);
puts ("");
- xprintf (_("\
-Dynamic loading features:\n\
- -M, --module-directory=DIR add DIR to module search path before\n\
- %s\n\
- -m, --load-module=MODULE load dynamic MODULE\n\
- --unload-module=MODULE unload dynamic MODULE\n\
-"), quotearg_style (locale_quoting_style, PKGLIBEXECDIR));
- puts ("");
fputs (_("\
Preprocessor features:\n\
-B, --prepend-include=DIR add DIR to include path before `.'\n\
@@ -181,10 +173,9 @@ FLAGS is any of:\n\
puts ("");
fputs (_("\
If defined, the environment variable `M4PATH' is a colon-separated list\n\
-of directories included after any specified by `-I', and the variable\n\
-`M4MODPATH' is a colon-separated list of directories searched before any\n\
-specified by `-M'. The environment variable `POSIXLY_CORRECT' implies\n\
--G -Q; otherwise GNU extensions are enabled by default.\n\
+of directories included after any specified by `-I' or `-B'. The\n\
+environment variable `POSIXLY_CORRECT' implies -G -Q; otherwise GNU\n\
+extensions are enabled by default.\n\
"), stdout);
puts ("");
fputs (_("\
@@ -210,7 +201,6 @@ enum
SAFER_OPTION, /* -S still has old no-op semantics */
SYNCOUTPUT_OPTION, /* not quite -s, because of opt arg */
TRACEOFF_OPTION, /* no short opt */
- UNLOAD_MODULE_OPTION, /* no short opt */
WORD_REGEXP_OPTION, /* deprecated, used to be -W */
HELP_OPTION, /* no short opt */
@@ -231,8 +221,6 @@ static const struct option long_options[] =
{"gnu", no_argument, NULL, 'g'},
{"include", required_argument, NULL, 'I'},
{"interactive", no_argument, NULL, 'i'},
- {"load-module", required_argument, NULL, 'm'},
- {"module-directory", required_argument, NULL, 'M'},
{"nesting-limit", required_argument, NULL, 'L'},
{"posix", no_argument, NULL, 'G'},
{"prefix-builtins", no_argument, NULL, 'P'},
@@ -258,7 +246,6 @@ static const struct option long_options[] =
{"safer", no_argument, NULL, SAFER_OPTION},
{"syncoutput", optional_argument, NULL, SYNCOUTPUT_OPTION},
{"traceoff", required_argument, NULL, TRACEOFF_OPTION},
- {"unload-module", required_argument, NULL, UNLOAD_MODULE_OPTION},
{"word-regexp", required_argument, NULL, WORD_REGEXP_OPTION},
{"help", no_argument, NULL, HELP_OPTION},
@@ -272,7 +259,7 @@ static const struct option long_options[] =
behavior also handles -s between files. Starting OPTSTRING with
'-' forces getopt_long to hand back file names as arguments to opt
'\1', rather than reordering the command line. */
-#define OPTSTRING "-B:D:EF:GH:I:L:M:PQR:S:T:U:Wbcd::egil:m:o:p:r::st:"
+#define OPTSTRING "-B:D:EF:GH:I:L:PQR:S:T:U:Wbcd::egil:o:p:r::st:"
/* For determining whether to be interactive. */
enum interactive_choice
@@ -296,29 +283,23 @@ size_opt (char const *opt, int oi, int optchar)
return size;
}
-/* Process a command line file NAME, and return true only if it was
- stdin. */
-static void
+/* Process a command line file NAME. */
+static bool
process_file (m4 *context, const char *name)
{
+ bool new_input = true;
+
if (STREQ (name, "-"))
/* TRANSLATORS: This is a short name for `standard input', used
when a command line file was given as `-'. */
m4_push_file (context, stdin, _("stdin"), false);
else
- {
- char *full_name;
- FILE *fp = m4_path_search (context, name, &full_name);
- if (fp == NULL)
- {
- m4_error (context, 0, errno, NULL, _("cannot open %s"),
- quotearg_style (locale_quoting_style, name));
- return;
- }
- m4_push_file (context, fp, full_name, true);
- free (full_name);
- }
- m4_macro_expand_input (context);
+ new_input = m4_load_filename (context, NULL, name, NULL, false);
+
+ if (new_input)
+ m4_macro_expand_input (context);
+
+ return new_input;
}
@@ -413,15 +394,13 @@ main (int argc, char *const *argv, char *const *envp)
/* fall through */
case 'D':
case 'U':
- case 'm':
case 'p':
case 'r':
case 't':
case POPDEF_OPTION:
case SYNCOUTPUT_OPTION:
case TRACEOFF_OPTION:
- case UNLOAD_MODULE_OPTION:
- defer:
+ defer:
/* Arguments that cannot be handled until later are accumulated. */
defn = (deferred *) xmalloc (sizeof *defn);
@@ -485,22 +464,6 @@ main (int argc, char *const *argv, char *const *envp)
m4_set_nesting_limit_opt (context, size);
break;
- case 'M':
- if (lt_dlinsertsearchdir (lt_dlgetsearchpath (), optarg) != 0)
- {
- const char *dlerr = lt_dlerror ();
- if (dlerr == NULL)
- m4_error (context, EXIT_FAILURE, 0, NULL,
- _("failed to add search directory %s"),
- quotearg_style (locale_quoting_style, optarg));
- else
- m4_error (context, EXIT_FAILURE, 0, NULL,
- _("failed to add search directory %s: %s"),
- quotearg_style (locale_quoting_style, optarg),
- dlerr);
- }
- break;
-
case 'P':
m4_set_prefix_builtins_opt (context, true);
break;
@@ -603,31 +566,12 @@ main (int argc, char *const *argv, char *const *envp)
}
}
- /* Interactive if specified, or if no input files and stdin and
- stderr are terminals, to match sh behavior. Interactive mode
- means unbuffered output, and interrupts ignored. */
-
- m4_set_interactive_opt (context, (interactive == INTERACTIVE_YES
- || (interactive == INTERACTIVE_UNKNOWN
- && optind == argc && !seen_file
- && isatty (STDIN_FILENO)
- && isatty (STDERR_FILENO))));
- if (m4_get_interactive_opt (context))
- {
- signal (SIGINT, SIG_IGN);
- setbuf (stdout, NULL);
- }
- else
- signal (SIGPIPE, SIG_DFL);
-
-
/* Do the basic initializations. */
if (debugfile && !m4_debug_set_output (context, NULL, debugfile))
m4_error (context, 0, errno, NULL, _("cannot set debug file %s"),
quotearg_style (locale_quoting_style, debugfile));
m4_input_init (context);
m4_output_init (context);
- m4_include_env_init (context);
if (frozen_file_to_read)
reload_frozen_state (context, frozen_file_to_read);
@@ -696,11 +640,6 @@ main (int argc, char *const *argv, char *const *envp)
quotearg_style (locale_quoting_style, arg));
break;
- case 'm':
- /* FIXME - should loading a module result in output? */
- m4_module_load (context, arg, NULL);
- break;
-
case 'r':
m4_set_regexp_syntax_opt (context, m4_regexp_syntax_encode (arg));
if (m4_get_regexp_syntax_opt (context) < 0)
@@ -714,7 +653,8 @@ main (int argc, char *const *argv, char *const *envp)
break;
case '\1':
- process_file (context, arg);
+ if (process_file (context, arg))
+ seen_file = true;
break;
case DEBUGFILE_OPTION:
@@ -748,11 +688,6 @@ main (int argc, char *const *argv, char *const *envp)
m4_set_symbol_name_traced (M4SYMTAB, arg, strlen (arg), false);
break;
- case UNLOAD_MODULE_OPTION:
- /* FIXME - should unloading a module result in output? */
- m4_module_unload (context, arg, NULL);
- break;
-
default:
assert (!"INTERNAL ERROR: bad code in deferred arguments");
abort ();
@@ -763,6 +698,25 @@ main (int argc, char *const *argv, char *const *envp)
defn = next;
}
+
+ /* Interactive if specified, or if no input files and stdin and
+ stderr are terminals, to match sh behavior. Interactive mode
+ means unbuffered output, and interrupts ignored. */
+
+ m4_set_interactive_opt (context, (interactive == INTERACTIVE_YES
+ || (interactive == INTERACTIVE_UNKNOWN
+ && optind == argc && !seen_file
+ && isatty (STDIN_FILENO)
+ && isatty (STDERR_FILENO))));
+ if (m4_get_interactive_opt (context))
+ {
+ signal (SIGINT, SIG_IGN);
+ setbuf (stdout, NULL);
+ }
+ else
+ signal (SIGPIPE, SIG_DFL);
+
+
/* Handle remaining input files. Each file is pushed on the input,
and the input read. */
diff --git a/tests/builtins.at b/tests/builtins.at
index 1147972..48309cf 100644
--- a/tests/builtins.at
+++ b/tests/builtins.at
@@ -243,7 +243,7 @@ AT_DATA([in.m4], [[include(`forloop3.m4')dnl
forloop(`i', `1', `10000', `define(`m'i, i)')m10000
forloop(`i', `1', `10000', `undefine(`m'i)')m10000
]])
-AT_CHECK_M4([-I "$top_srcdir/examples" in.m4], [0], [[10000
+AT_CHECK_M4([-I "$abs_top_srcdir/examples" in.m4], [0], [[10000
m10000
]])
@@ -379,7 +379,7 @@ forloop(`i', `9001', `10000',
divert(`-1')undivert
]])
-AT_CHECK_M4([-I "$top_srcdir/examples" in.m4])
+AT_CHECK_M4([-I "$abs_top_srcdir/examples" in.m4])
AT_CLEANUP
@@ -612,8 +612,8 @@ very late
]])
AT_DATA([[experr]],
-[[m4:include.m4:2: include: cannot open 'NOFILE': No such file or directory
-m4:include.m4:6: include: cannot open 'NOFILE': No such file or directory
+[[m4:include.m4:2: include: cannot open file 'NOFILE': No such file or
directory
+m4:include.m4:6: include: cannot open file 'NOFILE': No such file or directory
]])
AT_CHECK_M4([include.m4], 1, expout, experr)
@@ -927,7 +927,7 @@ AT_DATA([[expout]],
]])
-AT_CHECK_M4([-m mpeval in], 0, expout)
+AT_CHECK_M4([mpeval in], 0, expout)
AT_CLEANUP
diff --git a/tests/generate.awk b/tests/generate.awk
index a0256c8..6dcddf4 100755
--- a/tests/generate.awk
+++ b/tests/generate.awk
@@ -170,9 +170,9 @@ function new_test(input, status, output, error, options,
xfail, examples) {
output = normalize(output);
error = normalize(error);
- if (options ~ /-m/)
+ if (options ~ / (import|load|modtest|mpeval|perl|shadow|stdlib|time)/)
printf ("AT_CHECK_DYNAMIC_MODULE\n");
- if (options ~ /-m mpeval/)
+ if (options ~ / mpeval/)
printf ("AT_CHECK_GMP\n");
if (xfail == 1)
printf ("AT_XFAIL_IF([:])\n");
diff --git a/tests/m4.in b/tests/m4.in
index 84d62f9..7d34a00 100644
--- a/tests/m4.in
+++ b/tests/m4.in
@@ -34,8 +34,7 @@ else
case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
fi
-M4MODPATH="@abs_top_builddir@/modules${M4MODPATH+:$M4MODPATH}"
-export M4MODPATH
-
-exec "@abs_top_builddir@/src/m4" ${1+"$@"}
+exec "@abs_top_builddir@/src/m4" \
+ --include="@abs_top_builddir@/modules" \
+ ${1+"$@"}
exit 1
diff --git a/tests/modules.at b/tests/modules.at
index 953f06d..e31e33e 100644
--- a/tests/modules.at
+++ b/tests/modules.at
@@ -34,10 +34,10 @@ AT_DATA([[frozen.m4]],
define(`test', `local::`test'')dnl
define(`test1', defn(`test'))dnl
->test
-load(`modtest')
+include(`modtest')
define(`test2', defn(`test'))dnl
->test
-load(`shadow')
+include(`shadow')
define(`test3', defn(`test'))dnl
->test
]])
@@ -51,18 +51,18 @@ test3
# First generate the `expout' ouput by running over the sources before
# freezing.
-AT_CHECK_M4([-M "$abs_builddir" -m load frozen.m4 unfrozen.m4],
+AT_CHECK_M4([-I "$abs_builddir" load frozen.m4 unfrozen.m4],
[0], [stdout], [stderr])
mv stdout expout
mv stderr experr
# Now freeze the first source file.
-AT_CHECK_M4([-M "$abs_builddir" -m load -F frozen.m4f frozen.m4],
+AT_CHECK_M4([-I "$abs_builddir" load -F frozen.m4f frozen.m4],
[0], [], [ignore])
# Now rerun the original sequence, but using the frozen file.
-AT_CHECK_M4([-M "$abs_builddir" -R frozen.m4f unfrozen.m4],
+AT_CHECK_M4([-I "$abs_builddir" -R frozen.m4f unfrozen.m4],
[0], [expout], [experr])
AT_CLEANUP([frozen.m4f])
@@ -76,7 +76,7 @@ AT_SETUP([module test macros])
AT_CHECK_DYNAMIC_MODULE
AT_CHECK_GMP
-AT_DATA([in], [[load(`mpeval')
+AT_DATA([in], [[include(`mpeval')
-__load__-__mpeval__-
unload(`mpeval')
-__load__-__mpeval__-
@@ -84,7 +84,7 @@ unload(`load')
-__load__-__mpeval__-
]])
-AT_CHECK_M4([-m load in], [0], [[
+AT_CHECK_M4([load in], [0], [[
---
--__mpeval__-
@@ -108,7 +108,7 @@ m4_define([AT_CHECK_M4_MODTEST],
AT_CHECK_DYNAMIC_MODULE
AT_DATA([input.m4],
-[[load(`modtest')
+[[include(`modtest')
test
Dumpdef: dumpdef(`test').
unload(`modtest')
@@ -122,7 +122,7 @@ dnl carry over to the next AT_SETUP.
m4_ifval([$2], [$2
export m4_substr([$2], [0], m4_index([$2], [=]))])
-AT_CHECK_M4([-m load $3 input.m4], [0],
+AT_CHECK_M4([load $3 input.m4], [0],
[[
Test module called.
Dumpdef: .
@@ -141,24 +141,17 @@ AT_CLEANUP
-AT_CHECK_M4_MODTEST([--module-directory: absolute path],
- [], [-M "$abs_builddir"])
+AT_CHECK_M4_MODTEST([--include: absolute path],
+ [], [-I "$abs_builddir"])
-AT_CHECK_M4_MODTEST([--module-directory: relative path],
- [], [-M "$top_build_prefix/tests"])
+AT_CHECK_M4_MODTEST([--include: relative path],
+ [], [-I "$top_build_prefix/tests"])
-AT_CHECK_M4_MODTEST([M4MODPATH: absolute path],
- [M4MODPATH="$abs_builddir"], [])
-
-AT_CHECK_M4_MODTEST([M4MODPATH: relative path],
- [M4MODPATH="$top_build_prefix/tests"], [])
-
-AT_CHECK_M4_MODTEST([LTDL_LIBRARY_PATH: absolute path],
- [LTDL_LIBRARY_PATH="$abs_builddir"], [])
-
-AT_CHECK_M4_MODTEST([LTDL_LIBRARY_PATH: relative path],
- [LTDL_LIBRARY_PATH="$top_build_prefix/tests"], [])
+AT_CHECK_M4_MODTEST([M4PATH: absolute path],
+ [M4PATH="$abs_builddir:"], [])
+AT_CHECK_M4_MODTEST([M4PATH: relative path],
+ [M4PATH="$top_build_prefix/tests:"], [])
@@ -181,7 +174,7 @@ test
shadow
# module Shadow defines `shadow' and `test' macros
-load(`shadow')
+include(`shadow')
dumpdef(`test')
dumpdef(`shadow')
test
@@ -191,14 +184,14 @@ shadow
define(`Shadow::test', defn(`test'))
# module Modtest also defines a `test' macro
-load(`modtest')
+include(`modtest')
dumpdef(`test')
dumpdef(`shadow')
test
shadow
# Reloading Shadow shouldn't affect anything
-load(`shadow')
+include(`shadow')
dumpdef(`test')
dumpdef(`shadow')
test
@@ -296,7 +289,7 @@ test: <test>
shadow: <shadow>
]])
-AT_CHECK_M4([-M "$abs_builddir" -m load input.m4], [0],
+AT_CHECK_M4([-I "$abs_builddir" load input.m4], [0],
[expout], [experr])
AT_CLEANUP
@@ -313,16 +306,16 @@ AT_CHECK_DYNAMIC_MODULE
AT_DATA([[input.m4]],
[[test
__test__
-load(`modtest')
+include(`modtest')
test
__test__
-load(`shadow')
+include(`shadow')
test
__test__
unload(`modtest')
test
__test__
-load(`modtest')
+include(`modtest')
test
__test__
unload(`modtest')
@@ -364,7 +357,7 @@ Test module unloaded.
]])
-AT_CHECK_M4([-M "$abs_builddir" -m load input.m4],
+AT_CHECK_M4([-I "$abs_builddir" load input.m4],
[0], [expout], [experr])
AT_CLEANUP
@@ -387,7 +380,7 @@ AT_CHECK_DYNAMIC_MODULE
AT_DATA([[input.m4]],
[[import
-load(`import')
+include(`import')
import
unload(`modtest')
import
@@ -416,7 +409,9 @@ m4:input.m4:6: cannot load symbol `no_such' from module
`modtest'
m4:input.m4:7: cannot open module `no_such'
]])
-AT_CHECK_M4([-M "$abs_builddir" -m load input.m4],
+ls "$abs_builddir"
+
+AT_CHECK_M4([-I "$abs_builddir" load input.m4],
[1], [expout], [experr])
AT_CLEANUP
@@ -444,7 +439,7 @@ manyargs(1)
manyargs(1,2)
]])
-AT_CHECK_M4([-M "$abs_builddir" -m modtest input.m4], [0],
+AT_CHECK_M4([-I "$abs_builddir" modtest input.m4], [0],
[[modtest
modtest
modtest
@@ -477,11 +472,11 @@ AT_CHECK_DYNAMIC_MODULE
AT_DATA([[input.m4]],
[[test
-load(`shadow')
+include(`shadow')
test
unload(`shadow')
test
-load(`shadow')
+include(`shadow')
test
]])
@@ -501,7 +496,7 @@ m4trace: -1- test -> `Shadow::`test' called.'
]])
-AT_CHECK_M4([-M "$abs_builddir" -m load -t test input.m4],
+AT_CHECK_M4([-I "$abs_builddir" load -t test input.m4],
[0], [expout], [experr])
AT_CLEANUP
@@ -524,10 +519,10 @@ define(`forloop',
define(`_forloop',
`$4`'ifelse($1, `$3', `',
`define(`$1', incr($1))_forloop(`$1', `$2', `$3', `$4')')')
-forloop(`i', `1', `5000', `unload(`gnu')load(`gnu')regexp(`123', `\(4\)?2')')
+forloop(`i', `1', `5000', `unload(`gnu')include(`gnu')regexp(`123',
`\(4\)?2')')
]])
-AT_CHECK_M4([-m load input.m4], [0])
+AT_CHECK_M4([load input.m4], [0])
AT_CLEANUP
@@ -550,7 +545,7 @@ __load__ 3
]])
AT_DATA([in2.m4], [[__load__ 4
-load(`load') 5
+include(`load') 5
__load__ 6
unload(`load') 7
__load__ 8
@@ -558,7 +553,7 @@ unload(`load') 9
__load__ 10
]])
-AT_CHECK_M4([-m load in1.m4 -m load in2.m4], [0],
+AT_CHECK_M4([load in1.m4 load in2.m4], [0],
[[ 1
2
__load__ 3
diff --git a/tests/null.err b/tests/null.err
index d10916d..50ae627 100644
Binary files a/tests/null.err and b/tests/null.err differ
diff --git a/tests/options.at b/tests/options.at
index 4771cda..66abc42 100644
--- a/tests/options.at
+++ b/tests/options.at
@@ -99,7 +99,7 @@ dnl Check that all files are processed even after missing file
AT_DATA([in], [[hello world
]])
AT_CHECK_M4([oops in], [1], [[hello world
-]], [[m4: cannot open 'oops': No such file or directory
+]], [[m4: cannot open file 'oops': No such file or directory
]])
dnl Check that '-' means stdin, even if ./- exists.
@@ -705,7 +705,7 @@ AT_CHECK_M4([-I post -B pre in], [1],
[[in pre/foo
in ./bar
in post/blah
-]], [[m4:in:3: include: cannot open 'bad': No such file or directory
+]], [[m4:in:3: include: cannot open file 'bad': No such file or directory
]])
AT_CLEANUP
@@ -730,7 +730,7 @@ AT_CHECK_M4([--regexp-syntax= in], [0], [[0
]])
AT_CHECK_M4([-rEXTENDED in], [0], [[
-]], [[m4:in:1: warning: regexp: bad regular expression `(': Unmatched ( or \(
+]], [[m4:in:1: warning: regexp: bad regular expression '(': Unmatched ( or \(
]])
AT_CHECK_M4([-rgnu-m4 in], [0], [[0
@@ -742,7 +742,7 @@ AT_CHECK_M4([-r"gnu M4" in], [0], [[0
dnl Test behavior of -r intermixed with files
AT_CHECK_M4([-rEXTENDED in --regexp-syntax in], [0], [[
0
-]], [[m4:in:1: warning: regexp: bad regular expression `(': Unmatched ( or \(
+]], [[m4:in:1: warning: regexp: bad regular expression '(': Unmatched ( or \(
]])
AT_CLEANUP
diff --git a/tests/others.at b/tests/others.at
index b095cc6..b2985a5 100644
--- a/tests/others.at
+++ b/tests/others.at
@@ -145,14 +145,14 @@ AT_DATA([in3.m4],
AT_CHECK_M4([in1.m4/], [1], [], [stderr])
dnl mingw fails with EINVAL rather than the expected ENOTDIR
AT_CHECK([$SED 's/Invalid argument/Not a directory/' stderr], [0],
-[[m4: cannot open 'in1.m4/': Not a directory
+[[m4: cannot open file 'in1.m4/': Not a directory
]])
AT_CHECK_M4([in1.m4], [1], [[
]], [stderr])
dnl mingw fails with EINVAL rather than the expected ENOTDIR
AT_CHECK([$SED 's/Invalid argument/Not a directory/' stderr], [0],
-[[m4:in1.m4:1: include: cannot open 'in2.m4/': Not a directory
+[[m4:in1.m4:1: include: cannot open file 'in2.m4/': Not a directory
]])
AT_CHECK_M4([in2.m4], [0], [[
@@ -163,7 +163,7 @@ AT_CHECK_M4([in3.m4], [1], [[
]], [stderr])
dnl mingw fails with EACCES rather than the expected EISDIR
AT_CHECK([$SED 's/Permission denied/Is a directory/' stderr], [0],
-[[m4:in3.m4:1: include: cannot open '.': Is a directory
+[[m4:in3.m4:1: include: cannot open file '.': Is a directory
]])
AT_CLEANUP
hooks/post-receive
--
GNU M4 source repository
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU M4 source repository branch, master, updated. cvs-readonly-259-g076b2ba,
Gary V. Vaughan <=