[hackers] [st] Simplify tdeftrans || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 07 Jun 2014 13:24:31 +0200

commit 93661042a2a0cf6f3655360f5c52215c684a4211
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Sat Jun 7 13:23:45 2014 +0200

    Simplify tdeftrans

diff --git a/st.c b/st.c
index fde4d2d..b148401 100644
--- a/st.c
+++ b/st.c
_AT_@ -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
", ascii);
         else
- term.trantbl[term.icharset] = (*bp)[1];
+ term.trantbl[term.icharset] = vcs[p - cs];
 }
 
 void
Received on Sat Jun 07 2014 - 13:24:31 CEST

This archive was generated by hypermail 2.3.0 : Sat Jun 07 2014 - 13:36:07 CEST