ctype bug

Simon 'corecode' Schubert corecode at fs.ei.tum.de
Wed Jul 6 17:08:04 PDT 2005


Lately Matthew Dillon <dillon at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00011.pgp
Type: application/octet-stream
Size: 189 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/commits/attachments/20050706/c702129b/attachment-0020.obj>


More information about the Commits mailing list