mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
vt: fix buggy chains of ternary expressions in action_esc_dispatch()
Only the first character in the chain was being compared with `priv` and the rest were just being evaluated as simple expressions. This was causing the G2 and G3 operations to erroneously use the G1 index. Since the characters are a contiguous range, we can just subtract the start of the range to get the appropriate index. The outer switch statement already ensures the values are in range.
This commit is contained in:
parent
b34d76f711
commit
620fe8e764
1 changed files with 9 additions and 18 deletions
27
vt.c
27
vt.c
|
|
@ -442,32 +442,23 @@ action_esc_dispatch(struct terminal *term, uint8_t final)
|
|||
}
|
||||
break; /* private[0] == 0 */
|
||||
|
||||
case '(':
|
||||
case ')':
|
||||
case '*':
|
||||
case '+':
|
||||
// Designate character set
|
||||
case '(': // G0
|
||||
case ')': // G1
|
||||
case '*': // G2
|
||||
case '+': // G3
|
||||
switch (final) {
|
||||
case '0': {
|
||||
char priv = term->vt.private;
|
||||
ssize_t idx = priv ==
|
||||
'(' ? 0 :
|
||||
')' ? 1 :
|
||||
'*' ? 2 :
|
||||
'+' ? 3 : -1;
|
||||
xassert(idx != -1);
|
||||
size_t idx = term->vt.private - '(';
|
||||
xassert(idx <= 3);
|
||||
term->charsets.set[idx] = CHARSET_GRAPHIC;
|
||||
term_update_ascii_printer(term);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'B': {
|
||||
char priv = term->vt.private;
|
||||
ssize_t idx = priv ==
|
||||
'(' ? 0 :
|
||||
')' ? 1 :
|
||||
'*' ? 2 :
|
||||
'+' ? 3 : -1;
|
||||
xassert(idx != -1);
|
||||
size_t idx = term->vt.private - '(';
|
||||
xassert(idx <= 3);
|
||||
term->charsets.set[idx] = CHARSET_ASCII;
|
||||
term_update_ascii_printer(term);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue