Re: Bug#376159: Open21xx Bug Report
Sorry for the comment, but I may be missing something obvious here:
On Aug 13 2007, Matej Vela wrote:
> Michel Dänzer <daenzer@debian.org> writes:
> > Given the list of failing architectures, I think the most likely
> > cause is some code relying on char being signed by default. And
> > indeed, building the as21 directory with -fsigned-char makes it
> > build for me.
>
> You're right, as21/cpp.c was comparing a plain char to EOF. I've
> uploaded the attached patch, let's see if it works.
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.
Regards, Rogério Brito.
--
Rogério Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8
http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito
Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org
Reply to: