diff options
| -rw-r--r-- | generic/tclEncoding.c | 5 | ||||
| -rw-r--r-- | generic/tclInt.h | 1 | ||||
| -rw-r--r-- | generic/tclZipfs.c | 13 |
3 files changed, 9 insertions, 10 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 8dae256..6cec532 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -186,6 +186,7 @@ TCL_DECLARE_MUTEX(encodingMutex) static Tcl_Encoding defaultEncoding = NULL; static Tcl_Encoding systemEncoding = NULL; Tcl_Encoding tclIdentityEncoding = NULL; +Tcl_Encoding tclUtf8Encoding = NULL; /* * Names of encoding profiles and corresponding integer values. @@ -609,7 +610,7 @@ TclInitEncodingSubsystem(void) type.freeProc = NULL; type.nullSize = 1; type.clientData = INT2PTR(ENCODING_UTF); - Tcl_CreateEncoding(&type); + tclUtf8Encoding = Tcl_CreateEncoding(&type); type.clientData = NULL; type.encodingName = "cesu-8"; Tcl_CreateEncoding(&type); @@ -731,6 +732,8 @@ TclFinalizeEncodingSubsystem(void) defaultEncoding = NULL; FreeEncoding(tclIdentityEncoding); tclIdentityEncoding = NULL; + FreeEncoding(tclUtf8Encoding); + tclUtf8Encoding = NULL; hPtr = Tcl_FirstHashEntry(&encodingTable, &search); while (hPtr != NULL) { diff --git a/generic/tclInt.h b/generic/tclInt.h index 9c7ad17..1b6b3c4 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3029,6 +3029,7 @@ MODULE_SCOPE TclPlatformType tclPlatform; */ MODULE_SCOPE Tcl_Encoding tclIdentityEncoding; +MODULE_SCOPE Tcl_Encoding tclUtf8Encoding; MODULE_SCOPE int TclEncodingProfileNameToId(Tcl_Interp *interp, const char *profileName, diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index e9f7157..2df7705 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -273,15 +273,11 @@ static struct { * they are believed to not be UTF-8; only * written to from Tcl code in a trusted * interpreter, so not protected by mutex. */ - Tcl_Encoding utf8; /* The UTF-8 encoding that we prefer to use - * for the strings (especially filenames) - * embedded in a ZIP. Other encodings are used - * dynamically. */ int idCount; /* Counter for channel names */ Tcl_HashTable fileHash; /* File name to ZipEntry mapping */ Tcl_HashTable zipHash; /* Mount to ZipFile mapping */ } ZipFS = { - 0, 0, 0, DEFAULT_WRITE_MAX_SIZE, NULL, NULL, 0, + 0, 0, 0, DEFAULT_WRITE_MAX_SIZE, NULL, 0, {0,{0,0,0,0},0,0,0,0,0,0,0,0,0}, {0,{0,0,0,0},0,0,0,0,0,0,0,0,0} }; @@ -743,7 +739,7 @@ DecodeZipEntryText( while (1) { int srcRead, dstWrote; - int result = Tcl_ExternalToUtf(NULL, ZipFS.utf8, src, srcLen, flags, + int result = Tcl_ExternalToUtf(NULL, tclUtf8Encoding, src, srcLen, flags, &state, dst, dstLen, &srcRead, &dstWrote, NULL); int soFar = dst + dstWrote - Tcl_DStringValue(dstPtr); @@ -1860,7 +1856,6 @@ ZipfsSetup(void) ZipFS.fallbackEntryEncoding = (char *) Tcl_Alloc(strlen(ZIPFS_FALLBACK_ENCODING) + 1); strcpy(ZipFS.fallbackEntryEncoding, ZIPFS_FALLBACK_ENCODING); - ZipFS.utf8 = Tcl_GetEncoding(NULL, "utf-8"); ZipFS.initialized = 1; Tcl_CreateExitHandler(ZipfsExitHandler, NULL); } @@ -2541,7 +2536,7 @@ ZipAddFile( * crazy enough to embed NULs in filenames, they deserve what they get! */ - zpathExt = Tcl_UtfToExternalDString(ZipFS.utf8, zpathTcl, -1, &zpathDs); + zpathExt = Tcl_UtfToExternalDString(tclUtf8Encoding, zpathTcl, -1, &zpathDs); zpathlen = strlen(zpathExt); if (zpathlen + ZIP_CENTRAL_HEADER_LEN > bufsize) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -3210,7 +3205,7 @@ ZipFSMkZipOrImg( } z = (ZipEntry *) Tcl_GetHashValue(hPtr); - name = Tcl_UtfToExternalDString(ZipFS.utf8, z->name, TCL_INDEX_NONE, &ds); + name = Tcl_UtfToExternalDString(tclUtf8Encoding, z->name, TCL_INDEX_NONE, &ds); len = Tcl_DStringLength(&ds); SerializeCentralDirectoryEntry(start, end, (unsigned char *) buf, z, len); |
