From: <mie...@us...> - 2012-08-06 13:00:19
|
Revision: 8137 http://oorexx.svn.sourceforge.net/oorexx/?rev=8137&view=rev Author: miesfeld Date: 2012-08-06 13:00:13 +0000 (Mon, 06 Aug 2012) Log Message: ----------- 2849375 - redirect output to a /dev/tty Modified Paths: -------------- main/branches/4.1/trunk/common/platform/unix/SysFile.cpp main/branches/4.1/trunk/common/platform/unix/SysFile.hpp Modified: main/branches/4.1/trunk/common/platform/unix/SysFile.cpp =================================================================== --- main/branches/4.1/trunk/common/platform/unix/SysFile.cpp 2012-08-06 12:53:20 UTC (rev 8136) +++ main/branches/4.1/trunk/common/platform/unix/SysFile.cpp 2012-08-06 13:00:13 UTC (rev 8137) @@ -62,7 +62,7 @@ # include <sys/filio.h> #endif -#if defined(__APPLE__) && defined(__MACH__) +#if defined(__APPLE__) && defined(__MACH__) # define lseek64 lseek # define open64 open #endif @@ -111,6 +111,11 @@ * function. * * @return true if the file was opened successfully, false otherwise. + * + * @remarks TTY devices should not be buffered. Stdin, stdout, etc. are set + * correctly in their setStdIn() setStdOut(), etc., functions. But + * here we need to check for TTY devices and not buffer them. + * /dev/pts/n for example. */ bool SysFile::open(const char *name, int openFlags, int openMode, int shareMode) { @@ -142,9 +147,18 @@ // set eof flag fileeof = false; + getStreamTypeInfo(); + // set the default buffer size (and allocate the buffer) - setBuffering(true, 0); - getStreamTypeInfo(); + if ( isTTY ) + { + setBuffering(false, 0); + } + else + { + setBuffering(true, 0); + } + return true; } @@ -156,6 +170,11 @@ * @param fdopenMode The fdopen() mode flags for the stream. * * @return true if the file opened ok, false otherwise. + * + * @remarks TTY devices should not be buffered. Stdin, stdout, etc. are set + * correctly in their setStdIn() setStdOut(), etc., functions. But + * here we need to check for TTY devices and not buffer them. + * /dev/pts/n for example. */ bool SysFile::open(int handle) { @@ -163,9 +182,18 @@ openedHandle = false; fileHandle = handle; ungetchar = -1; // 0xFF indicates no char + getStreamTypeInfo(); + // set the default buffer size (and allocate the buffer) - setBuffering(true, 0); - getStreamTypeInfo(); + if ( isTTY ) + { + setBuffering(false, 0); + } + else + { + setBuffering(true, 0); + } + return true; } Modified: main/branches/4.1/trunk/common/platform/unix/SysFile.hpp =================================================================== --- main/branches/4.1/trunk/common/platform/unix/SysFile.hpp 2012-08-06 12:53:20 UTC (rev 8136) +++ main/branches/4.1/trunk/common/platform/unix/SysFile.hpp 2012-08-06 13:00:13 UTC (rev 8137) @@ -126,6 +126,7 @@ inline bool isReadable() { return readable; } inline bool isWriteable() { return writeable; } inline bool isOpen() { return fileHandle != -1; } + inline bool isStdIn() { return fileHandle == stdinHandle; } inline bool error() { return errInfo != 0; } inline int errorInfo() { return errInfo; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |