Re: [dev] [st PATCH] Simplify tdeftran.

From: Roberto E. Vargas Caballero <>
Date: Fri, 2 May 2014 22:04:05 +0200

Idea behind tdeftran is allowing to users create new charsets if they want,
and it is the reason why it is built as a data driven function. I don't
think is a good idea implement a lookup table using a switch statement, but
it is true that it can be written better. What do you think about this

tdeftran(char ascii) {
        static char cs[] = "0B";
        static int vcs[] = {CS_GRAPHIC0, CS_USA};
        char *p;

        if((p = strchr(cs, ascii)) == NULL)
                fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii);
                term.trantbl[term.icharset] = vcs[p - cs];

I think it is a common implementation for this kind of problems.


Roberto E. Vargas Caballero
Received on Fri May 02 2014 - 22:04:05 CEST

This archive was generated by hypermail 2.3.0 : Fri May 02 2014 - 22:12:06 CEST