cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: isspace() usage in cookie.c

From: Christopher R. Palmer <crpalmer_at_vivisimo.com>
Date: Thu, 23 Sep 2004 10:11:24 -0400

Harshal Pradhan wrote:

> Daniel Stenberg wrote:
>
>> On Thu, 23 Sep 2004, Harshal Pradhan wrote:
>> I think we should modify the 'char *' variables to become 'unsigned
>> char *' variables as then typecasting it to 'int' like we do won't
>> produce any negative values, which I assume is the actual problem you
>> face?
>
> I was looking for something more localized, but that would work I guess.
> And yes, negative values are the basic problem.

Hi,

When I want to find only ASCII whitespace characters in a string with upper
bits that may be set, I use a little macro:

#define MYISSPACE(x) (((x) & 0x80) == 0 && isspace(x))

for an unsigned char x (this should work for a signed x as well, but it's
better to use unsigned).

Older systems define isspace to be a char (which is signed) and for which I
would assume isspace(128) would be undefined. Personally, I like having
the extra protection that this macro adds...

Cheers,
Chris.

---
Christopher R. Palmer                     palmer_at_vivisimo.com
Chief Technology Officer                  www.vivisimo.com
Vivisimo, Inc.                            412-422-2499 ext. 118
Received on 2004-09-23