123 |
|
setformat(const char *fmt) |
124 |
|
{ |
125 |
|
switch (fmt[0]) { |
126 |
– |
case 'a': |
126 |
|
case 'f': |
127 |
|
case 'd': |
128 |
+ |
SET_FILE_BINARY(stdin); |
129 |
+ |
/* fall through */ |
130 |
+ |
case 'a': |
131 |
|
inpfmt = fmt[0]; |
132 |
|
break; |
133 |
|
default: |
500 |
|
LUENT *lep; |
501 |
|
|
502 |
|
if (ospec == NULL) { /* use stdout? */ |
503 |
< |
if (!using_stdout && header) |
504 |
< |
printheader(stdout); |
503 |
> |
if (!using_stdout) { |
504 |
> |
if (outfmt != 'a') |
505 |
> |
SET_FILE_BINARY(stdout); |
506 |
> |
if (header) |
507 |
> |
printheader(stdout); |
508 |
> |
} |
509 |
|
using_stdout = 1; |
510 |
|
return stdout; |
511 |
|
} |
547 |
|
if (lep->key == NULL) /* new entry */ |
548 |
|
lep->key = strcpy((char *)malloc(strlen(ofname)+1), ofname); |
549 |
|
if (lep->data == NULL) { /* open output file */ |
550 |
< |
FILE *fp = fopen(ofname, "w"); |
550 |
> |
FILE *fp; |
551 |
|
int i; |
552 |
+ |
if (ofname[0] == '!') /* output to command */ |
553 |
+ |
fp = popen(ofname+1, "w"); |
554 |
+ |
else |
555 |
+ |
fp = fopen(ofname, "w"); |
556 |
|
if (fp == NULL) { |
557 |
|
sprintf(errmsg, "cannot open '%s' for writing", ofname); |
558 |
|
error(SYSTEM, errmsg); |
559 |
|
} |
560 |
+ |
if (outfmt != 'a') |
561 |
+ |
SET_FILE_BINARY(fp); |
562 |
|
if (header) |
563 |
|
printheader(fp); |
564 |
|
/* play catch-up */ |