[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: signed vs unsigned char in coding.h
From: |
Chetan Pandya |
Subject: |
Re: signed vs unsigned char in coding.h |
Date: |
Fri, 20 Feb 2009 13:29:25 -0800 (PST) |
--- On Fri, 2/20/09, Dan Nicolaescu <address@hidden> wrote:
> struct coding_system in coding.h contains this:
>
> char *safe_charsets;
>
>
> and coding.c has this:
>
> #define SAFE_CHARSET_P(coding, id) \
> ((id) <= (coding)->max_charset_id \
> && (coding)->safe_charsets[id] >= 0)
>
> on some platforms "char" is unsigned by default,
> so the above >=0
> comparison is always true.
>
> What is the intention here, should safe_charsets be defined
> as "signed char" ?
It looks like there are more things needed here. Since the safe_charsets is
part of a string, it makes sense to declare it as unsigned char and compare it
to 255.
However, when in coding.c:9298 this is initialized with
safe_charsets = Fmake_string (make_number (max_charset_id + 1),
make_number (255));
This also has problems since it tries to create a string with a character that
is not ASCII_CHAR_P. Wouldn't it make sense to create with ascii char and then
replace all with 255 instead?
Chetan