Re: GCC9 bug on ppc64le ? or why just fail in ppc64le rawhide?

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

 



* Sérgio Basto:

>  stdio.h defines EOF as -1 , so if we want work with files
> and use EOF character, we need use signed chars, though .

No, this is not how it works.

Most C interfaces (hopefully all of them, but I wouldn't be sure) that
use in-band signaling for EOF return ints.  EOF is returned as int, and
the characters are returned after casting them to unsigned char, even if
char is signed on the architecture.

So getchar returns 255 when reading the character 'ÿ' in ISO-8859-1, and
-1 for EOF.

It is a common mistake to use a char variable to store the result of
getchar and similar functions because this way, you cannot tell 'ÿ' and
EOF apart.  This leads either to premature detection of EOF, or infinite
loops reading 'ÿ' over and over again, depending on the architecture.

Thanks,
Florian
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux