[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#376159: Open21xx Bug Report



Rogério Brito <rbrito@ime.usp.br> writes:

> Theoretically (and practically also), an EOF should *never* be compared
> to a char: only to an int.
>
>> --- open21xx-0.7.5.orig/as21/cpp.c
>> +++ open21xx-0.7.5/as21/cpp.c
>> @@ -235,7 +235,7 @@
>>          /* - 2 to leave room for testing comments and quotes */
>>          while (chars_read < max_size - 2)
>>          {
>> -            ch = buf[chars_read] = getc( yyin );
>> +            buf[chars_read] = ch = getc( yyin );
>>              if (ch == EOF)
>>              {
>>                  goto read_done;
>
> I would first read the character from getc, then see if it is EOF and,
> depending on the comparison, do whatever is needed. Otherwise, I would
> judge the code to be incorrect and losing precision in a case where such
> precision should not be lost.

Note that ch is an int.

Cheers,

Matej



Reply to: