summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2000-05-18 21:36:34 (GMT)
committerhobbs <hobbs>2000-05-18 21:36:34 (GMT)
commit2fcdf4ee0d6ecc76c3acadd4e553f7dadc10be4b (patch)
tree72ce7c7ec196764b9ccce8da739cdfe58b6cc1ad
parent9be3e766082bd89b18ca17b939bbfe66a62f72bc (diff)
downloadtcl-2fcdf4ee0d6ecc76c3acadd4e553f7dadc10be4b.zip
tcl-2fcdf4ee0d6ecc76c3acadd4e553f7dadc10be4b.tar.gz
tcl-2fcdf4ee0d6ecc76c3acadd4e553f7dadc10be4b.tar.bz2
* generic/tclClock.c (FormatClock): correct code to handle locale
specific return values from strftime, if any. [Bug: 3345] * unix/tclUnixInit.c (TclpSetInitialEncodings): attempt to correct setlocale calls for XIM support and locale issues. [BUG: 5422 3345 4236 2522 2521]
-rw-r--r--generic/tclClock.c15
-rw-r--r--unix/tclUnixInit.c23
2 files changed, 21 insertions, 17 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 8b2bc53..7e71325 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclClock.c,v 1.9 2000/03/30 04:36:11 hobbs Exp $
+ * RCS: @(#) $Id: tclClock.c,v 1.10 2000/05/18 21:36:34 hobbs Exp $
*/
#include "tcl.h"
@@ -258,7 +258,7 @@ FormatClock(interp, clockVal, useGMT, format)
char *format; /* Format string */
{
struct tm *timeDataPtr;
- Tcl_DString buffer;
+ Tcl_DString buffer, uniBuffer;
int bufSize;
char *p;
int result;
@@ -360,7 +360,16 @@ FormatClock(interp, clockVal, useGMT, format)
return TCL_ERROR;
}
- Tcl_SetStringObj(Tcl_GetObjResult(interp), buffer.string, -1);
+ /*
+ * Convert the time to external encoding, in case we asked for
+ * a localized return value. [Bug: 3345]
+ */
+ Tcl_DStringInit(&uniBuffer);
+ Tcl_ExternalToUtfDString(NULL, buffer.string, -1, &uniBuffer);
+
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), uniBuffer.string, -1);
+
+ Tcl_DStringFree(&uniBuffer);
Tcl_DStringFree(&buffer);
return TCL_OK;
}
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index ca1d357..fb664bd 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -7,7 +7,7 @@
* Copyright (c) 1999 by Scriptics Corporation.
* All rights reserved.
*
- * RCS: @(#) $Id: tclUnixInit.c,v 1.18 1999/10/13 00:32:49 hobbs Exp $
+ * RCS: @(#) $Id: tclUnixInit.c,v 1.19 2000/05/18 21:36:35 hobbs Exp $
*/
#include "tclInt.h"
@@ -369,7 +369,6 @@ TclpSetInitialEncodings()
int i;
Tcl_Obj *pathPtr;
char *langEnv;
- Tcl_DString ds;
/*
* Determine the current encoding from the LC_* or LANG environment
@@ -432,19 +431,17 @@ TclpSetInitialEncodings()
Tcl_SetSystemEncoding(NULL, encoding);
+ resetPath:
/*
* Initialize the C library's locale subsystem. This is required
- * for input methods to work properly on X11. Note that we need to
- * retore the initial "C" locale so that Tcl can parse numbers
- * properly. The side effect of setting the default locale should be to
- * load any locale specific modules that are needed by X.
+ * for input methods to work properly on X11. We only do this for
+ * LC_CTYPE because that's the necessary one, and we don't want to
+ * affect LC_TIME here. The side effect of setting the default locale
+ * should be to load any locale specific modules that are needed by X.
+ * [BUG: 5422 3345 4236 2522 2521].
*/
-
- Tcl_DStringInit(&ds);
- Tcl_DStringAppend(&ds, setlocale(LC_ALL, NULL), -1);
- setlocale(LC_ALL, "");
- setlocale(LC_ALL, Tcl_DStringValue(&ds));
- Tcl_DStringFree(&ds);
+
+ setlocale(LC_CTYPE, "");
/*
* In case the initial locale is not "C", ensure that the numeric
@@ -454,7 +451,6 @@ TclpSetInitialEncodings()
*/
setlocale(LC_NUMERIC, "C");
-
/*
* Until the system encoding was actually set, the library path was
@@ -478,7 +474,6 @@ TclpSetInitialEncodings()
* encoding.
*/
- resetPath:
pathPtr = TclGetLibraryPath();
if (pathPtr != NULL) {
int objc;