--- ray/src/px/pcompos.c 1991/05/30 10:33:30 1.8 +++ ray/src/px/pcompos.c 1992/07/07 18:36:09 2.7 @@ -14,13 +14,10 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" +#include "resolu.h" #define MAXFILE 32 -#define SIGNHT 24 -#define setpscom(b,n) sprintf(b, "psign -h %d '%.30s'|pfilt -1 -x /2 -y /2",\ - 2*SIGNHT, n) - /* output picture size */ int xsiz = 0; int ysiz = 0; @@ -32,6 +29,8 @@ int ymax = 0; COLR bgcolr = BLKCOLR; /* background color */ +int labelht = 24; /* label height */ + int checkthresh = 0; /* check threshold value */ char *progname; @@ -49,11 +48,9 @@ int nfile; /* number of files */ int wrongformat = 0; -char tmpbuf[128]; +FILE *popen(), *lblopen(); -FILE *popen(); - tabputs(s) /* print line preceded by a tab */ char *s; { @@ -73,10 +70,10 @@ main(argc, argv) int argc; char *argv[]; { - double atof(); int ncolumns = 0; - int dolabels = 0; + int autolabel = 0; int curcol = 0, curx = 0, cury = 0; + char *thislabel; int an; progname = argv[0]; @@ -99,7 +96,18 @@ char *argv[]; ncolumns = atoi(argv[++an]); break; case 'l': - dolabels++; + switch (argv[an][2]) { + case 'a': + autolabel++; + break; + case 'h': + labelht = atoi(argv[++an]); + break; + case '\0': + goto dofiles; + default: + goto userr; + } break; case '\0': case 't': @@ -109,20 +117,9 @@ char *argv[]; } dofiles: for (nfile = 0; an < argc; nfile++) { - if (dolabels) { - if (nfile >= MAXFILE-1) { - fprintf(stderr, - "%s: only %d files allowed with labels\n", - progname, MAXFILE/2); - quit(1); - } - } else { - if (nfile >= MAXFILE) { - fprintf(stderr, "%s: only %d files allowed\n", - progname, MAXFILE); - quit(1); - } - } + if (nfile >= MAXFILE) + goto toomany; + thislabel = NULL; input[nfile].hasmin = input[nfile].hasmax = 0; while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+')) switch (argv[an][1]) { @@ -143,24 +140,36 @@ dofiles: } an += 2; break; + case 'l': + if (strcmp(argv[an], "-l")) + goto userr; + thislabel = argv[an+1]; + an += 2; + break; case '\0': if (argv[an][0] == '-') goto getfile; - /* fall through */ + goto userr; default: goto userr; } getfile: if (argc-an < (ncolumns ? 1 : 3)) goto userr; + if (autolabel && thislabel == NULL) + thislabel = argv[an]; if (!strcmp(argv[an], "-")) { input[nfile].name = ""; input[nfile].fp = stdin; } else { - input[nfile].name = argv[an]; - if ((input[nfile].fp = argv[an][0] == '!' ? - popen(argv[an]+1, "r") : - fopen(argv[an], "r")) == NULL) { + if (argv[an][0] == '!') { + input[nfile].name = ""; + input[nfile].fp = popen(argv[an]+1, "r"); + } else { + input[nfile].name = argv[an]; + input[nfile].fp = fopen(argv[an], "r"); + } + if (input[nfile].fp == NULL) { perror(argv[an]); quit(1); } @@ -176,7 +185,7 @@ getfile: } /* get picture size */ if (fgetresolu(&input[nfile].xres, &input[nfile].yres, - input[nfile].fp) != (YMAJOR|YDECR)) { + input[nfile].fp) < 0) { fprintf(stderr, "%s: bad picture size\n", input[nfile].name); quit(1); @@ -203,20 +212,20 @@ getfile: xmax = input[nfile].xloc+input[nfile].xres; if (input[nfile].yloc+input[nfile].yres > ymax) ymax = input[nfile].yloc+input[nfile].yres; - if (dolabels) { - input[++nfile].name = "