From: ian Date: Fri, 22 Oct 2004 21:24:46 +0000 (+0000) Subject: some fixes X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=3944ce709d08a285a81a96878392d91be6c4d5da;p=trains.git some fixes --- diff --git a/layout/subseg2display.c b/layout/subseg2display.c index 40122f7..40695cb 100644 --- a/layout/subseg2display.c +++ b/layout/subseg2display.c @@ -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); } } }