st
simple terminal
git clone https://9o.is/git/st.git
commit 66c187a57f6eb0d5e113c346c2fbd4587783f3e8 parent c10f9b62cd8a1965b447af643897c555e6cc9a4b Author: Roberto E. Vargas Caballero <k0ga@shike2.com> Date: Sat, 7 Jun 2014 13:23:45 +0200 Simplify tdeftrans Diffstat:
| M | st.c | | | 15 | +++++---------- |
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/st.c b/st.c @@ -2315,19 +2315,14 @@ techo(char *buf, int len) { void tdeftran(char ascii) { - char c, (*bp)[2]; - static char tbl[][2] = { - {'0', CS_GRAPHIC0}, {'B', CS_USA}, - {0, 0} - }; - - for (bp = &tbl[0]; (c = (*bp)[0]) && c != ascii; ++bp) - /* nothing */; + static char cs[] = "0B"; + static int vcs[] = {CS_GRAPHIC0, CS_USA}; + char *p; - if (c == 0) + if((p = strchr(cs, ascii)) == NULL) fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii); else - term.trantbl[term.icharset] = (*bp)[1]; + term.trantbl[term.icharset] = vcs[p - cs]; } void