/* program for converting the character converting file "*.uni.src" to the SVGATextMode form "*.uni.new". To make the new table active, rename it from "*.uni.new" to "*.uni" by removing the trailling ".new". */ /* defining the "*" in the filename */ #define STAR "klm_def" /* Defining the "new" extension */ #define NEW ".new" #include <stdio.h> char *truncTabs(register const char *input) { static char buff[512]; register i; for (i=0; *input; input++) if (*input=='\t') do buff[i++]=' '; while (i & 7); else buff[i++]=*input; while (i<512) buff[i++]=' '; return buff; } int ishex(char c) { return (c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F'); } void convert(char *buff) { unsigned x, y; static unsigned line=0; line++; if (1!=sscanf(buff+16,"%x",&y)) fprintf(stderr,"No hex number at line offset 16 in line %u\n",line); if (ishex(buff[8]) && ishex(buff[9])) { if (1!=sscanf(buff+8,"%x",&x)) fprintf(stderr,"Inpossible error\n"); } else if (buff[8]!=' ' && buff[9]==' ') x=(unsigned char)buff[8]; else if (buff[8]==' ' && buff[9]==' ') return; else fprintf(stderr,"Can't interpret line offset 8/9 in line %u.\n",line); printf("0x%02X\tU+%04X\n",x,y); } int main(void) { char input[256]; freopen(STAR ".uni.src","rb",stdin ); freopen(STAR ".uni" NEW,"wb",stdout); while (gets(input)) convert(truncTabs(input)); return 0; } /* End of klm_def.uni.src_trans.c */