15 |
|
#include "copyright.h" |
16 |
|
|
17 |
|
#include "platform.h" |
18 |
< |
#include "rtprocess.h" |
18 |
> |
#include "paths.h" |
19 |
|
#include "rterror.h" |
20 |
|
#include "color.h" |
21 |
|
#include "resolu.h" |
22 |
|
|
23 |
< |
#define MAXFILE 512 |
23 |
> |
#ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ |
24 |
> |
#undef getc |
25 |
> |
#define getc getc_unlocked |
26 |
> |
#endif |
27 |
|
|
28 |
+ |
#define MAXFILE 1024 |
29 |
+ |
|
30 |
|
#define HASMIN 1 |
31 |
|
#define HASMAX 2 |
32 |
|
|
62 |
|
|
63 |
|
int nfile; /* number of files */ |
64 |
|
|
65 |
+ |
int echoheader = 1; |
66 |
|
char ourfmt[LPICFMT+1] = PICFMT; |
67 |
|
int wrongformat = 0; |
68 |
|
|
69 |
|
|
70 |
< |
static gethfunc tabputs; |
70 |
> |
static gethfunc headline; |
71 |
|
static void compos(void); |
72 |
|
static int cmpcolr(COLR c1, double lv2); |
73 |
|
static FILE * lblopen(char *s, int *xp, int *yp); |
75 |
|
|
76 |
|
|
77 |
|
static int |
78 |
< |
tabputs( /* print line preceded by a tab */ |
78 |
> |
headline( /* print line preceded by a tab */ |
79 |
|
char *s, |
80 |
|
void *p |
81 |
|
) |
90 |
|
strcpy(ourfmt, fmt); |
91 |
|
} else |
92 |
|
wrongformat = 1; |
93 |
< |
} else { |
94 |
< |
putc('\t', stdout); |
93 |
> |
} else if (echoheader) { |
94 |
> |
fputc('\t', stdout); |
95 |
|
fputs(s, stdout); |
96 |
|
} |
97 |
|
return(0); |
117 |
|
|
118 |
|
for (an = 1; an < argc && argv[an][0] == '-'; an++) |
119 |
|
switch (argv[an][1]) { |
120 |
+ |
case 'h': |
121 |
+ |
echoheader = !echoheader; |
122 |
+ |
break; |
123 |
|
case 'x': |
124 |
|
xsiz = atoi(argv[++an]); |
125 |
|
break; |
233 |
|
} |
234 |
|
an++; |
235 |
|
/* get header */ |
236 |
< |
printf("%s:\n", input[nfile].name); |
237 |
< |
getheader(input[nfile].fp, tabputs, NULL); |
236 |
> |
if (echoheader) |
237 |
> |
printf("%s:\n", input[nfile].name); |
238 |
> |
getheader(input[nfile].fp, headline, NULL); |
239 |
|
if (wrongformat) { |
240 |
|
fprintf(stderr, "%s: incompatible input format\n", |
241 |
|
input[nfile].name); |
248 |
|
input[nfile].name); |
249 |
|
quit(1); |
250 |
|
} |
251 |
< |
if (ncolumns > 0) { |
252 |
< |
if (curcol >= ncolumns) { |
251 |
> |
if (ncolumns) { |
252 |
> |
if (curcol >= abs(ncolumns)) { |
253 |
|
cury = ymax + spacing; |
254 |
|
curx = x0; |
255 |
|
curcol = 0; |
302 |
|
ysiz = ymax; |
303 |
|
else if (ysiz > ymax) |
304 |
|
ymax = ysiz; |
305 |
+ |
if (ncolumns < 0) { /* reverse rows if requested */ |
306 |
+ |
int i = nfile; |
307 |
+ |
while (i--) |
308 |
+ |
input[i].yloc = ymax - input[i].yres - input[i].yloc; |
309 |
+ |
} |
310 |
|
/* add new header info. */ |
311 |
|
printargs(argc, argv, stdout); |
312 |
|
if (strcmp(ourfmt, PICFMT)) |
319 |
|
quit(0); |
320 |
|
userr: |
321 |
|
fprintf(stderr, |
322 |
< |
"Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ", |
322 |
> |
"Usage: %s [-h][-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ", |
323 |
|
progname); |
324 |
|
fprintf(stderr, "[-t min1][+t max1][-l lab][=SS] pic1 x1 y1 ..\n"); |
325 |
|
quit(1); |