diff options
author | andreas_kupries <akupries@shaw.ca> | 2000-12-08 18:55:57 (GMT) |
---|---|---|
committer | andreas_kupries <akupries@shaw.ca> | 2000-12-08 18:55:57 (GMT) |
commit | 68fa236d8e2326157a6024efdfba2ca00a803c7a (patch) | |
tree | 56f092b30fbb493ade8b0b81b99dafba7f926f46 | |
parent | fb2436036c727de7a3c19cf004bd8a22cb98082c (diff) | |
download | tcl-68fa236d8e2326157a6024efdfba2ca00a803c7a.zip tcl-68fa236d8e2326157a6024efdfba2ca00a803c7a.tar.gz tcl-68fa236d8e2326157a6024efdfba2ca00a803c7a.tar.bz2 |
Fixing bug #119417 using patch #102496.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclEncoding.c | 36 |
2 files changed, 32 insertions, 10 deletions
@@ -1,3 +1,9 @@ +2000-12-08 Andreas Kupries <a.kupries@westend.com> + + * generic/tclEncoding.c (LoadTableEncoding): Changed dangerous + code to something less critical. This fixes bug 119417, part A + without affecting the speed when loading encodings. + 2000-12-08 Donal K. Fellows <fellowsd@cs.man.ac.uk> * doc/open.n: Added xref to fconfigure and advice on the opening diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index c70dd0b..beb36e5 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.5 2000/01/21 02:25:26 hobbs Exp $ + * RCS: @(#) $Id: tclEncoding.c,v 1.6 2000/12/08 18:55:58 andreas_kupries Exp $ */ #include "tclInt.h" @@ -1328,14 +1328,31 @@ LoadTableEncoding(interp, name, type, chan) TableEncodingData *dataPtr; unsigned short *pageMemPtr; Tcl_EncodingType encType; - char *hex; + + /* + * Speed over memory. Use a full 256 character table to decode hex + * sequences in the encoding files. + */ + static char staticHex[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, - 10, 11, 12, 13, 14, 15 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 ... 15 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16 ... 31 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 32 ... 47 */ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 48 ... 63 */ + 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 64 ... 79 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 ... 95 */ + 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 96 ... 111 */ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 112 ... 127 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 128 ... 143 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 144 ... 159 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 160 ... 175 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 176 ... 191 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 192 ... 207 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 208 ... 223 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 224 ... 239 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 240 ... 255 */ }; - hex = staticHex - '0'; - Tcl_DStringInit(&lineString); Tcl_Gets(chan, &lineString); line = Tcl_DStringValue(&lineString); @@ -1383,15 +1400,15 @@ LoadTableEncoding(interp, name, type, chan) Tcl_ReadChars(chan, objPtr, 3 + 16 * (16 * 4 + 1), 0); p = Tcl_GetString(objPtr); - hi = (hex[(int)p[0]] << 4) + hex[(int)p[1]]; + hi = (staticHex[(unsigned int)p[0]] << 4) + staticHex[(unsigned int)p[1]]; dataPtr->toUnicode[hi] = pageMemPtr; p += 2; for (lo = 0; lo < 256; lo++) { if ((lo & 0x0f) == 0) { p++; } - ch = (hex[(int)p[0]] << 12) + (hex[(int)p[1]] << 8) - + (hex[(int)p[2]] << 4) + hex[(int)p[3]]; + ch = (staticHex[(unsigned int)p[0]] << 12) + (staticHex[(unsigned int)p[1]] << 8) + + (staticHex[(unsigned int)p[2]] << 4) + staticHex[(unsigned int)p[3]]; if (ch != 0) { used[ch >> 8] = 1; } @@ -1510,7 +1527,6 @@ LoadTableEncoding(interp, name, type, chan) encType.nullSize = (type == ENCODING_DOUBLEBYTE) ? 2 : 1; encType.clientData = (ClientData) dataPtr; return Tcl_CreateEncoding(&encType); - } /* |