summaryrefslogtreecommitdiff
path: root/sys/src/cmd/awk
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2016-05-27 18:56:31 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2016-05-27 18:56:31 +0200
commite8eed628aec56b52288625e670a097ba3bdae370 (patch)
tree00b0ba706b3340c0e45db53ba7c38fd640015481 /sys/src/cmd/awk
parent7a28f9bd8cc98670f0559eed29f2cc3c62d93d8d (diff)
awk: restore old buffering behaviour for printf
Diffstat (limited to 'sys/src/cmd/awk')
-rw-r--r--sys/src/cmd/awk/run.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/sys/src/cmd/awk/run.c b/sys/src/cmd/awk/run.c
index 1fbb217a1..416d3a8c7 100644
--- a/sys/src/cmd/awk/run.c
+++ b/sys/src/cmd/awk/run.c
@@ -1018,18 +1018,10 @@ Cell *awkprintf(Node **a, int) /* printf */
FATAL("printf string %.30s... too long. can't happen.", buf);
if (istemp(x))
tfree(x);
- if (a[1] == nil) {
- /* fputs(buf, stdout); */
- if (Bwrite(&stdout, buf, len) < 0)
- FATAL("write error on stdout");
- Bflush(&stdout);
- } else {
- fp = redirect(ptoi(a[1]), a[2]);
- /* fputs(buf, fp); */
- if(Bwrite(fp, buf, len) < 0)
- FATAL("write error on %s", filename(fp));
- Bflush(fp);
- }
+ fp = a[1]? redirect(ptoi(a[1]), a[2]): &stdout;
+ if(Bwrite(fp, buf, len) < 0)
+ FATAL("write error on %s", filename(fp));
+ if(fp != &stdout) Bflush(fp);
free(buf);
return(True);
}