On 12.12.2016 15:36 Nikita Egorov wrote:
> Hi, guys!
>
> I'm again facing with old problem: debug assertion window popups when
> cyrillic symbols are used in Fl_Text_Editor. [Win7, VS2015 Debug build]
>
> A simple sequence to show this error: start test/editord.exe, copy 'oй'
> and paste into editor, press Ctrl+Left (previous word, etc) and the
> application fails!
Yep, confirmed :-(
> IIRC, it was Albrecht who fixed previous cases with this annoying bug.
I don't remember. Can you give me a hint which bug this was and when it
was fixed?
> I'm afraid, the error needs some more complex solution, otherwise it
> will appear again...
You found a bug where a Microsoft assert() fails. BTW: a Release build
does not crash, there is supposedly no assert() included.
The code is indeed faulty because it is not yet fully adapted to UTF-8:
static inline int fl_isseparator(unsigned int c) {
// FIXME: this does not take UCS-4 encoding into account
I'm afraid there can be more such issues hidden in the code. :-(
However, here's a simple patch that works for me:
diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx
index 59582b1..db85659 100644
--- a/src/Fl_Text_Display.cxx
+++ b/src/Fl_Text_Display.cxx
@@ -1581,7 +1581,7 @@ int Fl_Text_Display::rewind_lines(int startPos,
int nLines) {
static inline int fl_isseparator(unsigned int c) {
// FIXME: this does not take UCS-4 encoding into account
- return c != '$' && c != '_' && (isspace(c) || ispunct(c));
+ return c <= 255 && c != '$' && c != '_' && (isspace(c) || ispunct(c));
}
--- end of patch, cut here ---
Use 'patch -p1' to apply (note the two empty lines).
Please file a bug report (STR) against 1.3.4 with HIGH priority for
reference, even if this patch solves the issue for you, and please
confirm (here) if it works for you. Thanks.
Note 1: This minimal patch assumes that all word separators are in the
allowed range of isspace(), ispunct() and others which is "the value of
an unsigned char or EOF" according to the man page. Other Unicode word
separators (are there any?) would not be recognized with this patch, but
this is obviously better than to risk a crash.
Note 2: Behavior of isspace() etc. is not defined for values outside
this range, so a crash is one of many outcomes to be expected.
PS: Question to devs: is this worth a 1.3.5 release? I hope not, but a
crash is really, really bad. :-(