shithub: riscv

Download patch

ref: e8eed628aec56b52288625e670a097ba3bdae370
parent: 7a28f9bd8cc98670f0559eed29f2cc3c62d93d8d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri May 27 14:56:31 EDT 2016

awk: restore old buffering behaviour for printf

--- a/sys/src/cmd/awk/run.c
+++ b/sys/src/cmd/awk/run.c
@@ -1018,18 +1018,10 @@
 		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);
 }