| 54 |
|
FILE *fp; |
| 55 |
|
int i; |
| 56 |
|
|
| 57 |
< |
if (argc > 1 && !strcmp(argv[1], "-d")) { |
| 57 |
> |
if (argc > 1 && (argv[1][0] == '-') | (argv[1][0] == '+') && |
| 58 |
> |
argv[1][1] == 'd') { |
| 59 |
> |
dim = 1 - 2*(argv[1][0] == '-'); |
| 60 |
|
argc--; argv++; |
| 59 |
– |
dim = 1; |
| 61 |
|
} |
| 62 |
|
#ifdef getc_unlocked /* avoid lock/unlock overhead */ |
| 63 |
|
flockfile(stdin); |
| 76 |
|
fputs("No resolution string\n", stderr); |
| 77 |
|
return 1; |
| 78 |
|
} |
| 79 |
< |
fputsresolu(&rs, stdout); |
| 79 |
> |
if (dim > 0) |
| 80 |
> |
fputsresolu(&rs, stdout); |
| 81 |
|
} |
| 82 |
|
fflush(stdout); |
| 83 |
|
execvp(argv[2], argv+2); |
| 101 |
|
SET_FILE_BINARY(stdout); |
| 102 |
|
if (getheader(stdin, NULL, NULL) < 0) |
| 103 |
|
return 1; |
| 104 |
< |
if (dim) { /* skip resolution string? */ |
| 104 |
> |
if (dim < 0) { /* skip resolution string? */ |
| 105 |
|
RESOLU rs; |
| 106 |
|
if (!fgetsresolu(&rs, stdin)) { |
| 107 |
|
fputs("No resolution string\n", stderr); |
| 116 |
|
if ((fp = fopen(argv[i], "r")) == NULL) |
| 117 |
|
fputs(": cannot open\n", stdout); |
| 118 |
|
else { |
| 119 |
< |
if (dim) { |
| 119 |
> |
if (dim < 0) { /* dimensions only */ |
| 120 |
> |
if (getheader(fp, NULL, NULL) < 0) { |
| 121 |
> |
fputs("bad header\n", stdout); |
| 122 |
> |
continue; |
| 123 |
> |
} |
| 124 |
|
fputs(": ", stdout); |
| 125 |
|
getdim(fp); |
| 126 |
|
} else { |
| 127 |
|
tabstr(":\n", NULL); |
| 128 |
< |
getheader(fp, tabstr, NULL); |
| 128 |
> |
if (getheader(fp, tabstr, NULL) < 0) |
| 129 |
> |
return 1; |
| 130 |
|
fputc('\n', stdout); |
| 131 |
+ |
if (dim > 0) { |
| 132 |
+ |
fputc('\t', stdout); |
| 133 |
+ |
getdim(fp); |
| 134 |
+ |
} |
| 135 |
|
} |
| 136 |
|
fclose(fp); |
| 137 |
|
} |
| 138 |
|
} |
| 139 |
|
if (argc == 1) { |
| 140 |
< |
if (dim) { |
| 140 |
> |
if (dim < 0) { |
| 141 |
> |
if (getheader(stdin, NULL, NULL) < 0) |
| 142 |
> |
return 1; |
| 143 |
|
getdim(stdin); |
| 144 |
|
} else { |
| 145 |
|
if (getheader(stdin, (gethfunc *)fputs, stdout) < 0) |
| 146 |
|
return 1; |
| 147 |
|
fputc('\n', stdout); |
| 148 |
+ |
if (dim > 0) |
| 149 |
+ |
getdim(stdin); |
| 150 |
|
} |
| 151 |
|
} |
| 152 |
|
return 0; |
| 160 |
|
{ |
| 161 |
|
int j; |
| 162 |
|
int c; |
| 163 |
< |
/* skip header */ |
| 149 |
< |
if (getheader(fp, NULL, NULL) < 0) { |
| 150 |
< |
fputs("bad header\n", stdout); |
| 151 |
< |
return; |
| 152 |
< |
} |
| 163 |
> |
|
| 164 |
|
switch (c = getc(fp)) { |
| 165 |
|
case '+': /* picture */ |
| 166 |
|
case '-': |