[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
m4 -Dfoo regression
From: |
Eric Blake |
Subject: |
m4 -Dfoo regression |
Date: |
Mon, 11 Feb 2008 21:15:50 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
In trying to port the next argv_ref patch to the master branch, I discovered a
regression that I introduced several months ago, when I tried to improve
minimum and maximum argument counts for macros:
$ echo 'foo(one)' | m4-1.4.10 -Dfoo='$1'
one
$ echo 'foo(one)' | m4 -Dfoo='$1'
m4:stdin:1: Warning: foo: extra arguments ignored: 1 > 0
one
In other words, I missed setting the maximum argument count correctly for
command-line defines, causing a spurious warning. It's a shame that it went
this long without detection; our testsuite could definitely hammer out command
line interface behavior better.
And while fixing this, I decided that __gnu__() should warn rather than
silently ignore its argument, since the definition does not require any
arguments. So I made an ABI-incompatible change to allow modules to request
how many arguments a text macro should take (this still does not address the
TODO item on allowing the user to do this at runtime for any macro, but that
can come another day). This patch is for master; for the branch, I only
augmented the tests to make sure that these code paths are tested, but did not
change behavior since there was no regression to worry about.
From: Eric Blake <address@hidden>
Date: Mon, 11 Feb 2008 11:32:12 -0700
Subject: [PATCH] Fix regression in command line -D option, from 2006-08-25.
* m4/m4private.h (m4_symbol_value_create): Delete fast accessor.
* m4/m4module.h: Fix typo.
* m4/symtab.c (m4_symbol_value_create): Prime the maximum number
of arguments.
* tests/macros.at (Command line define): Enhance test.
* tests/others.at (nul character): Enhance test.
* tests/null.m4: Likewise.
* tests/null.out: Likewise.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 10 +++++
m4/m4module.h | 2 +-
m4/m4private.h | 3 +-
m4/symtab.c | 4 ++-
tests/macros.at | 9 +++++
tests/null.m4 | 109 +++++++++++++++++++++++++++++++++++++++----------------
tests/null.out | 5 ++-
tests/others.at | 10 ++++-
8 files changed, 113 insertions(+), 39 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index faf80eb..d9b0175 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2008-02-11 Eric Blake <address@hidden>
+ Fix regression in command line -D option, from 2006-08-25.
+ * m4/m4private.h (m4_symbol_value_create): Delete fast accessor.
+ * m4/m4module.h: Fix typo.
+ * m4/symtab.c (m4_symbol_value_create): Prime the maximum number
+ of arguments.
+ * tests/macros.at (Command line define): Enhance test.
+ * tests/others.at (nul character): Enhance test.
+ * tests/null.m4: Likewise.
+ * tests/null.out: Likewise.
+
Use gnulib's git-merge-changelog driver when available.
* .gitattributes: Add merge attributes for ChangeLog.
* bootstrap: Install driver, if not already present.
diff --git a/m4/m4module.h b/m4/m4module.h
index bdb31a3..5f144be 100644
--- a/m4/m4module.h
+++ b/m4/m4module.h
@@ -67,7 +67,7 @@ struct m4_builtin
const char * name; /* name found by builtin, printed by dumpdef */
int flags; /* bitwise OR of M4_BUILTIN_* bits */
size_t min_args; /* 0-based minimum number of arguments */
- /* max arguments, UINT_MAX if unlimited; must be >= min_args */
+ /* max arguments, SIZE_MAX if unlimited; must be >= min_args */
size_t max_args;
};
diff --git a/m4/m4private.h b/m4/m4private.h
index 28ac867..77590f3 100644
--- a/m4/m4private.h
+++ b/m4/m4private.h
@@ -330,8 +330,7 @@ extern void m4__push_arg_quote (m4 *, m4_obstack *,
m4_macro_args *,
# define m4_get_symbol_value(S) ((S)->value)
# define m4_set_symbol_value(S, V) ((S)->value = (V))
-# define m4_symbol_value_create() xzalloc (sizeof (m4_symbol_value))
-/* m4_symbol_value_delete is too complex for a simple macro. */
+/* m4_symbol_value_{create,delete} are too complex for a simple macro. */
# define m4_is_symbol_value_text(V) ((V)->type == M4_SYMBOL_TEXT)
# define m4_is_symbol_value_func(V) ((V)->type == M4_SYMBOL_FUNC)
diff --git a/m4/symtab.c b/m4/symtab.c
index 0d2055e..f302fe8 100644
--- a/m4/symtab.c
+++ b/m4/symtab.c
@@ -674,7 +674,9 @@ m4_get_symbol_traced (m4_symbol *symbol)
m4_symbol_value *
m4_symbol_value_create (void)
{
- return xzalloc (sizeof (m4_symbol_value));
+ m4_symbol_value *value = xzalloc (sizeof (m4_symbol_value));
+ VALUE_MAX_ARGS (value) = SIZE_MAX;
+ return value;
}
#undef m4_symbol_value_groks_macro
diff --git a/tests/macros.at b/tests/macros.at
index 3d74356..d0dd7e1 100644
--- a/tests/macros.at
+++ b/tests/macros.at
@@ -140,6 +140,15 @@ AT_CHECK_M4([-Ufoo in -Dfoo=bar in], [0], [[foo
bar
]])
+dnl Test macro arguments defined via -D
+AT_DATA([in], [[-foo-foo(1)-foo(1,2)-
+-bar-bar(1)-bar(1,2)-
+]])
+AT_CHECK_M4([-Dfoo -Dbar='$@' in], [0],
+[[----
+--1-1,2-
+]])
+
AT_CLEANUP
diff --git a/tests/null.m4 b/tests/null.m4
index e6e1816..2fa38dd 100644
--- a/tests/null.m4
+++ b/tests/null.m4
@@ -1,4 +1,6 @@
-# This file tests m4 behavior on NUL bytes
+# This file tests m4 behavior on NUL bytes.
+dnl Use `m4 -Dm4exit' to test rest of file. NUL not a number, needs to warn
+m4exit(`22')dnl
dnl Raw pass-through:
raw: --
dnl Embedded in quotes:
@@ -7,88 +9,131 @@ dnl Embedded in comments:
commented: #--
dnl Passed through $1, $*, $@:
define(`echo', address@hidden')define(`', `empty')dnl
+define(`-', `dash')define(`--', `dashes')dnl
user: echo(--,`11')
-dnl All macros matching __*__ take no arguments, and never produce NUL
+dnl All macros matching __*__ take no arguments, and never produce NUL.
dnl First argument of builtin: not tested yet. No builtin includes NUL, so
dnl this needs to warn, but warning output needs quoting.
dnl Remaining arguments of builtin:
`builtin:' builtin(`len', --)
-dnl changecom: not tested yet
-dnl changequote: not tested yet
-dnl changeresyntax: not tested yet. No resyntax includes NUL, needs to warn
-dnl changesyntax: not tested yet
-dnl debugfile: not tested yet. No file name includes NUL, needs to warn
-dnl debugmode: not tested yet. NUL not a valid mode, needs to warn
-dnl decr: not tested yet. NUL not a number, needs to warn
+dnl Single-byte delimiter in changecom: not tested yet
+dnl Multi-byte delimiter in changecom: not tested yet
+dnl Single-byte delimiter in changequote: not tested yet
+dnl Multi-byte delimiter in changequote: not tested yet
+dnl Quotes in trace and dump output: not tested yet
+dnl Warning from changeresyntax: not tested yet. No resyntax includes NUL,
needs to warn
+dnl Macro name in changesyntax: not tested yet
+dnl Escape in changesyntax: not tested yet
+dnl Ignored by changesyntax: TODO - support ignored category?
+dnl Warning from debugfile: not tested yet. No file name includes NUL, needs
to warn
+dnl Warning from debugmode: not tested yet. NUL not a valid mode, needs to warn
+dnl Warning from decr: not tested yet. NUL not a number, needs to warn
dnl Macro name of define:
define(`--', `odd name: $1')dnl
dnl Definition of define: not tested yet
-dnl Macro name in defn:
+dnl Undefined argument of defn: not tested yet
+dnl Defined macro name in defn:
`defn:' defn(`--')
dnl Macro contents in defn: not tested yet
-dnl divert: not tested yet. NUL not a number, needs to warn
-dnl divnum: Takes no arguments, and never produces NUL.
+dnl Argument to divert: not tested yet. NUL not a number, needs to warn
+dnl Passed through diversion by divert:
+divert(`1')`divert:' --
+divert`'undivert(`1')dnl
+dnl Divnum takes no arguments, and never produces NUL.
dnl Discarded by dnl: --
-dnl dumpdef: not tested yet. Needs to quote properly.
+dnl Undefined argument of dumpdef: not tested yet. Needs to quote properly.
+dnl Defined macro names in dumpdef: not tested yet
+dnl Macro contents in dumpdef: not tested yet
dnl Passed through errprint:
errprint(`errprint:' --, `--
')dnl
dnl Passed to esyscmd: not tested yet. NUL truncates string, needs to warn
dnl Generated from esyscmd:
`esyscmd:' esyscmd(`printf "[\\0]"')
-dnl eval: not tested yet. NUL not a number, needs to warn
-dnl format: not tested yet. Should %s string truncation warn?
+dnl First argument of eval: not tested yet. NUL not a number, needs to warn
+dnl Other arguments of eval: not tested yet. NUL not a number, needs to warn
+dnl First argument to format: not tested yet
+dnl Invalid specifier in format: not tested yet, needs to warn
+dnl Numeric and string arguments to format: not tested yet, needs to warn
+dnl Character argument to format: not tested yet, %c semantics needed
dnl Macro name in ifdef, passed through ifdef:
`ifdef:' ifdef(`--', `yes: --', `oops: --')dnl
ifdef(, `oops: --', `no: --')
dnl Compared in ifelse, passed through ifelse:
`ifelse:' ifelse(`-', `--', `oops', `--', --, `yes: --')
-dnl include: not tested yet. No file name includes NUL, needs to warn
-dnl incr: not tested yet. NUL not a number, needs to warn
+dnl Warning from include: not tested yet. No file name includes NUL, needs to
warn
+dnl Warning from incr: not tested yet. NUL not a number, needs to warn
dnl Passed through index:
`index:' index(`ab', `b') index(`-', `') index(`', `-')dnl
index(`-', `-')
dnl Defined first argument of indir:
`indir:' indir(`--', 11)dnl
dnl Undefined first argument of indir: not tested yet. Needs to warn
+dnl Warning issued via indir: not tested yet
dnl Other arguments of indir:
indir(`len', `--')
dnl Passed through len:
`len:' len() len(--)
-dnl m4exit: not tested yet. NUL not a number, needs to warn.
-dnl m4symbols: not tested yet
+dnl Test m4exit separately from m4wrap; see above.
+dnl Undefined macro name in m4symbols: not tested yet, needs to warn
+dnl Defined macro name in m4symbols: not tested yet
dnl Passed through m4wrap: not working yet
m4wrap(``m4wrap:' -
-
')dnl
-dnl maketemp: not tested yet. No file name includes NUL, needs to warn
-dnl mkdtemp: not tested yet. No file name includes NUL, needs to warn
-dnl mkstemp: not tested yet. No file name includes NUL, needs to warn
-dnl patsubst: not tested yet
+dnl Warning from maketemp: not tested yet. No file name includes NUL, needs to
warn
+dnl Warning from mkdtemp: not tested yet. No file name includes NUL, needs to
warn
+dnl Warning from mkstemp: not tested yet. No file name includes NUL, needs to
warn
+dnl Bad regex in patsubst: not tested yet
+dnl First argument of patsubst:
+`patsubst:' patsubst(`--', `-', `.')dnl
+dnl Matching via meta-character in patsubst:
+ patsubst(`--', `[^-]')dnl
+dnl Second argument of patsubst:
+ patsubst(`abc', `b', `-') patsubst(`--', `', `!')dnl
+dnl Third argument of patsubst: not tested yet
+dnl Syntax argument of patsubst: not tested yet, needs to warn
+dnl Replacement via reference in patsubst:
+ patsubst(`----', `-\(.\)-', `\1-\1')
dnl Defined argument of popdef:
`popdef:' popdef(`--')ifdef(`--', `oops', `ok')
dnl Undefined argument of popdef: not tested yet. Should it warn?
dnl Macro name of pushdef:
`pushdef:' pushdef(`--', `strange: $1')ifdef(`--', `ok', `oops')
dnl Definition of pushdef: not tested yet
-dnl regexp: not tested yet
-dnl renamesyms: not tested yet
+dnl Bad regex in regexp: not tested yet
+dnl First argument of regexp:
+`regexp:' regexp(`ab', `b')dnl
+dnl Matching via meta-character in regexp:
+ regexp(`--', `[^-]', `!')dnl
+dnl Second argument of regexp:
+ regexp(`--', `')dnl
+dnl Third argument of regexp: not tested yet
+dnl Syntax argument of patsubst: not tested yet, needs to warn
+dnl Replacement via reference in regexp:
+ regexp(`----', `-\(.\)-', `\1-\1')
+dnl Bad regex in renamesyms: not tested yet
+dnl Direct rename via renamesyms: not tested yet
+dnl Meta-character rename via renamesyms: not tested yet
dnl Passed through shift:
`shift:' shift(`hi', `--', --)
-dnl sinclude: not tested yet. No file name includes NUL, needs to warn
+dnl Warning from sinclude: not tested yet. No file name includes NUL, needs to
warn
dnl First argument of substr:
`substr:' substr(`----', `1', `3')
dnl Other arguments of substr: not tested yet. NUL not a number, needs to warn.
-dnl syncoutput: not tested yet. No mode contains NUL, needs to warn
-dnl syscmd: not tested yet. NUL truncates string, needs to warn
-dnl sysval: Takes no arguments, and never produces NUL.
+dnl Warning from syncoutput: not tested yet. No mode contains NUL, needs to
warn
+dnl Passed to syscmd: not tested yet. NUL truncates string, needs to warn
+dnl Sysval takes no arguments, and never produces NUL.
dnl Passed to traceoff:
traceoff(`--', `')dnl
-dnl traceon: not tested yet. Trace output needs quoting
+dnl Macro name and arguments of traceon: not tested yet. Trace output needs
quoting
`traceon:' indir(`--', `--')
-dnl translit: not tested yet
+dnl Defined text of traceon: not tested yet. Needs tracing indirect macros
+dnl First argument of translit: not tested yet
+dnl Single character in other arguments of translit: not tested yet
+dnl Character ranges of translit: not tested yet
dnl Defined argument of undefine:
`undefine:' undefine(`--')ifdef(`--', `oops', `ok')
dnl Undefined argument of undefine: not tested yet. Should it warn?
-dnl undivert: not tested yet. No file name or number includes NUL, needs to
warn
+dnl Warning from undivert: not tested yet. No file name or number includes
NUL, needs to warn
dnl other modules need to be tested independently
diff --git a/tests/null.out b/tests/null.out
index 6e8a114..c42e03c 100644
--- a/tests/null.out
+++ b/tests/null.out
@@ -1,18 +1,21 @@
-# This file tests m4 behavior on NUL bytes
+# This file tests m4 behavior on NUL bytes.
raw: --
quoted: --
commented: #--
user: .--.--,11.--,11.
builtin: 3
defn: odd name: $1
+divert: --
esyscmd: []
ifdef: yes: -- oops: --
ifelse: yes: --
index: 2 -1 -1 8
indir: odd name: 11 3
len: 1 3
+patsubst: .. -- abc -!- ---
popdef: ok
pushdef: ok
+regexp: 2 ! 0 -
shift: --,--
substr: --
traceon: strange: --
diff --git a/tests/others.at b/tests/others.at
index bb6254a..0b58c29 100644
--- a/tests/others.at
+++ b/tests/others.at
@@ -1,5 +1,5 @@
# Hand crafted tests for GNU M4. -*- Autotest -*-
-# Copyright (C) 2001, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2006, 2007, 2008 Free Software Foundation, Inc.
# This file is part of GNU M4.
#
@@ -321,7 +321,13 @@ AT_SETUP([nul character])
cp "$abs_srcdir/null.out" expout
cp "$abs_srcdir/null.err" experr
-AT_CHECK_M4(["$abs_srcdir/null.m4"], [0], [expout], [experr])
+dnl all but m4exit
+AT_CHECK_M4([-Dm4exit "$abs_srcdir/null.m4"], [0], [expout], [experr])
+
+dnl just m4exit
+AT_CHECK_M4(["$abs_srcdir/null.m4"], [2],
+[[# This file tests m4 behavior on NUL bytes.
+]])
AT_CLEANUP
--
1.5.4
>From 4af40c4d6f65e3d311ef4643b6b3bdb9729a9db6 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 11 Feb 2008 07:14:20 -0700
Subject: [PATCH] Allow builtin text macros to specify number of arguments.
* m4/m4module.h (struct m4_macro): Add argument limits to builtin
text macros.
* m4/module.c (install_macro_table): Allow text macros to warn on
extra arguments.
* modules/gnu.c (m4_macro_table): Update all clients.
* modules/load.c (m4_macro_table): Likewise.
* modules/mpeval.c (m4_macro_table): Likewise.
* modules/perl.c (m4_macro_table): Likewise.
* modules/shadow.c (m4_macro_table): Likewise.
* modules/traditional.c (m4_macro_table): Likewise.
* modules/modtest.c (m4_macro_table): Likewise. Also add text
macros, for testing this.
* doc/m4.texinfo (Standard Modules): Update text, and enhance
test.
* tests/modules.at (modules: text): New test.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 17 +++++++++++++++++
doc/m4.texinfo | 24 +++++++++++++++++++++---
m4/m4module.h | 3 +++
m4/module.c | 7 ++++++-
modules/gnu.c | 14 +++++++-------
modules/load.c | 9 +++++----
modules/modtest.c | 12 +++++++-----
modules/mpeval.c | 9 +++++----
modules/perl.c | 6 +++---
modules/shadow.c | 9 +++++----
modules/traditional.c | 14 +++++++-------
tests/modules.at | 44 +++++++++++++++++++++++++++++++++++++++++++-
12 files changed, 129 insertions(+), 39 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d9b0175..2554a45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2008-02-11 Eric Blake <address@hidden>
+ Allow builtin text macros to specify number of arguments.
+ * m4/m4module.h (struct m4_macro): Add argument limits to builtin
+ text macros.
+ * m4/module.c (install_macro_table): Allow text macros to warn on
+ extra arguments.
+ * modules/gnu.c (m4_macro_table): Update all clients.
+ * modules/load.c (m4_macro_table): Likewise.
+ * modules/mpeval.c (m4_macro_table): Likewise.
+ * modules/perl.c (m4_macro_table): Likewise.
+ * modules/shadow.c (m4_macro_table): Likewise.
+ * modules/traditional.c (m4_macro_table): Likewise.
+ * modules/modtest.c (m4_macro_table): Likewise. Also add text
+ macros, for testing this.
+ * doc/m4.texinfo (Standard Modules): Update text, and enhance
+ test.
+ * tests/modules.at (modules: text): New test.
+
Fix regression in command line -D option, from 2006-08-25.
* m4/m4private.h (m4_symbol_value_create): Delete fast accessor.
* m4/m4module.h: Fix typo.
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 642c14e..357358f 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -5804,7 +5804,9 @@ refcount(`NoSuchModule')
@acronym{GNU} @code{m4} ships with several bundled modules as standard.
By convention, these modules define a text macro that can be tested
with @code{ifdef} when they are loaded; only the @code{m4} module lacks
-this feature test macro.
+this feature test macro, since it is not permitted by @acronym{POSIX}.
+Each of the feature test macros are intended to be used without
+arguments.
@table @code
@item m4
@@ -5823,8 +5825,8 @@ module is loaded.
@end deffn
@deffn {Macro (gnu)} __m4_version__
-Expands to a quoted string containing the release version number of the
-running @acronym{GNU} @code{m4} executable.
+Expands to an unquoted string containing the release version number of
+the running @acronym{GNU} @code{m4} executable.
@end deffn
This module is always loaded, unless the @option{-G} command line
@@ -5871,6 +5873,9 @@ __gnu__-__traditional__
@result{}-__traditional__
ifdef(`__gnu__', `Extensions are active', `Minimal features')
@result{}Extensions are active
+__gnu__(`ignored')
address@hidden:stdin:3: Warning: __gnu__: extra arguments ignored: 1 > 0
address@hidden
@end example
@comment options: -G
@@ -5882,6 +5887,19 @@ ifdef(`__gnu__', `Extensions are active', `Minimal
features')
@result{}Minimal features
@end example
+Since the version string is unquoted and can potentially contain macro
+names (consider the beta release @samp{1.9b}, or the use of
address@hidden), the @code{__m4_version__} macro should generally
+be used via @code{defn} rather than directly invoked.
+
address@hidden This test is excluded from the testsuite since it depends on a
address@hidden texinfo macro; but builtin.at covers the same thing.
address@hidden ignore
address@hidden
+defn(`__m4_version__')
address@hidden@value{VERSION}
address@hidden example
+
@node Text handling
@chapter Macros for text handling
diff --git a/m4/m4module.h b/m4/m4module.h
index 5f144be..a807e70 100644
--- a/m4/m4module.h
+++ b/m4/m4module.h
@@ -75,6 +75,9 @@ struct m4_macro
{
const char *name;
const char *value;
+ size_t min_args; /* 0-based minimum number of arguments */
+ /* max arguments, SIZE_MAX if unlimited; must be >= min_args */
+ size_t max_args;
};
/* Describe a pair of strings, such as begin and end quotes. */
diff --git a/m4/module.c b/m4/module.c
index 901a48f..7ef6ab3 100644
--- a/m4/module.c
+++ b/m4/module.c
@@ -1,6 +1,6 @@
/* GNU m4 -- A simple macro processor
Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1998, 1999, 2002, 2003,
- 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of GNU M4.
@@ -195,9 +195,14 @@ install_macro_table (m4 *context, m4_module *module)
m4_symbol_value *value = m4_symbol_value_create ();
size_t len = strlen (mp->value);
+ /* Sanity check that builtins meet the required interface. */
+ assert (mp->min_args <= mp->max_args);
+
m4_set_symbol_value_text (value, xmemdup (mp->value, len + 1),
len, 0);
VALUE_MODULE (value) = module;
+ VALUE_MIN_ARGS (value) = mp->min_args;
+ VALUE_MAX_ARGS (value) = mp->max_args;
m4_symbol_pushdef (M4SYMTAB, mp->name, value);
}
diff --git a/modules/gnu.c b/modules/gnu.c
index 1f6bf29..10fb0ac 100644
--- a/modules/gnu.c
+++ b/modules/gnu.c
@@ -85,20 +85,20 @@ m4_builtin m4_builtin_table[] =
/* A table for mapping m4 symbol names to simple expansion text. */
m4_macro m4_macro_table[] =
{
- /* name text */
+ /* name text min max */
#if UNIX
- { "__unix__", "" },
+ { "__unix__", "", 0, 0 },
#elif W32_NATIVE
- { "__windows__", "" },
+ { "__windows__", "", 0, 0 },
#elif OS2
- { "__os2__", "" },
+ { "__os2__", "", 0, 0 },
#else
# warning Platform macro not provided
#endif
- { "__gnu__", "" },
- { "__m4_version__", VERSION/**/TIMESTAMP },
+ { "__gnu__", "", 0, 0 },
+ { "__m4_version__", VERSION/**/TIMESTAMP, 0, 0 },
- { NULL, NULL },
+ { NULL, NULL, 0, 0 },
};
diff --git a/modules/load.c b/modules/load.c
index 4ee1cc6..5ea7242 100644
--- a/modules/load.c
+++ b/modules/load.c
@@ -1,5 +1,6 @@
/* GNU m4 -- A simple macro processor
- Copyright (C) 2000, 2005, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2005, 2006, 2007, 2008 Free Software
+ Foundation, Inc.
This file is part of GNU M4.
@@ -65,9 +66,9 @@ m4_builtin m4_builtin_table[] =
/* A table for mapping m4 symbol names to simple expansion text. */
m4_macro m4_macro_table[] =
{
- /* name text */
- { "__load__", "" },
- { NULL, NULL },
+ /* name text min max */
+ { "__load__", "", 0, 0 },
+ { NULL, NULL, 0, 0 },
};
diff --git a/modules/modtest.c b/modules/modtest.c
index 022a2ef..f2d39ea 100644
--- a/modules/modtest.c
+++ b/modules/modtest.c
@@ -1,6 +1,6 @@
/* GNU m4 -- A simple macro processor
- Copyright (C) 1999, 2000, 2001, 2003, 2004, 2006, 2007 Free Software
- Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2003, 2004, 2006, 2007, 2008 Free
+ Software Foundation, Inc.
This file is part of GNU M4.
@@ -61,9 +61,11 @@ m4_builtin m4_builtin_table[] =
m4_macro m4_macro_table[] =
{
- /* name text */
- { "__test__", "`modtest'" },
- { NULL, NULL },
+ /* name text min max */
+ { "__test__", "`modtest'", 0, 0 },
+ { "onearg", "$1", 1, 1 },
+ { "manyargs", "$@", 0, SIZE_MAX },
+ { NULL, NULL, 0, 0 },
};
diff --git a/modules/mpeval.c b/modules/mpeval.c
index e70eb09..ab9a040 100644
--- a/modules/mpeval.c
+++ b/modules/mpeval.c
@@ -1,5 +1,6 @@
/* GNU m4 -- A simple macro processor
- Copyright (C) 2000, 2001, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2006, 2007, 2008 Free Software
+ Foundation, Inc.
This file is part of GNU M4.
@@ -123,9 +124,9 @@ m4_builtin m4_builtin_table[] =
/* A table for mapping m4 symbol names to simple expansion text. */
m4_macro m4_macro_table[] =
{
- /* name text */
- { "__mpeval__", "" },
- { NULL, NULL },
+ /* name text min max */
+ { "__mpeval__", "", 0, 0 },
+ { NULL, NULL, 0, 0 },
};
diff --git a/modules/perl.c b/modules/perl.c
index 46cf2cd..61db803 100644
--- a/modules/perl.c
+++ b/modules/perl.c
@@ -64,9 +64,9 @@ m4_builtin m4_builtin_table[] =
/* A table for mapping m4 symbol names to simple expansion text. */
m4_macro m4_macro_table[] =
{
- /* name text */
- { "__perleval__", "" },
- { NULL, NULL },
+ /* name text min max */
+ { "__perleval__", "", 0, 0 },
+ { NULL, NULL, 0, 0 },
};
diff --git a/modules/shadow.c b/modules/shadow.c
index 3698b4f..1a15798 100644
--- a/modules/shadow.c
+++ b/modules/shadow.c
@@ -1,5 +1,6 @@
/* GNU m4 -- A simple macro processor
- Copyright (C) 1999, 2000, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2006, 2007, 2008 Free Software
+ Foundation, Inc.
This file is part of GNU M4.
@@ -58,9 +59,9 @@ m4_builtin m4_builtin_table[] =
m4_macro m4_macro_table[] =
{
- /* name text */
- { "__test__", "`shadow'" },
- { NULL, NULL },
+ /* name text min max */
+ { "__test__", "`shadow'", 0, 0 },
+ { NULL, NULL, 0, 0 },
};
diff --git a/modules/traditional.c b/modules/traditional.c
index 9fc2e81..13a112d 100644
--- a/modules/traditional.c
+++ b/modules/traditional.c
@@ -1,5 +1,5 @@
/* GNU m4 -- A simple macro processor
- Copyright (C) 2000, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of GNU M4.
@@ -33,16 +33,16 @@
/* A table for mapping m4 symbol names to simple expansion text. */
m4_macro m4_macro_table[] =
{
- /* name text */
+ /* name text min max */
#if UNIX
- { "unix", "" },
+ { "unix", "", 0, 0 },
#elif W32_NATIVE
- { "windows", "" },
+ { "windows", "", 0, 0 },
#elif OS2
- { "os2", "" },
+ { "os2", "", 0, 0 },
#else
# warning Platform macro not provided
#endif
- { "__traditional__", "" },
- { NULL, NULL },
+ { "__traditional__", "", 0, 0 },
+ { NULL, NULL, 0, 0 },
};
diff --git a/tests/modules.at b/tests/modules.at
index 86f1388..0d81848 100644
--- a/tests/modules.at
+++ b/tests/modules.at
@@ -1,5 +1,5 @@
# Hand crafted tests for GNU M4. -*- Autotest -*-
-# Copyright (C) 2001, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2006, 2007, 2008 Free Software Foundation, Inc.
# This file is part of GNU M4.
#
@@ -422,6 +422,48 @@ AT_CLEANUP
+## ------------------- ##
+## text module symbols ##
+## ------------------- ##
+
+# Support text macros with requested numbers of parameters.
+
+AT_SETUP([modules: text])
+AT_CHECK_DYNAMIC_MODULE
+
+AT_DATA([input.m4],
+[[__test__
+__test__(1)
+__test__(1,2)
+onearg
+onearg(1)
+onearg(1,2)
+manyargs
+manyargs(1)
+manyargs(1,2)
+]])
+
+AT_CHECK_M4([-M "$abs_builddir" -m modtest input.m4], [0],
+[[modtest
+modtest
+modtest
+
+1
+1
+
+1
+1,2
+]], [[Test module loaded.
+m4:input.m4:2: Warning: __test__: extra arguments ignored: 1 > 0
+m4:input.m4:3: Warning: __test__: extra arguments ignored: 2 > 0
+m4:input.m4:4: Warning: onearg: too few arguments: 0 < 1
+m4:input.m4:6: Warning: onearg: extra arguments ignored: 2 > 1
+Test module unloaded.
+]])
+
+AT_CLEANUP
+
+
## -------------------- ##
## trace module symbols ##
## -------------------- ##
--
1.5.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- m4 -Dfoo regression,
Eric Blake <=