DragonFly BSD
DragonFly commits List (threaded) for 2005-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: ctype bug


From: "Simon 'corecode' Schubert" <corecode@xxxxxxxxxxxx>
Date: Thu, 7 Jul 2005 02:07:14 +0200

Lately Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx> said:
>     We can't use assert without including assert.h, but it does bring up
>     the point as to whether we should fault out the program or whether
>     we should silently return 0.

i'd say, make it a compile time flag. we can't assert, that's true, but
we could *(int*)0 = 1 or something like this.

>     Here's what I'm thinking of.  The only thing I don't like about it is
>     the way _CTYPE_NUM_CHARS is defined, but on the other hand I'm not
>     particularly expecting that we will ever port to an architecture where
>     a character is more then 8 bits.

seconded. if so, we can still change it :)

> +static __inline int
> +__libc_ctype_index(__uint16_t mask, int c)
> +{
> +	if (c < -1 || c >= _CTYPE_NUM_CHARS)
> +		return(0);

how about folding the argument? this way passing an signed char
actually works like "expected":

int i = 0xad;	/* euro sign (?) */
char c = i;
printf("%c %c %d %d\n", i, c, isprint(i), isprint(c));

should print "? ? 1 1", and not "? ? 1 0". or maybe it's too late
and i'm missing something.

cheers
  simon

-- 
Serve - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /"\
Work - Mac      +++  space for low $$$ NOW!1  +++      Campaign     \ /
Party Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \
Dude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \

Attachment: pgp00011.pgp
Description: PGP signature



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