[Top][All Lists]

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

Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again

From: Ken Hornstein
Subject: Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again
Date: Mon, 04 Feb 2013 21:57:12 -0500

>> Okay, seems clear enough.  But I'm wondering what the "right" solution
>> is here.  Should we simply convert things like the format engine over
>> to use unsigned char for everything?  Considering that we're starting
>> to support 8-bit characters more and more, that seems like the best
>> solution.
>Agreed.  I think we should chip away at these things.

So, I tried working on that today ... and you know what?  That's a GIGANTIC

The real problem is this: while unsigned char is required to prevent sign
extension from happening when using the ctype macros (because they take
int), every OTHER string function takes an unqualified char *.  E.g.,
strcpy, strcmp, mbtowc(), etc etc.  printf() and friends luckily end up
okay because the typing doesn't generate a warning with variable arguments
(or at least gcc doesn't complain about it).

So you ended up with some wholesale interface changes, _and_ you had a bunch
more cast's to (char *).  The whole thing felt wrong; it was too huge.

I poked around a bit, and I found this thread:


What they settled on was casting the arguments to the ctype functions/macros
using (int) (unsigned char), which seems like overkill to me; I think really
casting to unsigned char would be sufficient.  That seems to be what other
packages have done.  This would mean we'd change back all current unsigned
char *'s to just char *'s (it looks like m_getfld() has always taken
arguments of unsigned char *, so I am neutral about changing that; I don't
know why that's been the case).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]