chiark / gitweb /
some fixes
authorian <ian>
Fri, 22 Oct 2004 21:24:46 +0000 (21:24 +0000)
committerian <ian>
Fri, 22 Oct 2004 21:24:46 +0000 (21:24 +0000)
layout/subseg2display.c

index 40122f738cd4e5b6e2d0fade538c6b4c386955d0..40695cb13fa8a50efc819c9906bed4c8f76b4e98 100644 (file)
@@ -169,12 +169,12 @@ static void subsegarg(id ix, const char *arg) {
 
 /*---------- actual image processing ----------*/
 
-static int cols, rows, informat;
+static int cols, rows, informat, row, col;
 static pixval maxval;
 static FILE *encodingfile;
 
 static void badformat(const char *m) {
-  fprintf(stderr,"bad format: %s\n", m);
+  fprintf(stderr,"bad format (row=%d,col=%d): %s\n", row,col, m);
   exit(12);
 }
 
@@ -211,7 +211,7 @@ static void angle_to_colour(double result[3],
 }
 
 static void process(void) {
-  int row, col, i;
+  int i;
   
   ppm_readppminit(encodingfile, &cols, &rows, &maxval, &informat);
   if (maxval != 255) badformat("wrong maxval");
@@ -223,7 +223,7 @@ static void process(void) {
       unsigned char rgbi[3], rgbo[3];
       double rgbod[3];
 
-      if (fread(rgbi,1,3,encodingfile)!=-3) {
+      if (fread(rgbi,1,3,encodingfile)!=3) {
        if (ferror(encodingfile)) { perror("reading"); exit(12); }
        else badformat("truncated file");
       }
@@ -254,9 +254,9 @@ static void process(void) {
        angle_to_colour(rgbdirn, angle);
 
        ix= !movfeatpos ?
-         (segnum < fixed_a ? fixed[segnum] : fixed[0]) :
+         (segnum < fixed_a ? fixed[segnum] : 0) :
          (segnum < moveable_a && movfeatpos < moveable[segnum].lookup_a
-          ? moveable[segnum].lookup[movfeatpos] : fixed[0]);
+          ? moveable[segnum].lookup[movfeatpos] : 0);
 
        r= &idinfo[ix];
 
@@ -268,7 +268,7 @@ static void process(void) {
       for (i=0; i<3; i++)
        rgbo[i]= rgbod[i] * 255.0;
 
-      if (fwrite(rgbi,1,3,stdout)!=3) { perror("writing"); exit(12); }
+      if (fwrite(rgbo,1,3,stdout)!=3) { perror("writing"); exit(12); }
     }
 }