Re: V1.5.1 X-Face format change?

Mike Bolotski (misha@ai.mit.edu)
Fri, 19 Apr 91 14:49:05 EDT

>>>>> On Fri, 19 Apr 1991 11:35:25 -0700 (PDT), Michael Urban <urban%hercules@rand.org> said:

MU> Sure looks like the patch to gen.c to fix the lexer-scrambling problem
MU> is somehow defective; `misha's face was scrambled here (but was OK on
MU> patchlevel 0). I have gone back to my previous workaround of declaring
MU> an additional flak-catching buffer after `F' in compfaces.h, until the
MU> X-Face problem is resolved.

Here's the fix I got from Victor Riley. I installed it and X-Face
parsing/decompression now works fine (SunOS 4.1.1, SS2).

VR> In the latest patch there is a bug in compface/gen.c - I have sent
VR> Rich this file with my recommended changes. Try replacing this
VR> file with your current version and see if the problems go
VR> away.

====8<====8<=====8<====
/*
* Compface - 48x48x1 image compression and decompression
*
* Copyright (c) James Ashton - Sydney University - June 1990.
*
* Written 11th November 1989.
*
* Permission is given to distribute these sources, as long as the
* copyright messages are not removed, and no monies are exchanged.
*
* No responsibility is taken for any errors on inaccuracies inherent
* either to the comments or the code of this program, but if reported
* to me, then an attempt will be made to fix them.
*/

#include "compface.h"

#define GEN(g) F[h] ^= G.g[k]; break

static void Gen(f)
register char *f;
{
register int m, l, k, j, i, h;

for (j = 0; j < HEIGHT; j++)
{
for (i = 0; i < WIDTH; i++)
{
h = i + j * WIDTH;
k = 0;
for (l = i - 2; l <= i + 2; l++)
for (m = j - 2; m <= j; m++)
{
if ((l >= i) && (m == j))
continue;
if ((l > 0) && (l <= WIDTH) && (m > 0))
k = *(f + l + m * WIDTH) ? k * 2 + 1 : k * 2;
}
switch (i)
{
case 1 :
switch (j)
{
case 1 : GEN(g_22);
case 2 : GEN(g_21);
default : GEN(g_20);
}
break;
case 2 :
switch (j)
{
case 1 : GEN(g_12);
case 2 : GEN(g_11);
default : GEN(g_10);
}
break;
case WIDTH - 1 :
switch (j)
{
case 1 : GEN(g_42);
case 2 : GEN(g_41);
default : GEN(g_40);
}
break;
case WIDTH :
switch (j)
{
case 1 : GEN(g_32);
case 2 : GEN(g_31);
default : GEN(g_30);
}
break;
default :
switch (j)
{
case 1 : GEN(g_02);
case 2 : GEN(g_01);
default : GEN(g_00);
}
break;
}
}
}
}

void GenFace()
{
static char new[PIXELS];
register char *f1;
register char *f2;
register int i;

f1 = new;
f2 = F;
i = PIXELS;
while (i-- > 0)
*(f1++) = *(f2++);
Gen(new);
}

void UnGenFace()
{
Gen(F);
}