Current-Users archive

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

Re: Casting ctype lookups



Joerg Sonnenberger <joerg%britannica.bec.de@localhost> writes:

> On Mon, Nov 12, 2012 at 01:47:59PM -0500, D'Arcy J.M. Cain wrote:
>> Should the inline macro cast the args for these table lookups?  I would
>> like to modify sys/ctype_inline.h to change lookup lines like;
>
> No. Please read ctype(3).

I see the point about code that passes a signed char being incorrect.
However, the standard seems to say that isalpha etc. are required to be
functions that take an int, and may also be macros.  So it seems that
code that is written with an unsigned char should compile without
warnings.

Here's a simpler question: if these were implemented as functions, with
the type signature required by the standard, how would that be different
than adding a cast to int as D'Arcy suggests?

This all seems quite difficult; the notion of a int carrying either a
char or EOF makes it likely to have errors from type promotion.

Attachment: pgpYPOY3o4Jw4.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index