From b77ab7365d9d28f4a2d69a8246a019a4db9fd964 Mon Sep 17 00:00:00 2001 From: arakiken Date: Mon, 14 Aug 2023 14:28:00 +0900 Subject: [PATCH] * vt_char.c: IS_UNICODE_AREA_CS macro is enclosed by () to be expanded properly in 'if (IS_COMB_TRAILING(attr) && CHARSET(attr) == PICTURE_CHARSET)' in vt_get_picture_char(). * libctl/vt_line_bidi.c: Incorrect uncombining arabic characters is checked. --- ChangeLog | 8 ++++++++ vtemu/libctl/vt_line_bidi.c | 26 ++++++++++++++++++-------- vtemu/vt_char.c | 8 ++++---- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18d675b2..360c6245 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2023-08-14 Araki Ken + + * vt_char.c: IS_UNICODE_AREA_CS macro is enclosed by () to be expanded + properly in 'if (IS_COMB_TRAILING(attr) && CHARSET(attr) == PICTURE_CHARSET)' + in vt_get_picture_char(). + + * libctl/vt_line_bidi.c: Incorrect uncombining arabic characters is checked. + 2023-08-11 Araki Ken * ui.c: ASCII symbols and signs are added to keysym_table. diff --git a/vtemu/libctl/vt_line_bidi.c b/vtemu/libctl/vt_line_bidi.c index 3b959a2e..5850d6c1 100644 --- a/vtemu/libctl/vt_line_bidi.c +++ b/vtemu/libctl/vt_line_bidi.c @@ -242,6 +242,11 @@ int vt_line_bidi_visual(vt_line_t *line) { if (vt_get_combining_chars(src + count, &num) == NULL && vt_char_combine_simple(line->chars + vis_pos, src + count)) { line->num_filled_chars--; +#ifdef __DEBUG + bl_debug_printf("Combine arabic character %x to %x\n", + vt_char_code(src + count), + vt_char_code(line->chars + vis_pos)); +#endif } else { /* XXX Not correctly shown */ #ifdef DEBUG @@ -298,8 +303,20 @@ int vt_line_bidi_logical(vt_line_t *line) { if ((comb = vt_get_combining_chars(src + vis_pos, &num)) && (0x600 <= (code = vt_char_code(src + vis_pos)) && code <= 0x6ff) /* Arabic */ && !vt_char_is_comb(comb) /* arabic comb */) { +#ifdef __DEBUG + bl_debug_printf("Uncombine arabic character %x from %x\n", + vt_char_code(comb), vt_char_code(src + vis_pos)); +#endif + vt_char_copy(line->chars + count, vt_get_base_char(src + vis_pos)); + if (line->num_filled_chars + num > line->num_chars) { + bl_error_printf("Failed to show arabic chars correctly.\n"); + if ((num = line->num_chars - line->num_filled_chars) == 0) { + goto next_count; + } + } + do { vt_char_copy(line->chars + (++count), comb++); line->num_filled_chars++; @@ -310,18 +327,11 @@ int vt_line_bidi_logical(vt_line_t *line) { line->ctl_info.bidi->size, count); } + next_count: prev = vis_pos; } } -#ifdef DEBUG - if (line->num_filled_chars > line->num_chars) { - bl_error_printf(BL_DEBUG_TAG " Bidi visual <=> logical fails." - "(line->num_filled_chars %d > line->num_chars %d)\n", - line->num_filled_chars, line->num_chars); - } -#endif - vt_str_final(src, orig_num_filled_chars); /* diff --git a/vtemu/vt_char.c b/vtemu/vt_char.c index fae0f1b3..411e1a28 100644 --- a/vtemu/vt_char.c +++ b/vtemu/vt_char.c @@ -23,16 +23,16 @@ /* Combination of IS_ITALIC, IS_BOLD, IS_FULLWIDTH, CS_REVISION_1 and CHARSET(UNICODE AREA) */ #define VTFONT(attr) \ - IS_UNICODE_AREA_CS(attr) \ - ? ((((attr) >> 3) & 0xf00) | ISO10646_UCS4_1 | (((attr) << 9) & 0xff000)) \ - : (((attr) >> 3) & 0xfff) + (IS_UNICODE_AREA_CS(attr) \ + ? ((((attr) >> 3) & 0xf00) | ISO10646_UCS4_1 | (((attr) << 9) & 0xff000)) \ + : (((attr) >> 3) & 0xfff)) #define IS_ITALIC(attr) ((attr) & (0x1 << 14)) #define IS_BOLD(attr) ((attr) & (0x1 << 13)) #define IS_FULLWIDTH(attr) ((attr) & (0x1 << 12)) #define COLUMNS(attr) ((((attr) >> 12) & 0x1) + 1); #define CHARSET(attr) \ - IS_UNICODE_AREA_CS(attr) ? (ISO10646_UCS4_1 | (((attr) >> 3) & 0x100)) : (((attr) >> 3) & 0x1ff) + (IS_UNICODE_AREA_CS(attr) ? (ISO10646_UCS4_1 | (((attr) >> 3) & 0x100)) : (((attr) >> 3) & 0x1ff)) #define IS_COMB(attr) ((attr) & (0x1 << 2))