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
implementation?
void
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);
else
term.trantbl[term.icharset] = vcs[p - cs];
}
I think it is a common implementation for this kind of problems.
Regards,
--
Roberto E. Vargas Caballero
Received on Fri May 02 2014 - 22:04:05 CEST