Tcl Source Code

Artifact [664f6de884]
Login

Artifact 664f6de884d0f0136971964b9347177b4939c018:

Attachment "tcl-tip35-mopup.patch" to ticket [1901828fff] added by jenglish 2008-02-27 02:31:55.
Date: Tue Feb 26 11:28:51 PST 2008
Files: unix/tclUnixChan.c

--- unix/tclUnixChan.c.tip35-mopup.old	2008-02-26 10:51:43.176536344 -0800
+++ unix/tclUnixChan.c	2008-02-26 11:28:43.004325536 -0800
@@ -142,8 +142,6 @@
 typedef struct TtyState {
     FileState fs;		/* Per-instance state of the file descriptor.
 				 * Must be the first field. */
-    int stateUpdated;		/* Flag to say if the state has been modified
-				 * and needs resetting. */
     IOSTATE savedState;		/* Initial state of device. Used to reset
 				 * state when device closed. */
 } TtyState;
@@ -254,8 +252,6 @@
 			    const char *buf, int toWrite, int *errorCode);
 static void		TcpWatchProc(ClientData instanceData, int mask);
 #ifdef SUPPORTS_TTY
-static int		TtyCloseProc(ClientData instanceData,
-			    Tcl_Interp *interp);
 static void		TtyGetAttributes(int fd, TtyAttrs *ttyPtr);
 static int		TtyGetOptionProc(ClientData instanceData,
 			    Tcl_Interp *interp, const char *optionName,
@@ -311,7 +307,7 @@
 static Tcl_ChannelType ttyChannelType = {
     "tty",			/* Type name. */
     TCL_CHANNEL_VERSION_5,	/* v5 channel */
-    TtyCloseProc,		/* Close proc. */
+    FileCloseProc,		/* Close proc. */
     FileInputProc,		/* Input proc. */
     FileOutputProc,		/* Output proc. */
     NULL,			/* Seek proc. */
@@ -714,46 +710,6 @@
 }
 
 #ifdef SUPPORTS_TTY
-/*
- *----------------------------------------------------------------------
- *
- * TtyCloseProc --
- *
- *	This function is called from the generic IO level to perform
- *	channel-type-specific cleanup when a tty based channel is closed.
- *
- * Results:
- *	0 if successful, errno if failed.
- *
- * Side effects:
- *	Closes the device of the channel.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-TtyCloseProc(
-    ClientData instanceData,	/* Tty state. */
-    Tcl_Interp *interp)		/* For error reporting - unused. */
-{
-#if 0
-    /*
-     * TIP#35 agreed to remove the unsave so that TCL could be used as a
-     * simple stty. It would be cleaner to remove all the stuff related to
-     *	  TtyState.stateUpdated
-     *	  TtyState.savedState
-     * Then the structure TtyState would be the same as FileState. IMO this
-     * cleanup could better be done for the final 8.4 release after nobody
-     * complained about the missing unsave. - schroedter
-     */
-    if (ttyPtr->stateUpdated) {
-	SETIOSTATE(ttyPtr->fs.fd, &ttyPtr->savedState);
-    }
-#endif
-
-    return FileCloseProc(instanceData, interp);
-}
-
 #ifdef USE_TERMIOS
 /*
  *----------------------------------------------------------------------
@@ -840,7 +796,6 @@
 	 */
 
 	TtySetAttributes(fsPtr->fd, &tty);
-	((TtyState *) fsPtr)->stateUpdated = 1;
 	return TCL_OK;
     }
 
@@ -1632,10 +1587,10 @@
     int initialize)
 {
     TtyState *ttyPtr;
+    int stateUpdated = 0;
 
     ttyPtr = (TtyState *) ckalloc((unsigned) sizeof(TtyState));
     GETIOSTATE(fd, &ttyPtr->savedState);
-    ttyPtr->stateUpdated = 0;
     if (initialize) {
 	IOSTATE iostate = ttyPtr->savedState;
 
@@ -1646,7 +1601,7 @@
 		iostate.c_cflag & CREAD ||
 		iostate.c_cc[VMIN] != 1 ||
 		iostate.c_cc[VTIME] != 0) {
-	    ttyPtr->stateUpdated = 1;
+	    stateUpdated = 1;
 	}
 	iostate.c_iflag = IGNBRK;
 	iostate.c_oflag = 0;
@@ -1669,7 +1624,7 @@
 	 * Only update if we're changing anything to avoid possible blocking.
 	 */
 
-	if (ttyPtr->stateUpdated) {
+	if (stateUpdated) {
 	    SETIOSTATE(fd, &iostate);
 	}
     }