Martin and I are [for once] in complete agreement that Extbyte should be just
`char', not `unsigned char'. [Technically, just plain `char' could be
unsigned,
but whatever.] The reason for this is that it greatly simplifies dealing with
library functions, which invariably declare their strings as `char'. In fact,
this is the primary reason, I think, why we suppress many warnings about
signed/unsigned matches. [though i may be confused here] I was very surprised,
in fact, to find that Extbyte was unsigned char, and was sure that I had
originally made it char, but I was mistaken. I imagine that I did it because
chars are inherently dangerous to work with -- as was demonstrated clearly when
I just made the change and rebuilt a Mule version, and got crashes. In fact,
there were two bugs needed fixing, and in both cases GCC actually flagged them
with a warning like "comparison is always true due to limited range of type".
In both cases, the code itself was buggy; one had an Extbyte where it should
have had Bufbyte, and the other was breaking the cardinal rule of format
translation -- always do the translation at the very point you send data to the
external library [or receive data from it], and never ever do any operations on
the data in the external format. Assume black box. This second spot violated
this, and the result was buggy code, which would have failed badly, e.g., if the
externally-formatted code were JIS, which is used on some systems [esp. but not
exclusively window systems]. When I fixed these two spots, I got a Mule that
worked perfectly.
So, I'd like to make Extbyte be signed. This is actually an extremely small
patch, but with potentially big ramifications, so I'd like to do it after Martin
puts out his next beta. [Martin???]
The summary is:
-- makes code that deals with the outside world cleaner due to lack of lots of
now-unnecessary casts.
-- we can enable full warning again.
-- forces discipline on those who may tend to break the cardinal rule above
about internal/external translation.
-- sources of errors relating to the signed-ness [related to the previous point]
are generally flagged in gcc.
what do you guys think? i'm planning on putting this in shortly after Martin
releases his next beta, barring major objections.
Ben
In order to save my hands, I am cutting back on my mail. I also write
as succinctly as possible -- please don't be offended. If you send me
mail, you _will_ get a response, but please be patient, especially for
XEmacs-related mail. If you need an immediate response and it is not
apparent in your message, please say so. Thanks for your understanding.
See also
http://www.666.com/ben/chronic-pain/