diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-03-28 20:45:31 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-03-28 20:45:31 +0200 |
commit | 30450214307e3eba72dd411e0c700163341d7cdf (patch) | |
tree | c54d88ddc1710f00ef9e2e946c171e1228f85422 /src/gui | |
parent | ee82ba74616b9050346d01e27b452bee3c5f0afd (diff) | |
download | weechat-30450214307e3eba72dd411e0c700163341d7cdf.zip |
core: fix cut of chars in "cutscr" of evaluated strings
This fixes two problems:
- stop before max char displayed with wide chars
- preserve combining chars in the output
Before the fix (wrong):
>> ${cutscr:3,+,こんにちは世界}
== [こん+]
>> ${cutscr:1,+,a${\u0308}}
== [a+]
After the fix (OK):
>> ${cutscr:3,+,こんにちは世界}
== [こ+]
>> ${cutscr:1,+,a${\u0308}}
== [ä]
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-chat.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 02891ef06..5fc018dba 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -224,7 +224,7 @@ gui_chat_string_add_offset_screen (const char *string, int offset_screen) { int size_on_screen; - while (string && string[0] && (offset_screen > 0)) + while (string && string[0] && (offset_screen >= 0)) { string = gui_chat_string_next_char (NULL, NULL, (unsigned char *)string, @@ -233,6 +233,8 @@ gui_chat_string_add_offset_screen (const char *string, int offset_screen) { size_on_screen = gui_chat_char_size_screen (string); offset_screen -= size_on_screen; + if (offset_screen < 0) + return string; string = utf8_next_char (string); } } |