[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: 14-gary-move-traced-flag-to-token-data.patch
From: |
Gary V. Vaughan |
Subject: |
FYI: 14-gary-move-traced-flag-to-token-data.patch |
Date: |
Tue, 18 Sep 2001 02:14:02 +0100 |
User-agent: |
Mutt/1.3.22.1i |
Index: ChangeLog
from Gary V. Vaughan <address@hidden>
The `traced' flag needs to be attached to the definition of a
symbol rather than the current symbol containing the definition.
Implementing this showed up some long standing post 1.4 bugs in
flag propogation which I also fixed.
* m4/m4private.h (struct m4_symbol): Remove the traced flag.
(struct m4_token_data): And add it back in here.
* m4/input.c (init_macro_token): Propogate the traced flag
correctly.
* m4/macro.c (expand_argument): Ditto.
* tests/builtins.at (trace2, trace3): New tests based on Akim's
sadistic email ;-)
Index: m4/input.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/input.c,v
retrieving revision 1.9
diff -u -p -u -r1.9 input.c
--- m4/input.c 2001/09/08 02:36:47 1.9
+++ m4/input.c 2001/09/18 01:05:31
@@ -606,6 +606,7 @@ init_macro_token (m4_token_data *td)
M4_TOKEN_DATA_TYPE (td) = M4_TOKEN_FUNC;
M4_TOKEN_DATA_FUNC (td) = isp->u.u_m.func;
M4_TOKEN_DATA_HANDLE (td) = isp->u.u_m.handle;
+ M4_TOKEN_TRACED (td) = isp->u.u_m.traced;
}
Index: m4/m4private.h
===================================================================
RCS file: /cvsroot/m4/m4/m4/m4private.h,v
retrieving revision 1.8
diff -u -p -u -r1.8 m4private.h
--- m4/m4private.h 2001/09/08 02:36:47 1.8
+++ m4/m4private.h 2001/09/18 01:05:31
@@ -36,6 +36,7 @@ struct m4_module_data {
struct m4_token_data {
m4_token_data * next;
m4_token_data_t type;
+ boolean traced;
boolean macro_args;
boolean blind_no_args;
lt_dlhandle handle;
@@ -47,6 +48,7 @@ struct m4_token_data {
#define M4_TOKEN_DATA_NEXT(Td) ((Td)->next)
#define M4_TOKEN_DATA_TYPE(Td) ((Td)->type)
+#define M4_TOKEN_TRACED(Td) ((Td)->traced)
#define M4_TOKEN_MACRO_ARGS(Td) ((Td)->macro_args)
#define M4_TOKEN_BLIND_NO_ARGS(Td) ((Td)->blind_no_args)
#define M4_TOKEN_DATA_HANDLE(Td) ((Td)->handle)
@@ -60,14 +62,13 @@ struct m4_token_data {
struct m4_symbol
{
- boolean traced;
m4_token_data *data;
};
-#define M4_SYMBOL_TRACED(S) ((S)->traced)
#define M4_SYMBOL_DATA(S) ((S)->data)
#define M4_SYMBOL_DATA_NEXT(S) (M4_TOKEN_DATA_NEXT (M4_SYMBOL_DATA(S)))
#define M4_SYMBOL_TYPE(S) (M4_TOKEN_DATA_TYPE (M4_SYMBOL_DATA(S)))
+#define M4_SYMBOL_TRACED(S) (M4_TOKEN_TRACED (M4_SYMBOL_DATA(S)))
#define M4_SYMBOL_MACRO_ARGS(S) (M4_TOKEN_MACRO_ARGS
(M4_SYMBOL_DATA(S)))
#define M4_SYMBOL_BLIND_NO_ARGS(S) (M4_TOKEN_BLIND_NO_ARGS (M4_SYMBOL_DATA(S)))
#define M4_SYMBOL_TEXT(S) (M4_TOKEN_DATA_TEXT (M4_SYMBOL_DATA(S)))
Index: m4/macro.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/macro.c,v
retrieving revision 1.11
diff -u -p -u -r1.11 macro.c
--- m4/macro.c 2001/09/08 02:36:47 1.11
+++ m4/macro.c 2001/09/18 01:05:32
@@ -166,9 +166,10 @@ expand_argument (struct obstack *obs, m4
case M4_TOKEN_MACDEF:
if (obstack_object_size (obs) == 0)
{
- M4_TOKEN_DATA_TYPE (argp) = M4_TOKEN_FUNC;
+ M4_TOKEN_DATA_TYPE (argp) = M4_TOKEN_FUNC;
M4_TOKEN_DATA_HANDLE (argp) = M4_TOKEN_DATA_HANDLE (&td);
- M4_TOKEN_DATA_FUNC (argp) = M4_TOKEN_DATA_FUNC (&td);
+ M4_TOKEN_DATA_FUNC (argp) = M4_TOKEN_DATA_FUNC (&td);
+ M4_TOKEN_TRACED (argp) = M4_TOKEN_TRACED (&td);
}
break;
Index: modules/m4.c
===================================================================
RCS file: /cvsroot/m4/m4/modules/m4.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 m4.c
--- modules/m4.c 2001/09/08 01:56:34 1.20
+++ modules/m4.c 2001/09/18 01:05:35
@@ -150,15 +150,22 @@ M4BUILTIN_HANDLER (define)
{
lt_dlhandle handle = M4_TOKEN_DATA_HANDLE (argv[2]);
const m4_builtin *builtin = 0;
+ m4_symbol *symbol = 0;
/* If we find a TOKEN_FUNC with no defining module, then
somewhere along the way we have lost the module handle. */
assert (handle);
+ /* FIXME: Why go to all this effort just to find the macro_args
+ and blind_no_args flags? May as well carry these around with
+ the traced flag, and save a _lot_ of lookup time. */
builtin = m4_builtin_find_by_func (m4_module_builtins (handle),
M4_TOKEN_DATA_FUNC (argv[2]));
- m4_builtin_define (M4ARG (1), handle, builtin);
+ symbol = m4_builtin_define (M4ARG (1), handle, builtin);
+
+ /* Be sure to propogate the flags from the TOKEN_FUNC. */
+ M4_SYMBOL_TRACED (symbol) = M4_TOKEN_TRACED (argv[2]);
}
return;
}
Index: tests/builtins.at
===================================================================
RCS file: /cvsroot/m4/m4/tests/builtins.at,v
retrieving revision 1.3
diff -u -p -u -r1.3 builtins.at
--- tests/builtins.at 2001/09/05 07:51:41 1.3
+++ tests/builtins.at 2001/09/18 01:05:48
@@ -736,6 +736,142 @@ AT_CLEANUP
+## ------ ##
+## trace2 ##
+## ------ ##
+
+AT_SETUP([trace2])
+
+AT_DATA([[trace2.m4]],
+[[traceon(`define')
+debugmode(`aeq')
+
+# copy the `define' builtin definition to another symbol
+define(`my_define', defn(`define'))
+
+# delete the original
+undefine(`define')
+
+# Does it work?
+my_define(`foo', `bar')
+
+# Use the new definition to redefine the original symbol
+my_define(`define', defn(`my_define'))
+
+# Torture the flag propogation
+undefine(`my_define')
+define(`my_define', defn(`define'))
+
+# There are now 2 symbols pointing to the same builtin function
+my_define(`foo', `bar')
+define(`foo', `bar')
+]])
+
+AT_DATA([[expout]],
+[[
+
+
+# copy the `define' builtin definition to another symbol
+
+
+# delete the original
+
+
+# Does it work?
+
+
+# Use the new definition to redefine the original symbol
+
+
+# Torture the flag propogation
+
+
+
+# There are now 2 symbols pointing to the same builtin function
+
+
+]])
+
+AT_DATA([[experr]],
+[[m4trace: -1- define(`my_define', <define>)
+m4trace: -1- my_define(`foo', `bar')
+m4trace: -1- my_define(`define', <define>)
+m4trace: -1- define(`my_define', <define>)
+m4trace: -1- my_define(`foo', `bar')
+m4trace: -1- define(`foo', `bar')
+]])
+
+AT_CHECK_M4([trace2.m4], 0, expout, experr)
+
+AT_CLEANUP
+
+
+
+## ------ ##
+## trace3 ##
+## ------ ##
+
+AT_SETUP([trace3])
+
+AT_DATA([[trace3.m4]],
+[[# copy the `define' builtin definition to another symbol
+define(`my_define', defn(`define'))
+
+# delete the original
+undefine(`define')
+
+# Does it work?
+my_define(`foo', `bar')
+
+# Use the new definition to redefine the original symbol
+my_define(`define', defn(`my_define'))
+
+# Torture the flag propogation
+undefine(`my_define')
+define(`my_define', defn(`define'))
+
+# There are now 2 symbols pointing to the same builtin function
+my_define(`foo', `bar')
+define(`foo', `bar')
+]])
+
+AT_DATA([[expout]],
+[[# copy the `define' builtin definition to another symbol
+
+
+# delete the original
+
+
+# Does it work?
+
+
+# Use the new definition to redefine the original symbol
+
+
+# Torture the flag propogation
+
+
+
+# There are now 2 symbols pointing to the same builtin function
+
+
+]])
+
+AT_DATA([[experr]],
+[[m4trace: -1- define(`my_define', <define>)
+m4trace: -1- my_define(`foo', `bar')
+m4trace: -1- my_define(`define', <define>)
+m4trace: -1- define(`my_define', <define>)
+m4trace: -1- my_define(`foo', `bar')
+m4trace: -1- define(`foo', `bar')
+]])
+
+AT_CHECK_M4([-t define -daeq trace3.m4], 0, expout, experr)
+
+AT_CLEANUP
+
+
+
## -------- ##
## translit ##
## -------- ##
--
())_. Gary V. Vaughan gary@(oranda.demon.co.uk|gnu.org)
( '/ Research Scientist http://www.oranda.demon.co.uk ,_())____
/ )= GNU Hacker http://www.gnu.org/software/libtool \' `&
`(_~)_ Tech' Author http://sources.redhat.com/autobook =`---d__/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: 14-gary-move-traced-flag-to-token-data.patch,
Gary V. Vaughan <=