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

Re: [Patch:] restore the native use of isdigit() instead of ap_isdigit() in httpd.

Ok. I stand mostly corrected. What this appears to be saying is that if the value that one passes to isdigit is either EOF or what one would get if one assigned an unsigned char to an int then one is safe. If one is carrying the character around in an int and one knows that the int's value is either EOF or a value derived directly from an unsigned char then one is safe. If one knows that the value in question is not EOF then using an unsigned char to represent the value is obviously safer than using a char. If one can't be sure that the value might be EOF then it would seem that an int is safer. Using a char is never the safe/portable choice. Since one cannot represent the value EOF in an unsigned char then using an unsigned char to represent the value is unsafe if the value in question might be EOF. It is, of course, safe to use an unsigned char if one knows that the value in question cannot be EOF.

Thanks for the clarification.


On 30-Mar-2006, at 4:38 PM, joerg_(_at_)_britannica_(_dot_)_bec_(_dot_)_de wrote:

On Thu, Mar 30, 2006 at 03:21:29PM -0700, Daniel Boulet wrote:
Hmmm.  The isdigit man page from the Single Unix Specification on the
Open Groups' web site (www.unix.org) declares isdigit as follows:

	#include <ctype.h>

	int isdigit(int c);

This documentation for the isdigit interface would appear to allow
the parameter to be a char since chars can certainly be cast to ints
without any loss of information.

Please read the *full* description, especially the following:
The c argument is an int, the value of which the application shall
ensure is a character representable as an unsigned char or equal to
the value of the macro EOF. If the argument has any other value, the
behavior is undefined.