This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch for isdigit/isalpha/etc. macro arguments


Andreas Schwab <schwab@suse.de> writes:
> How can it distinguish EOF from '\377'?

EOF is -1 and '\377' is 255; they're different values.  Functions that
may return EOF return an int, not a char, and you should not cast that
value to char before checking for EOF.

The is*() macros take an int because there are 257 different values
(-1..255) that they must accept, not 256.

In many cases, programmers use 'char' to hold the result of, for
example, fgetc(), and the warning from gcc is valid (although
indirect) because they've lost the EOF marker.


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