From e1f212419083307320a8f1d1a3e8dc0c548efa92 Mon Sep 17 00:00:00 2001 From: Deposite Pirate Date: Sun, 16 Sep 2018 22:56:55 +0200 Subject: Debian fixes. --- compface.c | 2 +- compface.h | 1 - file.c | 44 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/compface.c b/compface.c index 90664c4..8d2cda8 100644 --- a/compface.c +++ b/compface.c @@ -19,7 +19,7 @@ #include "config.h" #endif -#include "compface_private.h" +#include "compface.h" int compface(fbuf) diff --git a/compface.h b/compface.h index fc4f486..d251b16 100644 --- a/compface.h +++ b/compface.h @@ -143,7 +143,6 @@ int AllBlack P((char *, int, int)) ; int AllWhite P((char *, int, int)) ; int BigPop P((Prob *)) ; int compface P((char *)) ; -int main P((int, char *[])) ; int ReadBuf P(()) ; int Same P((char *, int, int)) ; int uncompface P((char *)) ; diff --git a/file.c b/file.c index 3a3809e..019be13 100644 --- a/file.c +++ b/file.c @@ -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); -- cgit v1.2.3-70-g09d2