ctype bug

Simon 'corecode' Schubert corecode at fs.ei.tum.de
Wed Jul 6 11:44:36 PDT 2005


Lately Joerg Sonnenberger <joerg at xxxxxxxxxxxxxxxxx> said:
> >     No, that isn't a bug in the test case.  It is perfectly valid to pass
> >     a char to an is*() function.  It does NOT have to be unsigned, and
> >     the is*() function is expected to return the correct result.
> No, it is not. It ALWAYS was invalid, just that the old code was catching
> it in the slow path and hacking around it.

I have to second Joerg. I thought like Matt before, but after reading C99/SUS,
it is clear that any program passing negative vlaues other than EOF is
broken. It explicitly states that parameters must fit into an unsigned
char or have the value of the macro EOF.

So any program passing chars or signed chars is broken, unfortunately.
I would prefer unsigned chars as default anyways...

> >     We have to fix the is*() functions, plain and simple.
> > 
> >     EOF ?  Where'd EOF come from?  EOF is not a valid character.  It's the
> >     same as 'char c = 0xFF' and thus the is*() functions must return a
> >     representation for 0xFF in that case.
> It is. Please read the man page or SUS.

yah, that's the way it is... basically is*() operates on the value returned
by getch() (an int which fits into an unsigned char or is EOF), and not on
plain chars...

> >     The is*() functions MUST properly fold signed chars to return the correct
> >     result.  There is no two ways about it.  It MUST work, period.
> It can't.

I'd put it this way: it SHOULD work with 'char's, but it CAN'T on signed
chars.

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:
pgp00009.pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00009.pgp
Type: application/octet-stream
Size: 189 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/commits/attachments/20050706/17eeb294/attachment-0022.obj>


More information about the Commits mailing list