From: DJ Delorie Subject: Re: some unusual errors 21 Sep 1998 09:19:58 -0400 Message-ID: <3606527E.2781@delorie.com> References: <199809182005 DOT QAA03634 AT venus DOT solidum DOT com> <199809210056 DOT RAA27963 DOT cygnus DOT gnu-win32 AT aleph DOT ssd DOT hal DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0 (X11; I; IRIX 5.3 IP22) > This looks like a bug in the macro implementation of > isspace(), to me; it should be casting the parameter to > int so it will behave in the same way as the function > implementation. Until a fix appears, your options are: This discussion happens a lot in the djgpp newsgroup. The result is always the same: You can't cast to int in the macro. Why? Because: 1. If the programmer used the macro with a char argument (when char is signed), the macro can't tell the difference between EOF and char 0xff 2. If char is signed, a cast to int may not do what the macro is expecting. The is*() macros normally expect a parameter in the range 0..255 or -1, but if you cast a signed char to int, you get values in the range -128..127 or -1, and your program may crash. 3. Remember that getchar() returns in int - for the very same reason, so that EOF is not in the range of valid characters. getchar() returns EOF or 0..255, which is NOT the same range as the range for type `signed char'. Basically, if you're a programmer and you've stumbled onto this problem, you have a problem with your code. 60