From 0e4014dae7727a06a80b59b6ede26d8d08d2c42b Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Wed, 20 Sep 2017 23:27:18 +0900 Subject: fmdsp-pacc: add code to ignore ANSI escape sequences --- fmdsp/fmdsp-pacc.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'fmdsp/fmdsp-pacc.c') 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)); -- cgit v1.2.3