40 lines
885 B
Diff
40 lines
885 B
Diff
From 5073ddcd87868dfbaab7a8b2f2eff4cb509662a9 Mon Sep 17 00:00:00 2001
|
|
From: Dominik Honnef <dominik@honnef.co>
|
|
Date: Sat, 6 Jun 2015 23:25:03 +0200
|
|
Subject: [PATCH] Portable implementation of swapOutput
|
|
|
|
Assigning to stdin, stdout and stderr is not portable. They're specified
|
|
to be macros, and for example musl will not allow such code to be
|
|
compiled.
|
|
|
|
Use dup2 instead.
|
|
---
|
|
src/curses/curses.go | 7 ++++---
|
|
1 file changed, 4 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/curses/curses.go b/src/curses/curses.go
|
|
index 985dd87..1cfc2c9 100644
|
|
--- src/curses/curses.go
|
|
+++ src/curses/curses.go
|
|
@@ -1,13 +1,14 @@
|
|
package curses
|
|
|
|
/*
|
|
+#include <unistd.h>
|
|
#include <ncurses.h>
|
|
#include <locale.h>
|
|
#cgo LDFLAGS: -lncurses
|
|
void swapOutput() {
|
|
- FILE* temp = stdout;
|
|
- stdout = stderr;
|
|
- stderr = temp;
|
|
+ dup2(2, 3);
|
|
+ dup2(1, 2);
|
|
+ dup2(3, 1);
|
|
}
|
|
*/
|
|
import "C"
|
|
--
|
|
2.3.6
|
|
|