summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorredman <redman@noemail.net>1999-07-30 02:02:25 (GMT)
committerredman <redman@noemail.net>1999-07-30 02:02:25 (GMT)
commit998253e13d4a92480342f1214ce7f73632c3d9a5 (patch)
tree22ca5febd6a022674564de0813191609d4dd2615 /win
parentc5fa019ea758ebc41e73a2fc00cf0c6ec7bec846 (diff)
downloadtcl-998253e13d4a92480342f1214ce7f73632c3d9a5.zip
tcl-998253e13d4a92480342f1214ce7f73632c3d9a5.tar.gz
tcl-998253e13d4a92480342f1214ce7f73632c3d9a5.tar.bz2
* win/tclWinChan.c: Allow tcl to open CON and NUL, even for std
channels. Checking for bad/unusable std channels was moved to Tk since its only purpose was to check whether to use the Tk Console Window for the std channels. [Bug: 2393 2392 2209 2458] FossilOrigin-Name: 204ad522090d96fed9ee5de60c2a38f9dc90faa3
Diffstat (limited to 'win')
-rw-r--r--win/tclWinChan.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/win/tclWinChan.c b/win/tclWinChan.c
index 4052e87..1bca83d 100644
--- a/win/tclWinChan.c
+++ b/win/tclWinChan.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinChan.c,v 1.7 1999/05/22 01:20:15 stanton Exp $
+ * RCS: @(#) $Id: tclWinChan.c,v 1.8 1999/07/30 02:02:35 redman Exp $
*/
#include "tclWinInt.h"
@@ -762,7 +762,7 @@ TclpOpenFileChannel(interp, fileName, modeString, permissions)
}
TclWinConvertError(err);
if (interp != (Tcl_Interp *) NULL) {
- Tcl_AppendResult(interp, "couldn't open \"", fileName, "\": ",
+ Tcl_AppendResult(interp, "couldn't open \"", fileName, "\": ",
Tcl_PosixError(interp), (char *) NULL);
}
Tcl_DStringFree(&buffer);
@@ -785,6 +785,7 @@ TclpOpenFileChannel(interp, fileName, modeString, permissions)
if (GetCommState(handle, &dcb)) {
type = FILE_TYPE_SERIAL;
}
+
}
}
@@ -811,22 +812,23 @@ TclpOpenFileChannel(interp, fileName, modeString, permissions)
}
channel = TclpCreateCommandChannel(readFile, writeFile, NULL, 0, NULL);
break;
+ case FILE_TYPE_CHAR:
case FILE_TYPE_DISK:
+ case FILE_TYPE_UNKNOWN:
channel = TclWinOpenFileChannel(handle, channelName,
channelPermissions,
(mode & O_APPEND) ? FILE_APPEND : 0);
break;
- case FILE_TYPE_UNKNOWN:
- case FILE_TYPE_CHAR:
default:
/*
* The handle is of an unknown type, probably /dev/nul equivalent
- * or possibly a closed handle. Don't use it, otherwise Tk runs into
- * trouble with the MS DevStudio debugger.
+ * or possibly a closed handle.
*/
channel = NULL;
+ Tcl_AppendResult(interp, "couldn't open \"", fileName, "\": ",
+ "bad file type", (char *) NULL);
break;
}
@@ -927,16 +929,15 @@ Tcl_MakeFileChannel(rawHandle, mode)
break;
case FILE_TYPE_DISK:
+ case FILE_TYPE_CHAR:
+ case FILE_TYPE_UNKNOWN:
channel = TclWinOpenFileChannel(handle, channelName, mode, 0);
break;
- case FILE_TYPE_UNKNOWN:
- case FILE_TYPE_CHAR:
default:
/*
* The handle is of an unknown type, probably /dev/nul equivalent
- * or possibly a closed handle. Don't use it, otherwise Tk runs into
- * trouble with the MS DevStudio debugger.
+ * or possibly a closed handle.
*/
channel = NULL;
@@ -994,19 +995,21 @@ TclpGetDefaultStdChannel(type)
panic("TclGetDefaultStdChannel: Unexpected channel type");
break;
}
+
handle = GetStdHandle(handleId);
/*
- * Note that we need to check for 0 because Windows will return 0 if this
+ * Note that we need to check for 0 because Windows may return 0 if this
* is not a console mode application, even though this is not a valid
- * handle.
+ * handle.
*/
-
+
if ((handle == INVALID_HANDLE_VALUE) || (handle == 0)) {
return NULL;
}
-
+
channel = Tcl_MakeFileChannel(handle, mode);
+
if (channel == NULL) {
return NULL;
}
@@ -1065,7 +1068,7 @@ TclWinOpenFileChannel(handle, channelName, permissions, appendMode)
*/
for (infoPtr = tsdPtr->firstFilePtr; infoPtr != NULL;
- infoPtr = infoPtr->nextPtr) {
+ infoPtr = infoPtr->nextPtr) {
if (infoPtr->handle == (HANDLE) handle) {
return (permissions == infoPtr->validMask) ? infoPtr->channel : NULL;
}