ctype bug

Simon 'corecode' Schubert corecode at fs.ei.tum.de
Wed Jul 6 16:52:37 PDT 2005


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00010.pgp
Type: application/octet-stream
Size: 186 bytes
Desc: "Description: This is a digitally signed message part"
URL: <http://lists.dragonflybsd.org/pipermail/commits/attachments/20050706/50884405/attachment-0018.obj>


More information about the Commits mailing list