CVSROOT: /sources/m4 Module name: m4 Changes by: Eric Blake <ericb> 06/10/13 16:46:47
Index: m4/input.c =================================================================== RCS file: /sources/m4/m4/m4/input.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -b -r1.52 -r1.53 --- m4/input.c 12 Oct 2006 23:21:34 -0000 1.52 +++ m4/input.c 13 Oct 2006 16:46:47 -0000 1.53 @@ -314,7 +314,8 @@ static void file_print (m4_input_block *me, m4 *context, m4_obstack *obs) { - const char *text = m4_get_current_file (context); + const char *text = (me->funcs == &file_init_funcs ? me->u.u_f.name + : m4_get_current_file (context)); obstack_grow (obs, "<file: ", strlen ("<file: ")); obstack_grow (obs, text, strlen (text)); obstack_1grow (obs, '>'); @@ -646,8 +647,10 @@ Since wrapup text can install new wrapup text, pop_wrapup () returns false when there is no wrapup text on the stack, and true otherwise. */ bool -m4_pop_wrapup (void) +m4_pop_wrapup (m4 *context) { + static size_t level = 0; + next = NULL; obstack_free (current_input, NULL); free (current_input); @@ -655,11 +658,18 @@ if (wsp == NULL) { obstack_free (wrapup_stack, NULL); + m4_set_current_file (context, NULL); + m4_set_current_line (context, 0); + m4_debug_message (context, M4_DEBUG_TRACE_INPUT, + _("input from m4wrap exhausted")); current_input = NULL; DELETE (wrapup_stack); return false; } + m4_debug_message (context, M4_DEBUG_TRACE_INPUT, + _("input from m4wrap recursion level %d"), ++level); + current_input = wrapup_stack; wrapup_stack = (m4_obstack *) xmalloc (sizeof (m4_obstack)); obstack_init (wrapup_stack); @@ -897,19 +907,15 @@ void m4_input_init (m4 *context) { - /* FIXME: The user should never be able to see the empty string as a - file name, even during m4wrap expansion. */ - m4_set_current_file (context, ""); + obstack_init (&file_names); + m4_set_current_file (context, NULL); m4_set_current_line (context, 0); - current_input = (m4_obstack *) xmalloc (sizeof (m4_obstack)); obstack_init (current_input); wrapup_stack = (m4_obstack *) xmalloc (sizeof (m4_obstack)); obstack_init (wrapup_stack); - obstack_init (&file_names); - /* Allocate an object in the current chunk, so that obstack_free will always work even if the first token parsed spills to a new chunk. */