--- generic/tclEncoding.c.orig	Tue Sep  3 11:01:23 2002
+++ generic/tclEncoding.c	Wed Feb 19 13:42:13 2003
@@ -1533,6 +1533,41 @@
 	    dataPtr->fromUnicode[hi] = emptyPage;
 	}
     }
+    /* For trailing 'R'everse encoding... */
+    Tcl_DStringInit(&lineString);
+    do {
+	int len;
+	/* skip leading empty lines */
+	while ((len = Tcl_Gets(chan, &lineString)) == 0)
+	    ;
+	if (len < 0)
+	    break;
+	line = Tcl_DStringValue(&lineString);
+	if (line[0] != 'R')
+	    break;
+	for (Tcl_DStringSetLength(&lineString, 0);
+	     (len = Tcl_Gets(chan, &lineString)) >= 0;
+	     Tcl_DStringSetLength(&lineString, 0)) {
+	    unsigned char* p;
+	    int to, from;
+	    if (len < 5)
+		continue;
+	    p = (unsigned char*) Tcl_DStringValue(&lineString);
+	    to = (staticHex[p[0]] << 12) + (staticHex[p[1]] << 8)
+		+ (staticHex[p[2]] << 4) + staticHex[p[3]];
+	    if (to == 0)
+	    	continue;
+	    for (p += 5, len -= 5; len >= 0 && *p; p += 5, len -= 5) {
+		from = (staticHex[p[0]] << 12) + (staticHex[p[1]] << 8)
+			+ (staticHex[p[2]] << 4) + staticHex[p[3]];
+	    	if (from == 0)
+		    continue;
+		dataPtr->fromUnicode[from >> 8][from & 0xff] = to;
+	    }
+	}
+    } while (0);
+    Tcl_DStringFree(&lineString);
+
     encType.encodingName    = name;
     encType.toUtfProc	    = TableToUtfProc;
     encType.fromUtfProc	    = TableFromUtfProc;
@@ -1612,6 +1647,9 @@
 
 		strncpy(est.name, argv[0], sizeof(est.name));
 		est.name[sizeof(est.name) - 1] = '\0';
+
+		/* To avoid infinite recursion in [encoding system iso2022-*]*/
+		Tcl_GetEncoding(NULL, est.name);
 
 		est.encodingPtr = NULL;
 		Tcl_DStringAppend(&escapeData, (char *) &est, sizeof(est));
diff -u library/encoding.orig/cp932.enc library/encoding/cp932.enc
--- library/encoding.orig/cp932.enc	Fri Oct  5 05:04:45 2001
+++ library/encoding/cp932.enc	Wed Feb 19 16:07:31 2003
@@ -783,3 +783,19 @@
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
+R
+8160 301C FF5E
+8161 2016 2225
+817C 2212 FF0D
+8191 00A2 FFE0
+8192 00A3 FFE1
+81CA 00AC FFE2
+81BE 222a
+81BF 2229
+81DA 2220
+81DB 22a5
+81DF 2261
+81E0 2252
+81E3 221a
+81E6 2235
+81E7 222b
diff -u library/encoding.orig/euc-jp.enc library/encoding/euc-jp.enc
--- library/encoding.orig/euc-jp.enc	Fri Oct  5 05:04:45 2001
+++ library/encoding/euc-jp.enc	Wed Feb 19 13:39:11 2003
@@ -1344,3 +1344,10 @@
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
+R
+A1C1 301C FF5E
+A1C2 2016 2225
+A1DD 2212 FF0D
+A1F1 00A2 FFE0
+A1F2 00A3 FFE1
+A2CC 00AC FFE2
diff -u library/encoding.orig/iso2022-jp.enc library/encoding/iso2022-jp.enc
--- library/encoding.orig/iso2022-jp.enc	Sat Mar  2 12:51:00 2002
+++ library/encoding/iso2022-jp.enc	Wed Feb 19 12:55:44 2003
@@ -3,7 +3,7 @@
 name		iso2022-jp
 init		{}
 final		{}
-iso8859-1	\x1b(B
+ascii		\x1b(B
 jis0201		\x1b(J
 jis0208		\x1b$B
 jis0208		\x1b$@
diff -u library/encoding.orig/jis0208.enc library/encoding/jis0208.enc
--- library/encoding.orig/jis0208.enc	Fri Oct  5 05:04:46 2001
+++ library/encoding/jis0208.enc	Wed Feb 19 13:39:35 2003
@@ -1310,3 +1310,10 @@
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
+R
+2141 301C FF5E 
+2142 2016 2225 
+215D 2212 FF0D 
+2171 00A2 FFE0 
+2172 00A3 FFE1 
+224C 00AC FFE2 
diff -u library/encoding.orig/shiftjis.enc library/encoding/shiftjis.enc
--- library/encoding.orig/shiftjis.enc	Fri Oct  5 05:04:46 2001
+++ library/encoding/shiftjis.enc	Wed Feb 19 13:39:30 2003
@@ -681,3 +681,10 @@
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
+R
+8160 301C FF5E
+8161 2016 2225
+817C 2212 FF0D
+8191 00A2 FFE0
+8192 00A3 FFE1
+81CA 00AC FFE2
