diff options
author | hobbs <hobbs> | 2003-02-21 02:40:57 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2003-02-21 02:40:57 (GMT) |
commit | cc0e6436fbea0546291e1b2cbed4d3f8cecda514 (patch) | |
tree | f82ec344f5ec77eeefc3b3366748601a8ac9ee6b /generic/tclEncoding.c | |
parent | 2fad92d8ea334f30a6fbe1b10359e70d6370f626 (diff) | |
download | tcl-cc0e6436fbea0546291e1b2cbed4d3f8cecda514.zip tcl-cc0e6436fbea0546291e1b2cbed4d3f8cecda514.tar.gz tcl-cc0e6436fbea0546291e1b2cbed4d3f8cecda514.tar.bz2 |
* generic/tclEncoding.c (LoadTableEncoding):
* library/encoding/cp932.enc: Correct jis round-trip encoding
* library/encoding/euc-jp.enc: by adding 'R' type to .enc files.
* library/encoding/iso2022-jp.enc: [Patch #689341] (koboyasi, taguchi)
* library/encoding/jis0208.enc:
* library/encoding/shiftjis.enc:
* tests/encoding.test:
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r-- | generic/tclEncoding.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 93505c3..576a479 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclEncoding.c,v 1.15 2002/11/27 02:53:40 hobbs Exp $ + * RCS: @(#) $Id: tclEncoding.c,v 1.16 2003/02/21 02:40:58 hobbs Exp $ */ #include "tclInt.h" @@ -1535,6 +1535,48 @@ LoadTableEncoding(interp, name, type, chan) dataPtr->fromUnicode[hi] = emptyPage; } } + /* + * For trailing 'R'everse encoding, see [Patch #689341] + */ + 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; @@ -1615,6 +1657,9 @@ LoadEscapeEncoding(name, chan) 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)); } |