use a function to get stdout and stderr, instead of depending
on a specific libc implementation.
also make test/run.go replace \r\n by \n before comparing
output.
Fixes #2121.
Part of issue 1741.
R=alex.brainman, rsc, r, remyoudompheng
CC=golang-dev
https://golang.org/cl/
5847068
+// skip
+
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build !netbsd
-
package stdio
/*
#include <stdio.h>
+
+// on mingw, stderr and stdout are defined as &_iob[FILENO]
+// on netbsd, they are defined as &__sF[FILENO]
+// and cgo doesn't recognize them, so write a function to get them,
+// instead of depending on internals of libc implementation.
+FILE *getStdout(void) { return stdout; }
+FILE *getStderr(void) { return stderr; }
*/
import "C"
-var Stdout = (*File)(C.stdout)
-var Stderr = (*File)(C.stderr)
+var Stdout = (*File)(C.getStdout())
+var Stderr = (*File)(C.getStderr())
+++ /dev/null
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package stdio
-
-/*
-#include <stdio.h>
-
-extern FILE __sF[3];
-*/
-import "C"
-import "unsafe"
-
-var Stdout = (*File)(unsafe.Pointer(&C.__sF[1]))
-var Stderr = (*File)(unsafe.Pointer(&C.__sF[2]))
::if errorlevel 1 goto fail
::echo.
-:: TODO ..\misc\cgo\stdio
-::echo # ..\misc\cgo\stdio
-::go run %GOROOT%\test\run.go - ..\misc\cgo\stdio
-::if errorlevel 1 goto fail
-::echo.
+echo # ..\misc\cgo\stdio
+go run %GOROOT%\test\run.go - ..\misc\cgo\stdio
+if errorlevel 1 goto fail
+echo.
echo # ..\misc\cgo\test
go test ..\misc\cgo\test
if err != nil {
t.err = fmt.Errorf("%s\n%s", err, out)
}
- if string(out) != t.expectedOutput() {
+ if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() {
t.err = fmt.Errorf("incorrect output\n%s", out)
}