summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2008-04-10 11:51:27 -0600
committerEric Blake <ebb9@byu.net>2008-04-10 14:15:51 -0600
commit38f06945a35f382d5f7ab12d8d32184d544ba234 (patch)
tree150dff9be741d4161b69845077166889d5c87571
parente098cd5590ef999997130522698cbccc9e083930 (diff)
downloadm4-38f06945a35f382d5f7ab12d8d32184d544ba234.tar.gz
Allow back-referenced macro names; fixes 2008-03-13 regression.
* m4/m4module.h (m4_symbol_value_lookup): Change prototype. * m4/utility.c (m4_symbol_value_lookup): Change signature. * modules/m4.c (undefine, popdef, ifdef, m4_dump_symbols, defn): Adjust all callers. * tests/others.at (ifndef): New test. Signed-off-by: Eric Blake <ebb9@byu.net>
-rw-r--r--ChangeLog7
-rw-r--r--m4/m4module.h2
-rw-r--r--m4/utility.c8
-rw-r--r--modules/m4.c26
-rw-r--r--tests/others.at33
5 files changed, 53 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index c857a441..26906ff4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-04-10 Eric Blake <ebb9@byu.net>
+ Allow back-referenced macro names; fixes 2008-03-13 regression.
+ * m4/m4module.h (m4_symbol_value_lookup): Change prototype.
+ * m4/utility.c (m4_symbol_value_lookup): Change signature.
+ * modules/m4.c (undefine, popdef, ifdef, m4_dump_symbols, defn):
+ Adjust all callers.
+ * tests/others.at (ifndef): New test.
+
Be namespace clean for M4 version; fixes 2008-04-08 regression.
* configure.ac (version): Rename...
(M4_VERSION): ...to this, since using 'version' broke po.m4.
diff --git a/m4/m4module.h b/m4/m4module.h
index 357baca2..5c1f4e8b 100644
--- a/m4/m4module.h
+++ b/m4/m4module.h
@@ -165,7 +165,7 @@ extern bool m4_bad_argc (m4 *, int, const char *, size_t, size_t,
extern bool m4_numeric_arg (m4 *, const char *, const char *, int *);
extern bool m4_parse_truth_arg (m4 *, const char *, const char *, bool);
extern m4_symbol *m4_symbol_value_lookup (m4 *, const char *,
- m4_symbol_value *, bool);
+ m4_macro_args *, size_t, bool);
/* Error handling. */
extern void m4_error (m4 *, int, int, const char *, const char *, ...)
diff --git a/m4/utility.c b/m4/utility.c
index 1e17d610..2cd4d18c 100644
--- a/m4/utility.c
+++ b/m4/utility.c
@@ -125,12 +125,12 @@ m4_parse_truth_arg (m4 *context, const char *arg, const char *me,
result of the lookup, or NULL. */
m4_symbol *
m4_symbol_value_lookup (m4 *context, const char *caller,
- m4_symbol_value *value, bool must_exist)
+ m4_macro_args *argv, size_t i, bool must_exist)
{
m4_symbol *result = NULL;
- if (m4_is_symbol_value_text (value))
+ if (m4_is_arg_text (argv, i))
{
- const char *name = m4_get_symbol_value_text (value);
+ const char *name = M4ARG (i);
result = m4_symbol_lookup (M4SYMTAB, name);
if (must_exist && !result)
m4_warn (context, 0, caller, _("undefined macro `%s'"), name);
@@ -153,7 +153,7 @@ m4_verror_at_line (m4 *context, bool warn, int status, int errnum,
char *full = NULL;
char *safe_macro = NULL;
- /* Sanitize MACRO, sinze we are turning around and using it in a
+ /* Sanitize MACRO, since we are turning around and using it in a
format string. The allocation is overly conservative, but
problematic macro names only occur via indir or changesyntax. */
if (macro && strchr (macro, '%'))
diff --git a/modules/m4.c b/modules/m4.c
index 02ac090d..d484f4db 100644
--- a/modules/m4.c
+++ b/modules/m4.c
@@ -169,11 +169,8 @@ M4BUILTIN_HANDLER (undefine)
const char *me = M4ARG (0);
size_t i;
for (i = 1; i < argc; i++)
- {
- m4_symbol_value *value = m4_arg_symbol (argv, i);
- if (m4_symbol_value_lookup (context, me, value, true))
- m4_symbol_delete (M4SYMTAB, m4_get_symbol_value_text (value));
- }
+ if (m4_symbol_value_lookup (context, me, argv, i, true))
+ m4_symbol_delete (M4SYMTAB, M4ARG (i));
}
M4BUILTIN_HANDLER (pushdef)
@@ -194,11 +191,8 @@ M4BUILTIN_HANDLER (popdef)
const char *me = M4ARG (0);
size_t i;
for (i = 1; i < argc; i++)
- {
- m4_symbol_value *value = m4_arg_symbol (argv, i);
- if (m4_symbol_value_lookup (context, me, value, true))
- m4_symbol_popdef (M4SYMTAB, m4_get_symbol_value_text (value));
- }
+ if (m4_symbol_value_lookup (context, me, argv, i, true))
+ m4_symbol_popdef (M4SYMTAB, M4ARG (i));
}
@@ -209,8 +203,7 @@ M4BUILTIN_HANDLER (popdef)
M4BUILTIN_HANDLER (ifdef)
{
m4_push_arg (context, obs, argv,
- (m4_symbol_value_lookup (context, M4ARG (0),
- m4_arg_symbol (argv, 1), false)
+ (m4_symbol_value_lookup (context, M4ARG (0), argv, 1, false)
? 2 : 3));
}
@@ -308,11 +301,9 @@ m4_dump_symbols (m4 *context, m4_dump_symbol_data *data, size_t argc,
for (i = 1; i < argc; i++)
{
- m4_symbol_value *value = m4_arg_symbol (argv, i);
- symbol = m4_symbol_value_lookup (context, me, value, complain);
+ symbol = m4_symbol_value_lookup (context, me, argv, i, complain);
if (symbol)
- dump_symbol_CB (NULL, m4_get_symbol_value_text (value), symbol,
- data);
+ dump_symbol_CB (NULL, M4ARG (i), symbol, data);
}
}
@@ -365,8 +356,7 @@ M4BUILTIN_HANDLER (defn)
for (i = 1; i < argc; i++)
{
- m4_symbol_value *value = m4_arg_symbol (argv, i);
- m4_symbol *symbol = m4_symbol_value_lookup (context, me, value, true);
+ m4_symbol *symbol = m4_symbol_value_lookup (context, me, argv, i, true);
if (!symbol)
;
diff --git a/tests/others.at b/tests/others.at
index fbd692b9..22e8b994 100644
--- a/tests/others.at
+++ b/tests/others.at
@@ -273,6 +273,39 @@ Move one disk from source to destination.
AT_CLEANUP
+## ------ ##
+## ifndef ##
+## ------ ##
+
+AT_SETUP([ifndef])
+
+dnl This catches a bug added 2008-03-13, fixed 2008-04-10.
+AT_DATA([in.m4],
+[[define(`ifndef', `ifdef(`$1', `$3', `$2')')dnl
+define(`a_really_long_name', `1')dnl
+ifdef(`divnum', `yes', `no')
+ifndef(`divnum', `yes', `no')
+ifdef(`ifndef', `yes', `no')
+ifndef(`ifndef', `yes', `no')
+ifdef(`a_really_long_name', `yes', `no')
+ifndef(`a_really_long_name', `yes', `no')
+ifdef(`no_such', `yes', `no')
+ifndef(`no_such', `yes', `no')
+]])
+
+AT_CHECK_M4([in.m4], [0],
+[[yes
+no
+yes
+no
+yes
+no
+no
+yes
+]])
+
+AT_CLEANUP
+
## ------- ##
## iso8859 ##