diff options
author | Takamichi Horikawa <takamichiho@gmail.com> | 2017-09-20 23:27:18 +0900 |
---|---|---|
committer | Takamichi Horikawa <takamichiho@gmail.com> | 2017-09-20 23:27:18 +0900 |
commit | 0e4014dae7727a06a80b59b6ede26d8d08d2c42b (patch) | |
tree | f53bd2d6b31566e170da5f118c7ed8604b6d1cb7 /fmdsp/fmdsp-pacc.c | |
parent | aa27f073c63cb8120e9debebb627c6282870397a (diff) |
fmdsp-pacc: add code to ignore ANSI escape sequences
Diffstat (limited to 'fmdsp/fmdsp-pacc.c')
-rw-r--r-- | fmdsp/fmdsp-pacc.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fmdsp/fmdsp-pacc.c b/fmdsp/fmdsp-pacc.c index 02b6e17..39fbdfb 100644 --- a/fmdsp/fmdsp-pacc.c +++ b/fmdsp/fmdsp-pacc.c @@ -1794,9 +1794,38 @@ static void font_putline( int fh = font->height; int xo = 0; + enum { + STATE_NORMAL, + STATE_ESC, + STATE_CSI, + STATE_SYNC, + } esc_state = STATE_NORMAL; + while (*cp932str) { if (!sjis_is2nd) { if (!sjis_is_mb_start(*cp932str)) { + if (esc_state != STATE_NORMAL || *cp932str == 0x1b) { + if (esc_state == STATE_SYNC) { + esc_state = STATE_NORMAL; + } else if (esc_state == STATE_ESC) { + if (*cp932str == '[') { + esc_state = STATE_CSI; + } else if (*cp932str == '!') { + esc_state = STATE_SYNC; + } else { + esc_state = STATE_NORMAL; + } + } else if (esc_state == STATE_CSI) { + if (('0' <= *cp932str && *cp932str <= '9') || *cp932str == ';') { + } else { + esc_state = STATE_NORMAL; + } + } else { + esc_state = STATE_ESC; + } + cp932str++; + continue; + } if (*cp932str == '\t') { xo += fw*8; xo -= (xo % (fw*8)); |