| 350 | 
  | 
quiterr(err)            /* print message and exit */ | 
| 351 | 
  | 
char  *err; | 
| 352 | 
  | 
{ | 
| 353 | 
< | 
        if (err != NULL) | 
| 353 | 
> | 
        register int  es; | 
| 354 | 
> | 
        int  cs; | 
| 355 | 
> | 
 | 
| 356 | 
> | 
        if (es = err != NULL) | 
| 357 | 
  | 
                fprintf(stderr, "%s: %s: %s\n", progname,  | 
| 358 | 
  | 
                                fname==NULL?"<stdin>":fname, err); | 
| 359 | 
< | 
        if (wind) { | 
| 359 | 
> | 
        if (parent > 0 & wind != 0) { | 
| 360 | 
  | 
                XDestroyWindow(thedisplay, wind); | 
| 361 | 
  | 
                XFlush(thedisplay); | 
| 362 | 
  | 
        } | 
| 363 | 
< | 
        while (parent > 0 && wait(0) != -1)     /* wait for any children */ | 
| 363 | 
> | 
        while (parent > 0 && wait(&cs) != -1) { /* wait for any children */ | 
| 364 | 
> | 
                if (es == 0) | 
| 365 | 
> | 
                        es = cs>>8 & 0xff; | 
| 366 | 
  | 
                parent--; | 
| 367 | 
< | 
        exit(err != NULL); | 
| 367 | 
> | 
        } | 
| 368 | 
> | 
        exit(es); | 
| 369 | 
  | 
} | 
| 370 | 
  | 
 | 
| 371 | 
  | 
 | 
| 976 | 
  | 
getmapped()                     /* get color-mapped data */ | 
| 977 | 
  | 
{ | 
| 978 | 
  | 
        int     y; | 
| 979 | 
+ | 
                                        /* make sure we can do it first */ | 
| 980 | 
+ | 
        if (fname == NULL) | 
| 981 | 
+ | 
                quiterr("cannot map colors from standard input"); | 
| 982 | 
  | 
                                        /* set gamma correction */ | 
| 983 | 
  | 
        setcolrgam(gamcor); | 
| 984 | 
  | 
                                        /* make histogram */ | 
| 985 | 
  | 
        new_histo(); | 
| 986 | 
  | 
        for (y = 0; y < ymax; y++) { | 
| 987 | 
  | 
                if (getscan(y) < 0) | 
| 988 | 
< | 
                        quiterr("seek error in getmapped"); | 
| 988 | 
> | 
                        break; | 
| 989 | 
  | 
                add2icon(y, scanline); | 
| 990 | 
  | 
                if (scale) | 
| 991 | 
  | 
                        shiftcolrs(scanline, xmax, scale); | 
| 996 | 
  | 
        if (!new_clrtab(maxcolors)) | 
| 997 | 
  | 
                quiterr("cannot create color map"); | 
| 998 | 
  | 
        for (y = 0; y < ymax; y++) { | 
| 999 | 
< | 
                if (getscan(y) < 0) | 
| 991 | 
< | 
                        quiterr("seek error in getmapped"); | 
| 999 | 
> | 
                getscan(y); | 
| 1000 | 
  | 
                if (scale) | 
| 1001 | 
  | 
                        shiftcolrs(scanline, xmax, scale); | 
| 1002 | 
  | 
                colrs_gambs(scanline, xmax); | 
| 1039 | 
  | 
getscan(y) | 
| 1040 | 
  | 
int  y; | 
| 1041 | 
  | 
{ | 
| 1042 | 
+ | 
        static int  trunced = -1;               /* truncated file? */ | 
| 1043 | 
+ | 
skipit: | 
| 1044 | 
+ | 
        if (trunced >= 0 && y >= trunced) { | 
| 1045 | 
+ | 
                bzero(scanline, xmax*sizeof(COLR)); | 
| 1046 | 
+ | 
                return(-1); | 
| 1047 | 
+ | 
        } | 
| 1048 | 
  | 
        if (y != cury) { | 
| 1049 | 
  | 
                if (scanpos == NULL || scanpos[y] == -1) | 
| 1050 | 
  | 
                        return(-1); | 
| 1054 | 
  | 
        } else if (scanpos != NULL && scanpos[y] == -1) | 
| 1055 | 
  | 
                scanpos[y] = ftell(fin); | 
| 1056 | 
  | 
 | 
| 1057 | 
< | 
        if (freadcolrs(scanline, xmax, fin) < 0) | 
| 1058 | 
< | 
                quiterr("read error"); | 
| 1059 | 
< | 
 | 
| 1057 | 
> | 
        if (freadcolrs(scanline, xmax, fin) < 0) { | 
| 1058 | 
> | 
                fprintf(stderr, "%s: %s: unfinished picture\n", | 
| 1059 | 
> | 
                                progname, fname==NULL?"<stdin>":fname); | 
| 1060 | 
> | 
                trunced = y; | 
| 1061 | 
> | 
                goto skipit; | 
| 1062 | 
> | 
        } | 
| 1063 | 
  | 
        cury++; | 
| 1064 | 
  | 
        return(0); | 
| 1065 | 
  | 
} |