8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdlib.h> |
11 |
– |
#include <string.h> |
12 |
– |
#include <stdio.h> |
11 |
|
#include <ctype.h> |
12 |
|
|
13 |
+ |
#include "rtio.h" |
14 |
|
#include "platform.h" |
15 |
|
#include "resolu.h" |
17 |
– |
#include "rtio.h" |
16 |
|
|
17 |
|
#define DOHEADER 1 |
18 |
|
#define DORESOLU 2 |
96 |
|
switch (argv[i][1]) { |
97 |
|
case 't': |
98 |
|
curterm = argv[i][2]; |
99 |
+ |
if (!curterm) curterm = '\n'; |
100 |
|
break; |
101 |
|
case 'i': |
102 |
|
switch (argv[i][2]) { |
295 |
|
if (bytsiz[i] > 0) { /* binary output */ |
296 |
|
if (getbinary(buf, bytsiz[i], 1, stdin) < 1) |
297 |
|
break; |
298 |
< |
putbinary(buf, bytsiz[i], 1, output[i]); |
298 |
> |
if (putbinary(buf, bytsiz[i], 1, output[i]) != 1) |
299 |
> |
break; |
300 |
|
} else if (bytsiz[i] < 0) { /* N-field output */ |
301 |
|
int n = -bytsiz[i]; |
302 |
|
while (n--) { |
303 |
|
if (!scanOK(termc[i])) |
304 |
|
break; |
305 |
< |
fputs(buf, output[i]); |
305 |
> |
if (fputs(buf, output[i]) == EOF) |
306 |
> |
break; |
307 |
|
} |
308 |
|
if (n >= 0) /* fell short? */ |
309 |
|
break; |
310 |
+ |
if (termc[i] != '\n') /* add EOL if none */ |
311 |
+ |
fputc('\n', output[i]); |
312 |
|
} else { /* 1-field output */ |
313 |
|
if (!scanOK(termc[i])) |
314 |
|
break; |
315 |
< |
fputs(buf, output[i]); |
315 |
> |
if (fputs(buf, output[i]) == EOF) |
316 |
> |
break; |
317 |
> |
if (termc[i] != '\n') /* add EOL if none */ |
318 |
> |
fputc('\n', output[i]); |
319 |
|
} |
320 |
|
} |
321 |
|
if (i < nfiles) |
322 |
|
break; |
323 |
|
} while (--outcnt); |
324 |
|
/* check ending */ |
325 |
+ |
if (fflush(NULL) == EOF) { |
326 |
+ |
fputs(argv[0], stderr); |
327 |
+ |
fputs(": write error on one or more outputs\n", stderr); |
328 |
+ |
return(1); |
329 |
+ |
} |
330 |
|
if (outcnt > 0) { |
331 |
|
fputs(argv[0], stderr); |
332 |
|
fputs(": warning: premature EOD\n", stderr); |