Skip to content

Commit

Permalink
* vt_char.c: IS_UNICODE_AREA_CS macro is enclosed by () to be expanded
Browse files Browse the repository at this point in the history
  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.
  • Loading branch information
arakiken committed Aug 14, 2023
1 parent 8cd69a4 commit b77ab73
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2023-08-14 Araki Ken <arakiken@users.sf.net>

* 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 <arakiken@users.sf.net>

* ui.c: ASCII symbols and signs are added to keysym_table.
Expand Down
26 changes: 18 additions & 8 deletions vtemu/libctl/vt_line_bidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++;
Expand All @@ -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);

/*
Expand Down
8 changes: 4 additions & 4 deletions vtemu/vt_char.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit b77ab73

Please sign in to comment.