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 01:51:31 +0200

On 07.07.2005, at 01:15, Matthew Dillon wrote:
I am not going to cast the argument to an unsigned char, but I am going
to change the macros to work the same way they work in FreeBSD, which
is to say it will test whether the passed value is in the proper range
rather then blindly indexing into an array.

I agree we should prevent missindexing. how about:


#ifdef __CTYPE_FAST
#define	VALID_BOUNDS(c)	/**/
#else
#ifdef __CTYPE_ASSERT
#define	VALID_BOUNDS(c)	assert(c >= -1 && i < 256)
#else
#define	VALID_BOUND(c)	if (c != -1) c &= 255;
#endif
#endif

static __inline int
isprint(int c)
{
	VALID_BOUNDS(c);
	return ((int)((__libc_ctype_ + 1)[c] & _R));
}

oh well, doesn't look too good. maybe it's too late here.

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: PGP.sig
Description: This is a digitally signed message part



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