This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: cpplib bug fix (macro expansion)
- To: Zack Weinberg <zack at rabi dot columbia dot edu>
- Subject: Re: cpplib bug fix (macro expansion)
- From: Dave Brolley <brolley at cygnus dot com>
- Date: Fri, 16 Oct 1998 17:34:01 -0400
- CC: egcs-patches at cygnus dot com
- Organization: Cygnus Solutions Canada Ltd
- References: <199810151611.MAA01006@blastula.phys.columbia.edu>
I just installed this....
Dave
Zack Weinberg wrote:
> On Tue, 13 Oct 1998 15:01:56 -0400, Dave Brolley wrote:
> >We're getting closer. I think the patch is OK except that the blank representi
> >ng
> >the whitespace in the macro buffers should only be output if it was not a macr
> >o
> >call and before parse_goto_mark is called.
> >
> >If you agree to this change, then I'll install the patch.
>
> Here is a new patch, modified as you suggested.
>
> zw
>
> Index: cpplib.c
> ===================================================================
> RCS file: /egcs/carton/cvsfiles/egcs/gcc/cpplib.c,v
> retrieving revision 1.37
> diff -u -r1.37 cpplib.c
> --- cpplib.c 1998/10/11 00:05:09 1.37
> +++ cpplib.c 1998/10/15 16:09:55
> @@ -5099,29 +5099,43 @@
> if (hp->type == T_MACRO && hp->value.defn->nargs >= 0)
> {
> struct parse_marker macro_mark;
> - int is_macro_call;
> - while (CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile)))
> - {
> - cpp_buffer *next_buf;
> - cpp_skip_hspace (pfile);
> - if (PEEKC () != EOF)
> - break;
> - next_buf = CPP_PREV_BUFFER (CPP_BUFFER (pfile));
> - (*CPP_BUFFER (pfile)->cleanup) (CPP_BUFFER (pfile), pfile);
> - CPP_BUFFER (pfile) = next_buf;
> - }
> + int is_macro_call, macbuf_whitespace = 0;
> +
> parse_set_mark (¯o_mark, pfile);
> for (;;)
> {
> cpp_skip_hspace (pfile);
> c = PEEKC ();
> is_macro_call = c == '(';
> - if (c != '\n')
> - break;
> - FORWARD (1);
> + if(c != EOF)
> + {
> + if (c != '\n')
> + break;
> + FORWARD (1);
> + }
> + else
> + {
> + if (CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile)))
> + {
> + if (macro_mark.position !=
> + (CPP_BUFFER (pfile)->cur
> + - CPP_BUFFER (pfile)->buf))
> + macbuf_whitespace = 1;
> +
> + parse_clear_mark (¯o_mark);
> + cpp_pop_buffer (pfile);
> + parse_set_mark (¯o_mark, pfile);
> + }
> + else
> + break;
> + }
> }
> if (!is_macro_call)
> - parse_goto_mark (¯o_mark, pfile);
> + {
> + parse_goto_mark (¯o_mark, pfile);
> + if (macbuf_whitespace)
> + CPP_PUTC (pfile, ' ');
> + }
> parse_clear_mark (¯o_mark);
> if (!is_macro_call)
> return CPP_NAME;