This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: False syntax error (illegal 0377 character that's not there).


On Tue, 04 May 1999 09:04:49 -0600, Donn Terry wrote:
>
>False syntax error (illegal 0377 character that's not there).
>
>Problem:
>On test 950922-1.c the compiler upon occasion reports finding an illegal
>character.  (This is apparently unrelated to the purpose of the test.)
>
>Cause:
>In c-lex.c: it turns out that if an EOF is reported by getc(), under
>some circumstances it can be pushed back with UNGETC().  However, when
>not using the new cpp stuff, UNGETC is just ungetc(), which takes an
>ordinary character as input.  (Seen with position_after_white_space's
>call to skip_white_space()).  
>
>A subsequent getc() will return the EOF flag, now downsized to a char.
>(If EOF==-1, then the character read back is 0377).  Ungetc is also defined
>to turn off the EOF condition.

I don't object to the patch, but your library is buggy if this
happens.  ungetc(EOF, file) is defined to be a no-op:


       7.19.7.11  The ungetc function

       Synopsis

       [#1]

               #include <stdio.h>
               int ungetc(int c, FILE *stream);

       [#2] The ungetc function pushes the character specified by c
       (converted  to  an unsigned char) back onto the input stream
       pointed  to  by  stream.

...

       [#4]  If  the  value  of c equals that of the macro EOF, the
       operation fails and the input stream is unchanged.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]