retitle 349015 compface: no longer reads XBM files tag 349015 patch thanks The Debian-specific patch that allowed compface(1) to read XBM images got lost between 1989.11.11-24 and 1:1.5.2-1. (Upstream patched the new version to write XBMs, but not to read them.) The one-line patch in 1:1.5.2-2 worked around a symptom of this rather than the problem itself.
The following patch restores support for reading XBMs, and reverses the 1:1.5.2-2 change (which is causing spurious warnings for correct files). I can NMU if necessary. Thanks, Matej
diff -ruN libcompface-1.5.2.dist/cmain.c libcompface-1.5.2/cmain.c --- libcompface-1.5.2.dist/cmain.c 2006-02-03 20:06:35.000000000 +0100 +++ libcompface-1.5.2/cmain.c 2006-02-03 20:52:13.000000000 +0100 @@ -110,7 +110,7 @@ case -1 : INITERR(inname) ADDERR(": insufficient or invalid data") ERROR - case 0 : INITWARN(inname) + case 1 : INITWARN(inname) ADDWARN(": excess data ignored") WARN default : ; diff -ruN libcompface-1.5.2.dist/compface.1 libcompface-1.5.2/compface.1 --- libcompface-1.5.2.dist/compface.1 2005-10-04 14:29:00.000000000 +0200 +++ libcompface-1.5.2/compface.1 2006-02-03 20:52:13.000000000 +0100 @@ -51,8 +51,9 @@ The first line contains 72 characters and following lines contain 79 characters except that the last line may be short. .LP -If the -X option is given to uncompface, it generates XBM format -directly. +This version of compface has been patched to also be able to handle +normal XBM images. uncompface will produce XBM output only if the -X +switch is applied. .LP The amount of compression obtained varies between face image files but the output of diff -ruN libcompface-1.5.2.dist/compface.3 libcompface-1.5.2/compface.3 --- libcompface-1.5.2.dist/compface.3 2005-10-04 14:29:00.000000000 +0200 +++ libcompface-1.5.2/compface.3 2006-02-03 20:52:13.000000000 +0100 @@ -39,6 +39,10 @@ The first line contains 72 characters and following lines contain 79 characters except that the last line may be short. .LP +This version of compface has been patched to also be able to handle +normal XBM images. uncompface will produce XBM output only if the -X +switch is applied. +.LP The amount of compression obtained varies between face image files but the output of .I compface diff -ruN libcompface-1.5.2.dist/file.c libcompface-1.5.2/file.c --- libcompface-1.5.2.dist/file.c 2005-10-04 14:28:47.000000000 +0200 +++ libcompface-1.5.2/file.c 2006-02-03 20:52:13.000000000 +0100 @@ -77,8 +77,39 @@ { 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; t = s = fbuf; + + /* Does this look like an X bitmap ? */ + if (sscanf(s, "#define %*s %d", &bits) == 1) { + if (bits == 48) { + char type1[128]; + char type2[128]; + while (*s && *s++ != '\n'); + if (sscanf(s, "#define %*s %d", &bits) == 1) if (bits == 48) { + while (*s && *s++ != '\n'); + 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: 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 +120,7 @@ status = ERR_EXCESS; break; } - *(t++) = c - '0'; + (t++)[inc] = table[c - '0']; inc = - inc; } else if ((c >= 'A') && (c <= 'F')) { @@ -98,7 +129,7 @@ status = ERR_EXCESS; break; } - *(t++) = c - 'A' + 10; + (t++)[inc] = table[c - 'A' + 10]; inc = - inc; } else if ((c >= 'a') && (c <= 'f')) { @@ -107,10 +138,10 @@ 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);