|
2001-04-06
| ||
| 03:39 | • Closed ticket [217899ffff]: Locale support is broken again plus 3 other chan... artifact: 2a62950486 user: dgp | |
| 03:38 | • Open ticket [217899ffff]. artifact: f8255a0bea user: dgp | |
|
2000-10-26
| ||
| 08:09 | • Closed ticket [217899ffff]. artifact: d94c209758 user: welch | |
| 00:45 | • New ticket [217899ffff]. artifact: 98c3fef0cc user: nobody | |
Locale support is broken again
Closed / Fixed217899ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:45:36
OriginalBugID: 2521 Bug
Version: 8.2b2
SubmitDate: '1999-08-11'
LastModified: '2000-04-09'
Severity: SER
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 2522 3345 4236
OS: Linux
OSVersion: Debian 2.1
Machine: Other
FixedDate: '2000-10-25'
ClosedDate: '2000-04-09'
Name: Victor Wagner
Comments:
It would be nice to be able to change locale inside Tcl script (for
example
via traces on LC_ environment variables). It would save much trouble
with date
formatting and parsing.
ReproducibleScript:
Any wish script with locale ru_RU.KOI8-R
ObservedBehavior:
Tk scripts don't accept Cyrillic keyboard input.
Investigation shows that when current encoding is determined from LANG
environment variable and this variable has
<language>_<country>.<encoding> format, goto resetPath statement is
performed and setlocale call
is skipped. Moreover, even if this code is executed, Tcl sets locale
temporarily
to user settings and then resets it (all categories) back, when
resetting of
LC_NUMERIC only is enough for correct parsing of numbers (and this is
performed
two lines down the code).
clock format prints date in English when explicitely told to use
locale-specific
format (-format "%c"). When Tcl is patched to support locale, clock
format
incorrectly assumes that strftime returns string in ISO8859-1 encoding
and
doesn't attempt to convert it from current system default encoding.
DesiredBehavior:
All locale categories, except LC_NUMERIC should be set to user locale.
setlocale call should be performed to initilize X input method
correctly,
regardless of locale value.
date/time values should be formatted according to user preferences. If
app author wished, he always can set format to recognizable by clock
scan explicitely. May be even default format should be one of those,
instead of "%c",
but there should be way to obtain locale-specific date/time format via
clock format.
Patch:
diff -c -r tcl8.2b2/generic/tclClock.c tcl8.2b2-patched/generic/tclClock.c
*** tcl8.2b2/generic/tclClock.cFri Apr 16 04:46:43 1999
--- tcl8.2b2-patched/generic/tclClock.cWed Aug 11 17:23:22 1999
***************
*** 228,234 ****
char *format;/* Format string */
{
struct tm *timeDataPtr;
! Tcl_DString buffer;
int bufSize;
char *p;
Tcl_Obj *resultPtr;
--- 228,234 ----
char *format;/* Format string */
{
struct tm *timeDataPtr;
! Tcl_DString buffer,unicode_buffer;
int bufSize;
char *p;
Tcl_Obj *resultPtr;
***************
*** 315,322 ****
"\"", (char *) NULL);
return TCL_ERROR;
}
!
! Tcl_SetStringObj(resultPtr, buffer.string, -1);
Tcl_DStringFree(&buffer);
return TCL_OK;
}
--- 315,324 ----
"\"", (char *) NULL);
return TCL_ERROR;
}
! Tcl_DStringInit(&unicode_buffer);
! Tcl_ExternalToUtfDString(NULL,buffer.string,-1,&unicode_buffer);
! Tcl_SetStringObj(resultPtr, unicode_buffer.string, -1 );
! Tcl_DStringFree(&unicode_buffer);
Tcl_DStringFree(&buffer);
return TCL_OK;
}
diff -c -r tcl8.2b2/unix/tclUnixInit.c tcl8.2b2-patched/unix/tclUnixInit.c
*** tcl8.2b2/unix/tclUnixInit.cFri Jul 23 01:50:56 1999
--- tcl8.2b2-patched/unix/tclUnixInit.cWed Aug 11 17:00:57 1999
***************
*** 432,437 ****
--- 432,438 ----
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
***************
*** 443,449 ****
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, setlocale(LC_ALL, NULL), -1);
setlocale(LC_ALL, "");
- setlocale(LC_ALL, Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
[ED NOTE: SHOULD REMOVE ALL DString STUFF, IF ANY]
/*
--- 444,449 ----
***************
*** 478,484 ****
* encoding.
*/
- resetPath:
pathPtr = TclGetLibraryPath();
if (pathPtr != NULL) {
int objc;
--- 478,483 ----
PatchFiles:
generic/tclClock.c
unix/tkUnixInit.c
With this patch, the locale would be set to the user defined
environment, which may cause problems in the Tcl C library.
The intent of the above setlocale NULL->""->original, is that
we expect to get the current runtime setting (should be C for
the C runtime library), set it to "" to force loading of the
locale tables for X, and then back to the runtime. The idea
is that users could change the runtime in their own extension.
The solution may be to provide a 'tcl locale type ?settotype?'
Tcl level command.
-- 10/21/1999 hobbs
welch Closed ticket [217899ffff].
[History diff]2000-10-26 08:09:11
dgp Open ticket [217899ffff].
[History diff]2001-04-06 03:38:16
dgp Closed ticket [217899ffff].
[History diff]2001-04-06 03:39:11
Log in (anonymous is fine) to add a comment.