* signed vs unsigned char in coding.h
@ 2009-02-20 16:19 Dan Nicolaescu
2009-02-20 21:29 ` Chetan Pandya
0 siblings, 1 reply; 2+ messages in thread
From: Dan Nicolaescu @ 2009-02-20 16:19 UTC (permalink / raw)
To: emacs-devel; +Cc: Kenichi Handa
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" ?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: signed vs unsigned char in coding.h
2009-02-20 16:19 signed vs unsigned char in coding.h Dan Nicolaescu
@ 2009-02-20 21:29 ` Chetan Pandya
0 siblings, 0 replies; 2+ messages in thread
From: Chetan Pandya @ 2009-02-20 21:29 UTC (permalink / raw)
To: emacs-devel, Dan Nicolaescu; +Cc: Kenichi Handa
--- On Fri, 2/20/09, Dan Nicolaescu <dann@ics.uci.edu> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-02-20 21:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-20 16:19 signed vs unsigned char in coding.h Dan Nicolaescu
2009-02-20 21:29 ` Chetan Pandya
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).