[Armel Asselin]

> it seems that the characters are almost never cast (if ever) to 'unsigned
> char' before being sent to 'isalnum' or such... and VC++ libc does not like
> negavtie characters at all.

   The historical method used in old C code is to check for isascii(c)
before checking for isalnum(c). is* were defined to work over the
range (0..UCHAR_MAX, EOF). More recent ISO standards may have (I don't
posess a copy of the various C and C++ standards) defined is* to work
over the range (0..UCHAR_MAX, SCHAR_MIN..SCHAR_MAX, EOF).

   There are several functions defined in Scintilla (IsADigit,
IsASpace, isoperator, ...) that can avoid these problems.

   Many real world implementations such as the ctype.h used in Linux
normally will often play it safe by using a 384 element table.

> should there be a setting for compiling with 'char as unsigned' ? (I tried
> and it works... but should I have?)

   No, it is better to cope with whatever the platform likes to define char as.

[Robert Roessler]

> Well, yes... the character-accessing stuff in the styling machinery
> should not have been defined as returning "char" - for this and other
> reasons. ;)

   StyleContext is better than direct Styler access and
StyleContext::ch is an int. However, StyleContext::ch accumulates
bytes in DBCS modes so can be larger than 0xff so should still be
tested for isascii before calling is*.

   It is not just the returns from these functions, lexer implementers
often create small char arrays to perform some checks.

[Armel Asselin]

> ... just have to find
> the 'char' in the lexers and make them 'int'...
> but i fear that i may to modify several lexers though... (asm, avenue,
> mmixal at least)

   Only modify lexers that you are prepared to become responsible for.
Simply swapping int for char is likely to lead to many real bugs. Do
you know any of these languages well enough to test them?

   Neil

_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to