summaryrefslogtreecommitdiffstats
path: root/smenu.c
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2021-02-19 22:08:22 +0100
committerpgen <p.gen.progs@gmail.com>2021-02-19 23:31:04 +0100
commitdf9f37847eca8da7dbae177b8e70582af0ea8c6f (patch)
treeed31655543b01fe30bdc71f34961ec772b62bec1 /smenu.c
parent0a398c7bb7deab04f61861fd4423c289a4a5db0b (diff)
Change the implementation of utf8_validate
Thanks to Markus Kuhn for this code. The old implementation was not foolproof.
Diffstat (limited to 'smenu.c')
-rw-r--r--smenu.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/smenu.c b/smenu.c
index fed9515..8e80111 100644
--- a/smenu.c
+++ b/smenu.c
@@ -2398,7 +2398,7 @@ get_bytes(FILE * input, char * utf8_buffer, ll_t * zapped_glyphs_list,
/* In this case the original sequence is lost (unsupported */
/* encoding). */
/* """""""""""""""""""""""""""""""""""""""""""""""""""""""" */
- if (langinfo->utf8 && !utf8_validate(utf8_buffer, last))
+ if (langinfo->utf8 && utf8_validate(utf8_buffer) != NULL)
{
byte = utf8_buffer[0] = misc->invalid_char_substitute;
utf8_buffer[1] = '\0';
@@ -3025,6 +3025,8 @@ build_metadata(term_t * term, long count, win_t * win)
while (i < count)
{
/* Determine the number of screen positions used by the word. */
+ /* Note: mbstowcs will always succeed here as word_a[i].str */
+ /* has already been utf8_validated/repaired. */
/* """""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
word_len = mbstowcs(NULL, word_a[i].str, 0);
word_width = wcswidth((w = utf8_strtowcs(word_a[i].str)), word_len);