diff options
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 44 |
1 files changed, 39 insertions, 5 deletions
@@ -77,8 +77,42 @@ char *fbuf; { register int c, i; register char *s, *t; + static char table_inv[] = { 0,8,4,12,2,10,6,14,1,9, 5,13, 3,11, 7,15 }; + static char table_nop[] = { 0,1,2, 3,4, 5,6, 7,8,9,10,11,12,13,14,15 }; + char *table = table_nop; /* optionally invert bits in nibble */ + register inc = 0; /* optionally swap nimmles */ + int bits; + int len; t = s = fbuf; + + /* Does this look like an X bitmap ? */ + if (sscanf(s, "#define %*s %d", &bits) == 1) { + if (bits == 48) { + char type1[256]; + char type2[256]; + while (*s && *s++ != '\n'); + if (sscanf(s, "#define %*s %d", &bits) == 1) if (bits == 48) { + while (*s && *s++ != '\n'); + for (len=0; s[len] && s[len]!='\n'; len++); + if (len<255) { + if (sscanf(s, "static %s %s", type1,type2)==2 && + (!strcmp(type1, "char") || + !strcmp(type2, "char"))) { + while (*s && *s++ != '\n'); + inc = 1; + table = table_inv; + } + else fprintf(stderr, "warning: xbitmap line 3 not static [unsigned] short ...\n"); + } else fprintf(stderr, "warning: xbitmap line 3 too long\n"); + } + else fprintf(stderr, "warning: xbitmaps must be 48x48\n"); + } + else fprintf(stderr, "warning: xbitmaps must be 48x48\n"); + } + /* Ensure s is reset if it was not an X bitmap ... */ + if (! inc) s = fbuf; + for(i = strlen(s); i > 0; i--) { c = (int)*(s++); @@ -89,7 +123,7 @@ char *fbuf; status = ERR_EXCESS; break; } - *(t++) = c - '0'; + (t++)[inc] = table[c - '0']; inc = - inc; } else if ((c >= 'A') && (c <= 'F')) { @@ -98,7 +132,7 @@ char *fbuf; status = ERR_EXCESS; break; } - *(t++) = c - 'A' + 10; + (t++)[inc] = table[c - 'A' + 10]; inc = - inc; } else if ((c >= 'a') && (c <= 'f')) { @@ -107,10 +141,10 @@ char *fbuf; status = ERR_EXCESS; break; } - *(t++) = c - 'a' + 10; + (t++)[inc] = table[c - 'a' + 10]; inc = - inc; } - else if (((c == 'x') || (c == 'X')) && (t > fbuf) && (*(t-1) == 0)) - t--; + else if (((c == 'x') || (c == 'X')) && (t > fbuf) && + ((t-1)[-inc] == table[0])) { t--; inc = -inc; } } if (t < fbuf + DIGITS) longjmp(comp_env, ERR_INSUFF); |