41.0 sec user + 0.9 sec system *** input.c.patch1 2008-02-28 01:45:09.000000000 +0100 --- input.c 2008-02-28 01:59:43.000000000 +0100 *************** *** 75,81 **** INPUT_STRING, /* String resulting from macro expansion. */ INPUT_FILE, /* File from command line or include. */ INPUT_MACRO, /* Builtin resulting from defn. */ ! INPUT_CHAIN /* FIFO chain of separate strings and $@ refs. */ }; typedef enum input_type input_type; --- 75,82 ---- INPUT_STRING, /* String resulting from macro expansion. */ INPUT_FILE, /* File from command line or include. */ INPUT_MACRO, /* Builtin resulting from defn. */ ! INPUT_CHAIN, /* FIFO chain of separate strings and $@ refs. */ ! INPUT_NONE /* End of the input block stack. */ }; typedef enum input_type input_type; *************** *** 115,120 **** --- 116,126 ---- u; }; + /* This input block is an indicator that the input stack is at its end. + This fake input block avoids the need for testing 'isp' in next_char() + and next_char_1(). */ + static struct input_block input_block_none = { NULL, INPUT_NONE }; + /* Current input file name. */ const char *current_file; *************** *** 307,313 **** { /* Free any memory occupied by completely parsed strings. */ assert (next == NULL); ! while (isp && pop_input (false)); /* Reserve the next location on the obstack. */ next = (input_block *) obstack_alloc (current_input, sizeof *next); --- 313,319 ---- { /* Free any memory occupied by completely parsed strings. */ assert (next == NULL); ! while (isp->type != INPUT_NONE && pop_input (false)); /* Reserve the next location on the obstack. */ next = (input_block *) obstack_alloc (current_input, sizeof *next); *************** *** 607,613 **** return false; if (debug_level & DEBUG_TRACE_INPUT) { ! if (tmp) DEBUG_MESSAGE2 ("input reverted to %s, line %d", tmp->file, tmp->line); else --- 613,619 ---- return false; if (debug_level & DEBUG_TRACE_INPUT) { ! if (tmp->type != INPUT_NONE) DEBUG_MESSAGE2 ("input reverted to %s, line %d", tmp->file, tmp->line); else *************** *** 652,658 **** obstack_free (current_input, NULL); free (current_input); ! if (wsp == NULL) { /* End of the program. Free all memory even though we are about to exit, since it makes leak detection easier. */ --- 658,664 ---- obstack_free (current_input, NULL); free (current_input); ! if (wsp->type == INPUT_NONE) { /* End of the program. Free all memory even though we are about to exit, since it makes leak detection easier. */ *************** *** 671,677 **** obstack_init (wrapup_stack); isp = wsp; ! wsp = NULL; input_change = true; return true; --- 677,683 ---- obstack_init (wrapup_stack); isp = wsp; ! wsp = &input_block_none; input_change = true; return true; *************** *** 753,761 **** while (1) { - if (block == NULL) - return CHAR_EOF; - switch (block->type) { case INPUT_STRING: --- 759,764 ---- *************** *** 819,824 **** --- 822,830 ---- } break; + case INPUT_NONE: + return CHAR_EOF; + default: assert (!"peek_input"); abort (); *************** *** 841,847 **** `-------------------------------------------------------------------*/ #define next_char(AQ) \ ! (isp && isp->str_len && !input_change \ ? (isp->str_len--, to_uchar (*isp->u.u_s.str++)) \ : next_char_1 (AQ)) --- 847,853 ---- `-------------------------------------------------------------------*/ #define next_char(AQ) \ ! (isp->str_len && !input_change \ ? (isp->str_len--, to_uchar (*isp->u.u_s.str++)) \ : next_char_1 (AQ)) *************** *** 853,865 **** while (1) { - if (isp == NULL) - { - current_file = ""; - current_line = 0; - return CHAR_EOF; - } - if (input_change) { current_file = isp->file; --- 859,864 ---- *************** *** 949,954 **** --- 948,958 ---- } break; + case INPUT_NONE: + current_file = ""; + current_line = 0; + return CHAR_EOF; + default: assert (!"next_char_1"); abort (); *************** *** 1195,1202 **** obstack_init (&token_stack); token_bottom = obstack_finish (&token_stack); ! isp = NULL; ! wsp = NULL; next = NULL; start_of_input_line = false; --- 1199,1206 ---- obstack_init (&token_stack); token_bottom = obstack_finish (&token_stack); ! isp = &input_block_none; ! wsp = &input_block_none; next = NULL; start_of_input_line = false;