summaryrefslogtreecommitdiffstats
path: root/win/tclWinChan.c
diff options
context:
space:
mode:
authorredman <redman>1999-07-30 02:02:26 (GMT)
committerredman <redman>1999-07-30 02:02:26 (GMT)
commit6468cf2bca94c513b598b8238ce64d0cc639da40 (patch)
tree22ca5febd6a022674564de0813191609d4dd2615 /win/tclWinChan.c
parent8ae23baa02cc4fb6cbdea4ed29006244f133bd0c (diff)
downloadtcl-6468cf2bca94c513b598b8238ce64d0cc639da40.zip
tcl-6468cf2bca94c513b598b8238ce64d0cc639da40.tar.gz
tcl-6468cf2bca94c513b598b8238ce64d0cc639da40.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]
Diffstat (limited to 'win/tclWinChan.c')
-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;
}