Unix Technical Forum

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

This is a discussion on Re: [Patch:] restore the native use of isdigit() instead of ap_isdigit() in httpd. within the lucky.openbsd.tech forums, part of the OpenBSD category; --> Ok. I stand mostly corrected. What this appears to be saying is that if the value that one passes ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > lucky.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008, 01:16 PM
Daniel Boulet
 
Posts: n/a
Default 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.

-Danny

On 30-Mar-2006, at 4:38 PM, joerg@britannica.bec.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.
>
> Joerg


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:31 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com