This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: cpplib: lexer cleanup
Zack Weinberg wrote:-
> Too many changes in the same patch. Could you split it into:
>
> - the pure bug fixes
> - folding all the spelling functions
> - the changes to comment handling
> - the assertion changes
>
> and send each separately, please?
Grrr... OK, here is the whitespace bug fix. It's real substance is
just adding a single line - the one mentioning flags - but looks more
complex because I've reversed the sense of the "if" for clarity.
> Also, you should test your patches
> *before* you submit them. For code like this where it's not currently
> used, it suffices to make sure it compiles (you needn't run a full
> bootstrap).
Yes. I half-felt you'd reject it as too big, so didn't bother
bootstrapping. Everything I post compiles cpp otherwise I wouldn't
have been able to test it myself. We know what happened last time I
posted a patch that compiled but I thought touched nothing else - I'm
just being on the safe side.
Neil.
* cpplex.c (_cpp_lex_line): Maintain PREV_WHITESPACE flag
when removing escaped newlines. Reverse sense of test for
escaped newline.
Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplex.c,v
retrieving revision 1.38
diff -u -p -r1.38 cpplex.c
--- cpplex.c 2000/05/08 22:22:48 1.38
+++ cpplex.c 2000/05/08 22:28:59
@@ -3010,30 +3010,31 @@ _cpp_lex_line (pfile, list)
case '\n':
case '\r':
handle_newline (cur, buffer->rlimit, c);
- if (PREV_TOKEN_TYPE != CPP_BACKSLASH || !IMMED_TOKEN ())
+ if (PREV_TOKEN_TYPE == CPP_BACKSLASH && IMMED_TOKEN ())
{
- if (PREV_TOKEN_TYPE == CPP_BACKSLASH)
+ /* Remove the escaped newline. Then continue to process
+ any interrupted name or number. */
+ cur_token--;
+ if (IMMED_TOKEN ())
{
- buffer->cur = cur;
- cpp_warning (pfile,
- "backslash and newline separated by space");
+ cur_token--;
+ if (cur_token->type == CPP_NAME)
+ goto continue_name;
+ else if (cur_token->type == CPP_NUMBER)
+ goto continue_number;
+ cur_token++;
}
- PUSH_TOKEN (CPP_VSPACE);
- goto out;
+ /* Remember whitespace setting. */
+ flags = cur_token->flags;
+ break;
}
- /* Remove the escaped newline. Then continue to process
- any interrupted name or number. */
- cur_token--;
- if (IMMED_TOKEN ())
+ if (PREV_TOKEN_TYPE == CPP_BACKSLASH)
{
- cur_token--;
- if (cur_token->type == CPP_NAME)
- goto continue_name;
- else if (cur_token->type == CPP_NUMBER)
- goto continue_number;
- cur_token++;
+ buffer->cur = cur;
+ cpp_warning (pfile, "backslash and newline separated by space");
}
- break;
+ PUSH_TOKEN (CPP_VSPACE);
+ goto out;
case '-':
if (IMMED_TOKEN () && PREV_TOKEN_TYPE == CPP_MINUS)