Tcl Source Code

Artifact [1bd06e9ada]
Login

Artifact 1bd06e9ada554baef022c71738587c0801809294:

Attachment "channelbug.patch" to ticket [772288ffff] added by dkf 2003-07-16 20:18:16.
? bug.tcl
? bug2.tcl
? channelbug.patch
? unix/dltest.marker
? unix/httpd_26183
Index: generic/tclEncoding.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclEncoding.c,v
retrieving revision 1.16
diff -u -r1.16 tclEncoding.c
--- generic/tclEncoding.c	21 Feb 2003 02:40:58 -0000	1.16
+++ generic/tclEncoding.c	16 Jul 2003 13:17:05 -0000
@@ -2877,6 +2877,13 @@
 		Tcl_DStringFree(&libPath);
 		Tcl_DStringFree(&buffer);
 	    }
+	    /*
+	     * Ensure that the std{in,out,err} are there; thishas to
+	     * be done here, not TclInitSubsystems() to make sure that
+	     * encoding initialisation is completed first.  Otherwise
+	     * the encoding of the standard channels ends up wrong.
+	     */
+	    TclInitStdIOChannels();
 	}
 	TclpInitUnlock();
     }
Index: generic/tclIO.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIO.c,v
retrieving revision 1.61.2.2
diff -u -r1.61.2.2 tclIO.c
--- generic/tclIO.c	11 Apr 2003 17:35:33 -0000	1.61.2.2
+++ generic/tclIO.c	16 Jul 2003 13:17:06 -0000
@@ -178,7 +178,14 @@
      * allocating it for each thread.
      */
     (void) TCL_TSD_INIT(&dataKey);
-}   
+}
+void
+TclInitStdIOChannels()
+{
+    Tcl_GetStdChannel(TCL_STDIN);
+    Tcl_GetStdChannel(TCL_STDOUT);
+    Tcl_GetStdChannel(TCL_STDERR);
+}
 
 /*
  *-------------------------------------------------------------------------
@@ -362,7 +369,7 @@
                 if (tsdPtr->stdinChannel != (Tcl_Channel) NULL) {
                     (void) Tcl_RegisterChannel((Tcl_Interp *) NULL,
                             tsdPtr->stdinChannel);
-                }
+		}
 	    }
 	    channel = tsdPtr->stdinChannel;
 	    break;
@@ -373,7 +380,7 @@
                 if (tsdPtr->stdoutChannel != (Tcl_Channel) NULL) {
                     (void) Tcl_RegisterChannel((Tcl_Interp *) NULL,
                             tsdPtr->stdoutChannel);
-                }
+		}
 	    }
 	    channel = tsdPtr->stdoutChannel;
 	    break;
@@ -384,7 +391,7 @@
                 if (tsdPtr->stderrChannel != (Tcl_Channel) NULL) {
                     (void) Tcl_RegisterChannel((Tcl_Interp *) NULL,
                             tsdPtr->stderrChannel);
-                }
+		}
 	    }
 	    channel = tsdPtr->stderrChannel;
 	    break;
Index: generic/tclInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
retrieving revision 1.118.2.3
diff -u -r1.118.2.3 tclInt.h
--- generic/tclInt.h	16 Apr 2003 23:31:44 -0000	1.118.2.3
+++ generic/tclInt.h	16 Jul 2003 13:17:06 -0000
@@ -1644,6 +1644,7 @@
 EXTERN void		TclInitDbCkalloc _ANSI_ARGS_((void));
 EXTERN void		TclInitEncodingSubsystem _ANSI_ARGS_((void));
 EXTERN void		TclInitIOSubsystem _ANSI_ARGS_((void));
+EXTERN void		TclInitStdIOChannels _ANSI_ARGS_((void));
 EXTERN void		TclInitNamespaceSubsystem _ANSI_ARGS_((void));
 EXTERN void		TclInitNotifier _ANSI_ARGS_((void));
 EXTERN void		TclInitObjSubsystem _ANSI_ARGS_((void));