Tcl Source Code

Artifact [4e9d83d2e6]
Login

Artifact 4e9d83d2e6c9c14ade87ada88fea7e085f3e8cde:

Attachment "None" to ticket [402874ffff] added by haf 2000-12-16 22:14:26.
DESC: Some patches for support czech locale with iso8859-2 encoding.
VERS: 8.3.2
LANG: Tcl/Tk

Modified files:
* tcl/generic/tclCmdIL.c
    locale dependent sorting (lsort command)
* tcl/unix/tclUnixInit.c
    czech locale detection, initialize locale dependent sorting (LC_COLLATE)
* tk/unix/tkUnixKey.c
    keyboard input hack for input with X11 dead keys
* tk/unix/tkUnixSelect.c
    locale depended work with clipboard

DIFS:
diff -urw ../tclCmdIL.c.original tclCmdIL.c
--- ../tclCmdIL.c.original	Tue Apr  4 10:04:41 2000
+++ tclCmdIL.c	Thu Dec  7 22:17:57 2000
@@ -2823,6 +2823,10 @@
     Tcl_Obj *objPtr;
     char buffer[TCL_INTEGER_SPACE];
 
+    /* * */
+    /* Variables which we need to locale sorting support. */
+    Tcl_DString ds1, ds2;
+    /* * */    
     order = 0;
     if (infoPtr->resultCode != TCL_OK) {
 	/*
@@ -2889,7 +2893,10 @@
 	objPtr2 = objPtr;
     }
     if (infoPtr->sortMode == SORTMODE_ASCII) {
-	order = strcmp(Tcl_GetString(objPtr1), Tcl_GetString(objPtr2));
+/* * */
+	/* Apply locale dependent sorting rules - patch by Roman Vasicek */
+	order = strcoll(Tcl_UtfToExternalDString(NULL, Tcl_GetString(objPtr1), 1, &ds1), Tcl_UtfToExternalDString(NULL, Tcl_GetString(objPtr2), 1, &ds2));
+/* * */
     } else if (infoPtr->sortMode == SORTMODE_DICTIONARY) {
 	order = DictionaryCompare(
 		Tcl_GetString(objPtr1),	Tcl_GetString(objPtr2));
@@ -2963,6 +2970,10 @@
     if (!infoPtr->isIncreasing) {
 	order = -order;
     }
+    /* * */
+    Tcl_DStringFree(&ds1);
+    Tcl_DStringFree(&ds2);
+    /* * */
     return order;
 }
 

diff -urw ../tclUnixInit.c.original tclUnixInit.c
--- ../tclUnixInit.c.original	Mon Aug  7 23:31:12 2000
+++ tclUnixInit.c	Mon Nov 27 11:05:55 2000
@@ -90,6 +90,13 @@
 
     {"zh",		"cp936"},
 
+    /* * */
+    /* Czech locale support  by Roman Vasicek */
+    {"czech",		"iso8859-2"},		
+    {"cs",		"iso8859-2"},		
+    {"cs_CZ",		"iso8859-2"},		
+    /* * */
+
     {NULL, NULL}
 };
 
@@ -442,6 +449,10 @@
      */
 
     setlocale(LC_CTYPE, "");
+/* * */
+    /* For locale dependent sorting rules by Roman Vasicek */
+    setlocale(LC_COLLATE, "");
+/* * */
 
     /*
      * In case the initial locale is not "C", ensure that the numeric

diff -urw ../tkUnixKey.c.original tkUnixKey.c
--- ../tkUnixKey.c.original	Tue Apr 11 00:43:13 2000
+++ tkUnixKey.c	Thu Dec  7 21:50:14 2000
@@ -18,6 +18,91 @@
  * Prototypes for local procedures defined in this file:
  */
 
+/*
+ * Global variables for keyboard input hack to work with X11 dead keys
+ */
+KeySym lastDeadKeySym;	/* Keysym of last pressed dead key */
+/*
+ * Following  table is used to determine new composed keys.
+ * Mostly used in czech locale (system encoding iso8859-2).
+ */
+typedef struct DeadKeyTableEntry {
+    KeySym deadKeyKeySym;
+    CONST char *key;
+    CONST char *composedKey;
+} DeadKeyTableEntry;
+
+static CONST DeadKeyTableEntry deadKeyTable[] = {
+    { XK_dead_caron, "\x63", "\xe8" },	/*  -c-č */
+    { XK_dead_caron, "\x43", "\xc8" },	/*  -C-Č */
+    { XK_dead_caron, "\x64", "\xef" },	/*  -d-ď */
+    { XK_dead_caron, "\x44", "\xcf" },	/*  -D-Ď */
+    { XK_dead_caron, "\x65", "\xec" },	/*  -e-ě */
+    { XK_dead_caron, "\x45", "\xcc" },	/*  -E-Ě */
+    { XK_dead_caron, "\x6c", "\xb5" },	/*  -l-µ */
+    { XK_dead_caron, "\x4c", "\xa5" },	/*  -L-Ą */
+    { XK_dead_caron, "\x6e", "\xf2" },	/*  -n-ň */
+    { XK_dead_caron, "\x4e", "\xd2" },	/*  -N-Ň */
+    { XK_dead_caron, "\x72", "\xf8" },	/*  -r-ř */
+    { XK_dead_caron, "\x52", "\xd8" },	/*  -R-Ř */
+    { XK_dead_caron, "\x73", "\xb9" },	/*  -s-ą */
+    { XK_dead_caron, "\x53", "\xa9" },	/*  -S-© */
+    { XK_dead_caron, "\x74", "\xbb" },	/*  -t-» */
+    { XK_dead_caron, "\x54", "\xab" },	/*  -T-« */
+    { XK_dead_caron, "\x75", "\xf9" },	/*  -u-ů */	/*!! NOT CLEAR, BUT SOMETIMES USED !!*/
+    { XK_dead_caron, "\x55", "\xd9" },	/*  -U-Ů */	/*!! NOT CLEAR, BUT SOMETIMES USED !!*/
+    { XK_dead_caron, "\x7a", "\xbe" },	/*  -z-ľ */
+    { XK_dead_caron, "\x5a", "\xae" },	/*  -Z-® */
+    
+    { XK_dead_abovering, "\x75", "\xf9" },	/*  -u-ů */
+    { XK_dead_abovering, "\x55", "\xd9" },	/*  -U-Ů */
+
+    { XK_dead_acute, "\x61", "\xe1" },	/*  -a-á */
+    { XK_dead_acute, "\x41", "\xc1" },	/*  -A-Á */
+    { XK_dead_acute, "\x65", "\xe9" },	/*  -e-é */
+    { XK_dead_acute, "\x45", "\xc9" },	/*  -E-É */
+    { XK_dead_acute, "\x69", "\xed" },	/*  -i-í */
+    { XK_dead_acute, "\x49", "\xcd" },	/*  -I-Í */
+    { XK_dead_acute, "\x6f", "\xf3" },	/*  -o-ó */
+    { XK_dead_acute, "\x4f", "\xd3" },	/*  -O-Ó */
+    { XK_dead_acute, "\x75", "\xfa" },	/*  -u-ú */
+    { XK_dead_acute, "\x55", "\xda" },	/*  -U-Ú */
+    { XK_dead_acute, "\x79", "\xfd" },	/*  -y-ý */
+    { XK_dead_acute, "\x59", "\xdd" },	/*  -Y-Ý */
+
+    { 0, NULL, NULL }
+};
+/*
+ * KeySyms - generated event, we don't want use it to compose...
+ */
+static CONST KeySym excludedKeySym[] = {
+    XK_Page_Up,
+    XK_Page_Down,
+    XK_Print,
+    XK_F1,
+    XK_F2,
+    XK_F3,
+    XK_F4,
+    XK_F5,
+    XK_F6,
+    XK_F7,
+    XK_F8,
+    XK_F9,
+    XK_F10,
+    XK_F11,
+    XK_F12,
+    XK_Shift_L,
+    XK_Shift_R,
+    XK_Control_L,
+    XK_Control_R,
+    XK_Caps_Lock,
+    XK_Alt_L,
+    XK_Mode_switch,
+    XK_Num_Lock,
+    XK_Pause,
+    XK_Scroll_Lock,
+    0
+};
 
 
 /*
@@ -49,6 +134,11 @@
     int len;
     Tcl_DString buf;
     Status status;
+/* * */
+    KeySym ksKlavesy = 0;
+    int i = 0, excluded = 0;
+    char newComposedKey;
+/* * */
 
     /*
      * Overallocate the dstring to the maximum stack amount.
@@ -77,9 +167,66 @@
 	    len = 0;
 	}
     } else {
+/* * */
 	len = XLookupString(&eventPtr->xkey, Tcl_DStringValue(&buf),
-		Tcl_DStringLength(&buf), (KeySym *) NULL,
+		Tcl_DStringLength(&buf), &ksKlavesy,
 		(XComposeStatus *) NULL);
+		
+    if (lastDeadKeySym) {
+	/* We have remembered KeySym - try to combine it... */
+	excluded = 0;
+	for (i = 0; excludedKeySym[i] != 0; i++) {
+	    if (ksKlavesy == excludedKeySym[i]) {
+		excluded = 1;
+		break;
+	    }
+	}
+	if (len && (!excluded)) {
+	    /* Some key was pressed - not modifier */
+	    newComposedKey = 0;
+	    for (i = 0; deadKeyTable[i].deadKeyKeySym != 0; i++) {
+		if (lastDeadKeySym == deadKeyTable[i].deadKeyKeySym) {
+		    if (*Tcl_DStringValue(&buf) == *(deadKeyTable[i].key)) {
+			newComposedKey = *(deadKeyTable[i].composedKey);
+			break;
+		    }
+		}
+	    }
+	    if (newComposedKey) {
+		/* Composed char we found */
+		Tcl_DStringValue(&buf)[0] = newComposedKey;
+	        lastDeadKeySym = 0;
+		len = 1;
+	    } else {
+		/* Can't combine  */
+		if (lastDeadKeySym != ksKlavesy) {
+		    lastDeadKeySym = 0;
+		    for (i = 0; deadKeyTable[i].deadKeyKeySym != 0; i++) {
+			if (ksKlavesy == deadKeyTable[i].deadKeyKeySym) {
+			    lastDeadKeySym = ksKlavesy;
+			    break;
+			}
+		    }
+		    if (lastDeadKeySym) {
+			len = 0;
+		    }
+		}
+	    }
+	}
+    } else {
+	/* We don't have remembered KeySym */
+	for (i = 0; deadKeyTable[i].deadKeyKeySym != 0; i++) {
+	    if (ksKlavesy == deadKeyTable[i].deadKeyKeySym) {
+		lastDeadKeySym = ksKlavesy;
+		break;
+	    }
+	}
+	if (lastDeadKeySym) {
+	    len = 0;
+	}
+    }
+/* * */
+
     }
 #else /* TK_USE_INPUT_METHODS */
     len = XLookupString(&eventPtr->xkey, Tcl_DStringValue(&buf),

diff -urw ../tkUnixSelect.c.original tkUnixSelect.c
--- ../tkUnixSelect.c.original	Thu Jun  3 20:50:46 1999
+++ tkUnixSelect.c	Sun Dec  3 20:02:31 2000
@@ -381,7 +381,10 @@
 		    flags |= TCL_ENCODING_END;
 		}
 		if (formatType == XA_STRING) {
-		    encoding = Tcl_GetEncoding(NULL, "iso8859-1");
+		/* * */
+		/* Using system encoding instead iso8859-1 - by Roman Vasicek */
+		    encoding = Tcl_GetEncoding(NULL, Tcl_GetEncodingName(NULL));
+		/* * */
 		} else {
 		    encoding = Tcl_GetEncoding(NULL, "iso2022");
 		}
@@ -622,7 +625,10 @@
 	    if (type == dispPtr->compoundTextAtom) {
 		encoding = Tcl_GetEncoding(NULL, "iso2022");
 	    } else {
-		encoding = Tcl_GetEncoding(NULL, "iso8859-1");
+	    /* * */
+	    /* Using system encoding instead iso8859-1 - by Roman Vasicek */
+		encoding = Tcl_GetEncoding(NULL, Tcl_GetEncodingName(NULL));
+	    /* * */
 	    }
 	    Tcl_ExternalToUtfDString(encoding, propInfo, (int)numItems, &ds);
 	    if (encoding) {
@@ -952,7 +958,10 @@
 	     */
 
 	    if (type == XA_STRING) {
-		encoding = Tcl_GetEncoding(NULL, "iso8859-1");
+	    /* * */
+	    /* Using system encoding instead iso8859-1 - by Roman Vasicek */
+		encoding = Tcl_GetEncoding(NULL, Tcl_GetEncodingName(NULL));
+	    /* * */
 	    } else {
 		encoding = Tcl_GetEncoding(NULL, "iso2022");
 	    } 
@@ -1135,7 +1144,10 @@
 	if (type == retrPtr->winPtr->dispPtr->compoundTextAtom) {
 	    encoding = Tcl_GetEncoding(NULL, "iso2022");
 	} else {
-	    encoding = Tcl_GetEncoding(NULL, "iso8859-1");
+	/* * */
+	/* Using system encoding instead iso8859-1 - by Roman Vasicek */
+	    encoding = Tcl_GetEncoding(NULL, Tcl_GetEncodingName(NULL));
+	/* * */
 	}
 
 	/*