Hi,

* Tony Balinski wrote (2007-10-15 13:26):
>Quoting Ivan Skytte Jørgensen <[EMAIL PROTECTED]>:
>> file.c: 1198: The casts in:
>>         if ((int)(strlen(fullname) + 5) > (int)MAXPATHLEN)
>> look weird. It should be:
>>         if ((strlen(fullname) + 5) > (size_t)MAXPATHLEN)
>
>No cast at all needed here IMO. This looks like a case of someone trying
>to remove warnings by brute force. The best way, of course, is to have
>MAXPATHLEN defined as unsigned, but even that probably isn't necessary,
>given the type promotion to the unsigned type that's big enough for the
>compare (assuming size_t is unsigned, which it should be). Casting just
>muddies the waters here.

Even if not necessary, casts may help by making things explicit.


>> selection.c:95-110
>>     char *endptr;
>>     ...
>>     if (isdigit((unsigned char) *endptr ) ...
>> Why the cast?
>
>These "ctype function" casts were added when passing a plain char caused
>problems. I think it was on older Sun machines that the bug occurred. The
>implementation used macros to implement is...() and toupper/tolower, using
>the character's ordinal value as an index into a table. This worked for
>ASCII, but, since char was a signed value, failed for non-ASCII (eg Latin1)
>characters. The cast to unsigned char cured this. (A cast to int was
>rejected since this would cause sign extension.)
>
>I would prefer that these casts remain; it was a painful problem to find
>in the first place, and I wouldn't want to see a regression.

I see. Could you come up with a comment to add then?


Thorsten                                       Kristin Hersh: Houdini Blues
-- 
I propose we leave math to the machines and go play outside.
    - Calvin

Attachment: pgpwpT3FaT2wr.pgp
Description: PGP signature

-- 
NEdit Develop mailing list - [email protected]
http://www.nedit.org/mailman/listinfo/develop

Reply via email to