From 6468cf2bca94c513b598b8238ce64d0cc639da40 Mon Sep 17 00:00:00 2001 From: redman Date: Fri, 30 Jul 1999 02:02:26 +0000 Subject: * 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] --- ChangeLog | 5 +++++ win/tclWinChan.c | 33 ++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index f47373a..9c20f15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 1999-07-29 + * 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] + * unix/mkLinks.tcl: Applied patch to avoid linking pack.n to pack-old.n. Patch from Don Porter. [Bug: 2469] 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; } -- cgit v0.12