This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Patch for isdigit/isalpha/etc. macro arguments
- From: DJ Delorie <dj at redhat dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: gdb-patches at sourceware dot org
- Date: 09 Apr 2007 08:57:20 -0400
- Subject: Re: Patch for isdigit/isalpha/etc. macro arguments
- References: <jed52g5atf.fsf@sykes.suse.de>
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.