diff options
-rw-r--r-- | ChangeLog | 23 | ||||
-rw-r--r-- | doc/Encoding.3 | 96 | ||||
-rw-r--r-- | doc/encoding.n | 17 | ||||
-rw-r--r-- | generic/tcl.decls | 18 | ||||
-rw-r--r-- | generic/tclBasic.c | 9 | ||||
-rw-r--r-- | generic/tclCmdAH.c | 21 | ||||
-rw-r--r-- | generic/tclDecls.h | 46 | ||||
-rw-r--r-- | generic/tclEncoding.c | 26 | ||||
-rw-r--r-- | generic/tclInt.decls | 21 | ||||
-rw-r--r-- | generic/tclInt.h | 7 | ||||
-rw-r--r-- | generic/tclIntDecls.h | 43 | ||||
-rw-r--r-- | generic/tclStubInit.c | 12 | ||||
-rw-r--r-- | generic/tclTest.c | 15 | ||||
-rw-r--r-- | library/init.tcl | 14 | ||||
-rw-r--r-- | tests/cmdAH.test | 4 | ||||
-rw-r--r-- | tests/encoding.test | 28 | ||||
-rw-r--r-- | unix/tclUnixInit.c | 6 | ||||
-rw-r--r-- | win/tclWinInit.c | 6 |
18 files changed, 281 insertions, 131 deletions
@@ -1,3 +1,26 @@ +2006-02-08 Don Porter <dgp@users.sourceforge.net> + + TIP#258 IMPLEMENTATION + + * doc/Encoding.3: New subcommand [encoding dirs]. + * doc/encoding.n: New routine Tcl_GetEncodingNameFromEnvironment. + * generic/tcl.decls: Made public: + * generic/tclBasic.c: TclGetEncodingFromObj + * generic/tclCmdAH.c: -> Tcl_GetEncodingFromObj + * generic/tclEncoding.c:TclGetEncodingSearchPath + * generic/tclInt.decls: -> Tcl_GetEncodingSearchPath + * generic/tclInt.h: TclSetEncodingSearchPath + * generic/tclTest.c: -> Tcl_SetEncodingSearchPath + * library/init.tcl: Removed commands: + * tests/cmdAH.test: [tcl::unsupported::EncodingDirs] + * tests/encoding.test: [testencoding path] (Tcltest) + * unix/tclUnixInit.c: [Patch 1413934]. + * win/tclWinInit.c: + + * generic/tclDecls.h: make genstubs + * generic/tclIntDecls.h: + * generic/tclStubInit.c: + 2006-02-01 Miguel Sofer <msofer@users.sf.net> * generic/tclProc.c: minor improvements to [apply] diff --git a/doc/Encoding.3 b/doc/Encoding.3 index c365aaf..efdc8ca 100644 --- a/doc/Encoding.3 +++ b/doc/Encoding.3 @@ -4,7 +4,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: Encoding.3,v 1.20 2004/10/07 15:15:37 dkf Exp $ +'\" RCS: @(#) $Id: Encoding.3,v 1.21 2006/02/08 21:41:27 dgp Exp $ '\" .so man.macros .TH Tcl_GetEncoding 3 "8.1" Tcl "Tcl Library Procedures" @@ -21,6 +21,11 @@ Tcl_Encoding void \fBTcl_FreeEncoding\fR(\fIencoding\fR) .sp +.VS 8.5 +int +\fBTcl_GetEncodingFromObj\fR(\fIinterp, objPtr, encodingPtr\fR) +.VE 8.5 +.sp char * \fBTcl_ExternalToUtfDString\fR(\fIencoding, src, srcLen, dstPtr\fR) .sp @@ -47,12 +52,25 @@ const char * int \fBTcl_SetSystemEncoding\fR(\fIinterp, name\fR) .sp +.VS 8.5 +const char * +\fBTcl_GetEncodingNameFromEnvironment\fR(\fIbufPtr\fR)in +.VE 8.5 +.sp void \fBTcl_GetEncodingNames\fR(\fIinterp\fR) .sp Tcl_Encoding \fBTcl_CreateEncoding\fR(\fItypePtr\fR) .sp +.VS 8.5 +Tcl_Obj * +\fBTcl_GetEncodingSearchPath\fR() +.sp +int +\fBTcl_SetEncodingSearchPath\fR(\fIsearchPath\fR) +.VE 8.5 +.sp const char * \fBTcl_GetDefaultEncodingDir\fR(\fIvoid\fR) .sp @@ -69,6 +87,14 @@ Name of encoding to load. .AP Tcl_Encoding encoding in The encoding to query, free, or use for converting text. If \fIencoding\fR is NULL, the current system encoding is used. +.AP Tcl_Obj *objPtr in +.VS 8.5 +Name of encoding to get token for. +.VE 8.5 +.AP Tcl_Encoding *encodingPtr out +.VS 8.5 +Points to storage where encoding token is to be written. +.VE 8.5 .AP "const char" *src in For the \fBTcl_ExternalToUtf\fR functions, an array of bytes in the specified encoding that are to be converted to UTF-8. For the @@ -121,8 +147,16 @@ buffer as a result of the conversion. May be NULL. .AP int *dstCharsPtr out Filled with the number of characters that correspond to the number of bytes stored in the output buffer. May be NULL. +.AP Tcl_DString *bufPtr out +.VS 8.5 +Storage for the prescribed system encoding name. +.VE 8.5 .AP Tcl_EncodingType *typePtr in Structure that defines a new type of encoding. +.AP Tcl_Obj *searchPath in +.VS 8.5 +List of filesystem directories in which to search for encoding data files. +.VE 8.5 .AP "const char" *path in A path to the location of the encoding file. .BE @@ -171,6 +205,25 @@ anywhere (i.e., it has been freed as many times as it has been gotten) \fBTcl_FreeEncoding\fR will release all storage the encoding was using and delete it from the database. .PP +.VS 8.5 +\fBTcl_GetEncodingFromObj\fR treats the string representation of \fIobjPtr\fR +as an encoding name, and finds an encoding with that name, just as +\fBTcl_GetEncoding\fR does. When an encoding is found, its \fBTcl_Encoding\fB +token is written to the storage pointed to by \fIencodingPtr\fR, and the value +\fBTCL_OK\fR is returned. In addition, a copy of the \fBTcl_Encoding\fR is +kept as the internal representation of \fIobjPtr\fR. If no such encoding is +found, the value \fBTCL_ERROR\fR is returned, and no writing to +\fI*encodingPtr\fR takes place. +.PP +The reference count of the \fBTcl_Encoding\fR token may be incremented twice, +once for the reference written to \fI*encodingPtr\fR and once for the +reference stored in \fIobjPtr\fR, if a reference is not already in place +there. The caller should call \fBTcl_FreeEncoding\fR on \fI*encodingPtr\fR +when the token will no longer be used. The usual mechanisms for freeing the +internal representation of a \fBTcl_Obj\fR will take care of calling +\fBTcl_FreeEncoding\fR on that reference at the appropriate time. +.VE 8.5 +.PP \fBTcl_ExternalToUtfDString\fR converts a source buffer \fIsrc\fR from the specified \fIencoding\fR into UTF-8. The converted bytes are stored in \fIdstPtr\fR, which is then null-terminated. The caller should eventually @@ -277,6 +330,15 @@ procedure increments the reference count of the new system encoding, decrements the reference count of the old system encoding, and returns \fBTCL_OK\fR. .PP +.VS 8.5 +\fBTcl_GetEncodingNameFromEnvironment\fR provides a means for the Tcl +library to report the encoding name it believes to be the correct one +to use as the system encoding, based on system calls and examination of +the environment suitable for the platform. It accepts \fIbufPtr\fR, +a pointer to an uninitialized or freed \fBTcl_DString\fR and writes +the encoding name to it. The \fBTcl_DStringValue\fR is returned. +.VE 8.5 +.PP \fBTcl_GetEncodingNames\fR sets the \fIinterp\fR result to a list consisting of the names of all the encodings that are currently defined or can be dynamically loaded, searching the encoding path specified by @@ -376,12 +438,34 @@ This \fIfreeProc\fR function is called when the encoding is deleted. The \fIclientData\fR parameter is the same as the \fIclientData\fR field specified to \fBTcl_CreateEncoding\fR when the encoding was created. .PP - +.VS 8.5 +\fBTcl_GetEncodingSearchPath\fR and \fBTcl_SetEncodingSearchPath\fR +are called to access and set the list of filesystem directories searched +for encoding data files. +.PP +The value returned by \fBTcl_GetEncodingSearchPath\fR +is the value stored by the last successful call to +\fBTcl_SetEncodingSearchPath\fR. If no calls to +\fBTcl_SetEncodingSearchPath\fR have occurred, Tcl will compute an initial +value based on the environment. There is one encoding search path for the +entire process, shared by all threads in the process. +.PP +\fBTcl_SetEncodingSearchPath\fR stores \fIsearchPath\fR and returns +\fBTCL_OK\fR, unless \fIsearchPath\fR is not a valid Tcl list, which +causes \fBTCL_ERROR\fR to be returned. The elements of \fIsearchPath\fR +are not verified as existing readable filesystem directories. When +searching for encoding data files takes place, and non-existent or +non-readable filesystem directories on the \fIsearchPath\fR are silently +ignored. +.PP \fBTcl_GetDefaultEncodingDir\fR and \fBTcl_SetDefaultEncodingDir\fR -access and set the directory to use when locating the default encoding -files. If this value is not NULL, the \fBTclpInitLibraryPath\fR routine -appends the path to the head of the search path, and uses this path as -the first place to look into when trying to locate the encoding file. +are obsolete interfaces best replaced with calls to +\fBTcl_GetEncodingSearchPath\fR and \fBTcl_SetEncodingSearchPath\fR. +They are called to access and set the first element of the \fIsearchPath\fR +list. Since Tcl searches \fIsearchPath\fR for encoding data files in +list order, these routines establish the ``default'' directory in which +to find encoding data files. +.VE 8.5 .SH "ENCODING FILES" Space would prohibit precompiling into Tcl every possible encoding diff --git a/doc/encoding.n b/doc/encoding.n index 36db314..69d6d21 100644 --- a/doc/encoding.n +++ b/doc/encoding.n @@ -4,7 +4,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: encoding.n,v 1.6 2004/10/27 14:24:37 dkf Exp $ +'\" RCS: @(#) $Id: encoding.n,v 1.7 2006/02/08 21:41:27 dgp Exp $ '\" .so man.macros .TH encoding n "8.1" Tcl "Tcl Built-In Commands" @@ -41,6 +41,21 @@ string. Each byte is stored in the lower 8-bits of a Unicode character. If \fIencoding\fR is not specified, the current system encoding is used. .TP +\fBencoding dirs\fR ?\fIdirectoryList\fR? +.VS 8.5 +Tcl can load encoding data files from the file system that describe +additional encodings for it to work with. This command +sets the search path for \fB*.enc\fR encoding data files to +the list of directories \fIdirectoryList\fR. If +\fIdirectoryList\fR is omitted then the command returns the +current list of directories that make up the search path. +If \fIdirectoryList\fR is present, but is not a valid Tcl +list, an error is raised. Any elements in \fIdirectoryList\fR +that are not in fact readable directories in the filesystem are ignored +without raising an error when searches for encoding data files +take place. +.VE 8.5 +.TP \fBencoding names\fR Returns a list containing the names of all of the encodings that are currently available. diff --git a/generic/tcl.decls b/generic/tcl.decls index 6fe33f1..e19db3f 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tcl.decls,v 1.119 2006/02/01 18:27:43 dgp Exp $ +# RCS: @(#) $Id: tcl.decls,v 1.120 2006/02/08 21:41:27 dgp Exp $ library tcl @@ -2049,6 +2049,22 @@ declare 568 generic { Tcl_Obj *handlerPtr) } +# TIP#258 Enhanced Interface for Encodings + +declare 569 generic { + int Tcl_GetEncodingFromObj(Tcl_Interp* interp, Tcl_Obj* objPtr, + Tcl_Encoding* encodingPtr) +} +declare 570 generic { + Tcl_Obj* Tcl_GetEncodingSearchPath(void) +} +declare 571 generic { + int Tcl_SetEncodingSearchPath(Tcl_Obj* searchPath) +} +declare 572 generic { + CONST char *Tcl_GetEncodingNameFromEnvironment(Tcl_DString* bufPtr) +} + ############################################################################## # Define the platform specific public Tcl interface. These functions are diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 42f07a6..6496fb3 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBasic.c,v 1.189 2006/02/01 19:26:01 dgp Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.190 2006/02/08 21:41:27 dgp Exp $ */ #include "tclInt.h" @@ -493,13 +493,6 @@ Tcl_CreateInterp(void) TclDefaultBgErrorHandlerObjCmd, (ClientData) NULL, NULL); /* - * Register the unsupported encoding search path command. - */ - - Tcl_CreateObjCommand(interp, "::tcl::unsupported::EncodingDirs", - TclEncodingDirsObjCmd, NULL, NULL); - - /* * Register the builtin math functions. */ diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 78ce150..ce50da4 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdAH.c,v 1.71 2005/12/08 20:20:34 hobbs Exp $ + * RCS: @(#) $Id: tclCmdAH.c,v 1.72 2006/02/08 21:41:27 dgp Exp $ */ #include "tclInt.h" @@ -24,6 +24,9 @@ static int CheckAccess(Tcl_Interp *interp, Tcl_Obj *pathPtr, int mode); +static int EncodingDirsObjCmd(ClientData dummy, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[]); static int GetStatBuf(Tcl_Interp *interp, Tcl_Obj *pathPtr, Tcl_FSStatProc *statProc, Tcl_StatBuf *statPtr); static char * GetTypeFromMode(int mode); @@ -427,11 +430,11 @@ Tcl_EncodingObjCmd(dummy, interp, objc, objv) int index; static CONST char *optionStrings[] = { - "convertfrom", "convertto", "names", "system", + "convertfrom", "convertto", "dirs", "names", "system", NULL }; enum options { - ENC_CONVERTFROM, ENC_CONVERTTO, ENC_NAMES, ENC_SYSTEM + ENC_CONVERTFROM, ENC_CONVERTTO, ENC_DIRS, ENC_NAMES, ENC_SYSTEM }; if (objc < 2) { @@ -456,7 +459,7 @@ Tcl_EncodingObjCmd(dummy, interp, objc, objv) encoding = Tcl_GetEncoding(interp, NULL); data = objv[2]; } else if (objc == 4) { - if (TclGetEncodingFromObj(interp, objv[2], &encoding) != TCL_OK) { + if (Tcl_GetEncodingFromObj(interp, objv[2], &encoding) != TCL_OK) { return TCL_ERROR; } data = objv[3]; @@ -497,6 +500,8 @@ Tcl_EncodingObjCmd(dummy, interp, objc, objv) Tcl_FreeEncoding(encoding); break; } + case ENC_DIRS: + return EncodingDirsObjCmd(dummy, interp, objc-1, objv+1); case ENC_NAMES: if (objc > 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); @@ -523,7 +528,7 @@ Tcl_EncodingObjCmd(dummy, interp, objc, objv) /* *---------------------------------------------------------------------- * - * TclEncodingDirsObjCmd -- + * EncodingDirsObjCmd -- * * This command manipulates the encoding search path. * @@ -537,7 +542,7 @@ Tcl_EncodingObjCmd(dummy, interp, objc, objv) */ int -TclEncodingDirsObjCmd(dummy, interp, objc, objv) +EncodingDirsObjCmd(dummy, interp, objc, objv) ClientData dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ @@ -548,10 +553,10 @@ TclEncodingDirsObjCmd(dummy, interp, objc, objv) return TCL_ERROR; } if (objc == 1) { - Tcl_SetObjResult(interp, TclGetEncodingSearchPath()); + Tcl_SetObjResult(interp, Tcl_GetEncodingSearchPath()); return TCL_OK; } - if (TclSetEncodingSearchPath(objv[1]) == TCL_ERROR) { + if (Tcl_SetEncodingSearchPath(objv[1]) == TCL_ERROR) { Tcl_AppendResult(interp, "expected directory list but got \"", Tcl_GetString(objv[1]), "\"", NULL); return TCL_ERROR; diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 236a28d..00f009f 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -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: tclDecls.h,v 1.121 2006/02/01 18:27:44 dgp Exp $ + * RCS: @(#) $Id: tclDecls.h,v 1.122 2006/02/08 21:41:27 dgp Exp $ */ #ifndef _TCLDECLS @@ -3547,6 +3547,30 @@ EXTERN int Tcl_SetNamespaceUnknownHandler _ANSI_ARGS_(( Tcl_Interp * interp, Tcl_Namespace * nsPtr, Tcl_Obj * handlerPtr)); #endif +#ifndef Tcl_GetEncodingFromObj_TCL_DECLARED +#define Tcl_GetEncodingFromObj_TCL_DECLARED +/* 569 */ +EXTERN int Tcl_GetEncodingFromObj _ANSI_ARGS_(( + Tcl_Interp* interp, Tcl_Obj* objPtr, + Tcl_Encoding* encodingPtr)); +#endif +#ifndef Tcl_GetEncodingSearchPath_TCL_DECLARED +#define Tcl_GetEncodingSearchPath_TCL_DECLARED +/* 570 */ +EXTERN Tcl_Obj* Tcl_GetEncodingSearchPath _ANSI_ARGS_((void)); +#endif +#ifndef Tcl_SetEncodingSearchPath_TCL_DECLARED +#define Tcl_SetEncodingSearchPath_TCL_DECLARED +/* 571 */ +EXTERN int Tcl_SetEncodingSearchPath _ANSI_ARGS_(( + Tcl_Obj* searchPath)); +#endif +#ifndef Tcl_GetEncodingNameFromEnvironment_TCL_DECLARED +#define Tcl_GetEncodingNameFromEnvironment_TCL_DECLARED +/* 572 */ +EXTERN CONST char * Tcl_GetEncodingNameFromEnvironment _ANSI_ARGS_(( + Tcl_DString* bufPtr)); +#endif typedef struct TclStubHooks { struct TclPlatStubs *tclPlatStubs; @@ -4157,6 +4181,10 @@ typedef struct TclStubs { int (*tcl_InitBignumFromDouble) _ANSI_ARGS_((Tcl_Interp* interp, double initval, mp_int * toInit)); /* 566 */ Tcl_Obj * (*tcl_GetNamespaceUnknownHandler) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Namespace * nsPtr)); /* 567 */ int (*tcl_SetNamespaceUnknownHandler) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Namespace * nsPtr, Tcl_Obj * handlerPtr)); /* 568 */ + int (*tcl_GetEncodingFromObj) _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj* objPtr, Tcl_Encoding* encodingPtr)); /* 569 */ + Tcl_Obj* (*tcl_GetEncodingSearchPath) _ANSI_ARGS_((void)); /* 570 */ + int (*tcl_SetEncodingSearchPath) _ANSI_ARGS_((Tcl_Obj* searchPath)); /* 571 */ + CONST char * (*tcl_GetEncodingNameFromEnvironment) _ANSI_ARGS_((Tcl_DString* bufPtr)); /* 572 */ } TclStubs; #ifdef __cplusplus @@ -6473,6 +6501,22 @@ extern TclStubs *tclStubsPtr; #define Tcl_SetNamespaceUnknownHandler \ (tclStubsPtr->tcl_SetNamespaceUnknownHandler) /* 568 */ #endif +#ifndef Tcl_GetEncodingFromObj +#define Tcl_GetEncodingFromObj \ + (tclStubsPtr->tcl_GetEncodingFromObj) /* 569 */ +#endif +#ifndef Tcl_GetEncodingSearchPath +#define Tcl_GetEncodingSearchPath \ + (tclStubsPtr->tcl_GetEncodingSearchPath) /* 570 */ +#endif +#ifndef Tcl_SetEncodingSearchPath +#define Tcl_SetEncodingSearchPath \ + (tclStubsPtr->tcl_SetEncodingSearchPath) /* 571 */ +#endif +#ifndef Tcl_GetEncodingNameFromEnvironment +#define Tcl_GetEncodingNameFromEnvironment \ + (tclStubsPtr->tcl_GetEncodingNameFromEnvironment) /* 572 */ +#endif #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */ diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 2d942c9..1e2e8fe 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.38 2005/10/18 15:01:56 dkf Exp $ + * RCS: @(#) $Id: tclEncoding.c,v 1.39 2006/02/08 21:41:27 dgp Exp $ */ #include "tclInt.h" @@ -274,7 +274,7 @@ static Tcl_ObjType EncodingType = { /* *---------------------------------------------------------------------- * - * TclGetEncodingFromObj -- + * Tcl_GetEncodingFromObj -- * * Writes to (*encodingPtr) the Tcl_Encoding value of (*objPtr), if * possible, and returns TCL_OK. If no such encoding exists, TCL_ERROR is @@ -291,7 +291,7 @@ static Tcl_ObjType EncodingType = { */ int -TclGetEncodingFromObj( +Tcl_GetEncodingFromObj( Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Encoding *encodingPtr) @@ -350,7 +350,7 @@ DupEncodingIntRep( /* *---------------------------------------------------------------------- * - * TclGetEncodingSearchPath -- + * Tcl_GetEncodingSearchPath -- * * Keeps the per-thread copy of the encoding search path current with * changes to the global copy. @@ -362,7 +362,7 @@ DupEncodingIntRep( */ Tcl_Obj * -TclGetEncodingSearchPath(void) +Tcl_GetEncodingSearchPath(void) { return TclGetProcessGlobalValue(&encodingSearchPath); } @@ -370,7 +370,7 @@ TclGetEncodingSearchPath(void) /* *---------------------------------------------------------------------- * - * TclSetEncodingSearchPath -- + * Tcl_SetEncodingSearchPath -- * * Keeps the per-thread copy of the encoding search path current with * changes to the global copy. @@ -379,7 +379,7 @@ TclGetEncodingSearchPath(void) */ int -TclSetEncodingSearchPath( +Tcl_SetEncodingSearchPath( Tcl_Obj *searchPath) { int dummy; @@ -470,7 +470,7 @@ FillEncodingFileMap(void) int i, numDirs = 0; Tcl_Obj *map, *searchPath; - searchPath = TclGetEncodingSearchPath(); + searchPath = Tcl_GetEncodingSearchPath(); Tcl_IncrRefCount(searchPath); Tcl_ListObjLength(NULL, searchPath, &numDirs); map = Tcl_NewDictObj(); @@ -643,7 +643,7 @@ CONST char * Tcl_GetDefaultEncodingDir(void) { int numDirs; - Tcl_Obj *first, *searchPath = TclGetEncodingSearchPath(); + Tcl_Obj *first, *searchPath = Tcl_GetEncodingSearchPath(); Tcl_ListObjLength(NULL, searchPath, &numDirs); if (numDirs == 0) { @@ -675,12 +675,12 @@ void Tcl_SetDefaultEncodingDir( CONST char *path) { - Tcl_Obj *searchPath = TclGetEncodingSearchPath(); + Tcl_Obj *searchPath = Tcl_GetEncodingSearchPath(); Tcl_Obj *directory = Tcl_NewStringObj(path, -1); searchPath = Tcl_DuplicateObj(searchPath); Tcl_ListObjReplace(NULL, searchPath, 0, 0, 1, &directory); - TclSetEncodingSearchPath(searchPath); + Tcl_SetEncodingSearchPath(searchPath); } /* @@ -1412,7 +1412,7 @@ OpenEncodingFileChannel( { Tcl_Obj *nameObj = Tcl_NewStringObj(name, -1); Tcl_Obj *fileNameObj = Tcl_DuplicateObj(nameObj); - Tcl_Obj *searchPath = Tcl_DuplicateObj(TclGetEncodingSearchPath()); + Tcl_Obj *searchPath = Tcl_DuplicateObj(Tcl_GetEncodingSearchPath()); Tcl_Obj *map = TclGetProcessGlobalValue(&encodingFileMap); Tcl_Obj **dir, *path, *directory = NULL; Tcl_Channel chan = NULL; @@ -3211,7 +3211,7 @@ unilen( * * This is the fallback routine that sets the default value of the * encoding search path if the application has not set one via a call to - * TclSetEncodingSearchPath() by the first time the search path is needed + * Tcl_SetEncodingSearchPath() by the first time the search path is needed * to load encoding data. * * The default encoding search path is produced by taking each directory diff --git a/generic/tclInt.decls b/generic/tclInt.decls index 02eeaf5..aef1260 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -12,7 +12,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tclInt.decls,v 1.94 2005/12/13 22:43:17 kennykb Exp $ +# RCS: @(#) $Id: tclInt.decls,v 1.95 2006/02/08 21:41:27 dgp Exp $ library tcl @@ -846,15 +846,16 @@ declare 208 generic { Tcl_Channel TclpOpenFileChannel (Tcl_Interp *interp, Tcl_Obj *pathPtr, int mode, int permissions) } -declare 209 generic { - Tcl_Obj * TclGetEncodingSearchPath(void) -} -declare 210 generic { - int TclSetEncodingSearchPath(Tcl_Obj *searchPath) -} -declare 211 generic { - CONST char * TclpGetEncodingNameFromEnvironment(Tcl_DString *bufPtr) -} +# Made public by TIP 258 +#declare 209 generic { +# Tcl_Obj * TclGetEncodingSearchPath(void) +#} +#declare 210 generic { +# int TclSetEncodingSearchPath(Tcl_Obj *searchPath) +#} +#declare 211 generic { +# CONST char * TclpGetEncodingNameFromEnvironment(Tcl_DString *bufPtr) +#} declare 212 generic { void TclpFindExecutable(CONST char *argv0) } diff --git a/generic/tclInt.h b/generic/tclInt.h index 64dbfec..69a44eb 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInt.h,v 1.267 2006/02/01 19:26:02 dgp Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.268 2006/02/08 21:41:27 dgp Exp $ */ #ifndef _TCLINT @@ -2066,8 +2066,6 @@ MODULE_SCOPE int TclFormatToErrorInfo(Tcl_Interp *interp, MODULE_SCOPE int TclFSFileAttrIndex(Tcl_Obj *pathPtr, CONST char *attributeName, int *indexPtr); MODULE_SCOPE Tcl_Obj * TclGetBgErrorHandler(Tcl_Interp *interp); -MODULE_SCOPE int TclGetEncodingFromObj(Tcl_Interp *interp, - Tcl_Obj *objPtr, Tcl_Encoding *encodingPtr); MODULE_SCOPE int TclGetNamespaceFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Namespace **nsPtrPtr); MODULE_SCOPE int TclGetNumberFromObj(Tcl_Interp *interp, @@ -2295,9 +2293,6 @@ MODULE_SCOPE int Tcl_DictObjCmd(ClientData clientData, MODULE_SCOPE int Tcl_EncodingObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -MODULE_SCOPE int TclEncodingDirsObjCmd( - ClientData clientData, Tcl_Interp *interp, - int objc, Tcl_Obj *CONST objv[]); MODULE_SCOPE int Tcl_EofObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h index 5df62d5..2eeaa4d 100644 --- a/generic/tclIntDecls.h +++ b/generic/tclIntDecls.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIntDecls.h,v 1.85 2005/12/13 22:43:18 kennykb Exp $ + * RCS: @(#) $Id: tclIntDecls.h,v 1.86 2006/02/08 21:41:27 dgp Exp $ */ #ifndef _TCLINTDECLS @@ -988,23 +988,9 @@ EXTERN int TclpObjAccess _ANSI_ARGS_((Tcl_Obj * pathPtr, EXTERN Tcl_Channel TclpOpenFileChannel _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * pathPtr, int mode, int permissions)); #endif -#ifndef TclGetEncodingSearchPath_TCL_DECLARED -#define TclGetEncodingSearchPath_TCL_DECLARED -/* 209 */ -EXTERN Tcl_Obj * TclGetEncodingSearchPath _ANSI_ARGS_((void)); -#endif -#ifndef TclSetEncodingSearchPath_TCL_DECLARED -#define TclSetEncodingSearchPath_TCL_DECLARED -/* 210 */ -EXTERN int TclSetEncodingSearchPath _ANSI_ARGS_(( - Tcl_Obj * searchPath)); -#endif -#ifndef TclpGetEncodingNameFromEnvironment_TCL_DECLARED -#define TclpGetEncodingNameFromEnvironment_TCL_DECLARED -/* 211 */ -EXTERN CONST char * TclpGetEncodingNameFromEnvironment _ANSI_ARGS_(( - Tcl_DString * bufPtr)); -#endif +/* Slot 209 is reserved */ +/* Slot 210 is reserved */ +/* Slot 211 is reserved */ #ifndef TclpFindExecutable_TCL_DECLARED #define TclpFindExecutable_TCL_DECLARED /* 212 */ @@ -1291,9 +1277,9 @@ typedef struct TclIntStubs { int (*tclpObjStat) _ANSI_ARGS_((Tcl_Obj * pathPtr, Tcl_StatBuf * buf)); /* 206 */ int (*tclpObjAccess) _ANSI_ARGS_((Tcl_Obj * pathPtr, int mode)); /* 207 */ Tcl_Channel (*tclpOpenFileChannel) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * pathPtr, int mode, int permissions)); /* 208 */ - Tcl_Obj * (*tclGetEncodingSearchPath) _ANSI_ARGS_((void)); /* 209 */ - int (*tclSetEncodingSearchPath) _ANSI_ARGS_((Tcl_Obj * searchPath)); /* 210 */ - CONST char * (*tclpGetEncodingNameFromEnvironment) _ANSI_ARGS_((Tcl_DString * bufPtr)); /* 211 */ + void *reserved209; + void *reserved210; + void *reserved211; void (*tclpFindExecutable) _ANSI_ARGS_((CONST char * argv0)); /* 212 */ Tcl_Obj * (*tclGetObjNameOfExecutable) _ANSI_ARGS_((void)); /* 213 */ void (*tclSetObjNameOfExecutable) _ANSI_ARGS_((Tcl_Obj * name, Tcl_Encoding encoding)); /* 214 */ @@ -1971,18 +1957,9 @@ extern TclIntStubs *tclIntStubsPtr; #define TclpOpenFileChannel \ (tclIntStubsPtr->tclpOpenFileChannel) /* 208 */ #endif -#ifndef TclGetEncodingSearchPath -#define TclGetEncodingSearchPath \ - (tclIntStubsPtr->tclGetEncodingSearchPath) /* 209 */ -#endif -#ifndef TclSetEncodingSearchPath -#define TclSetEncodingSearchPath \ - (tclIntStubsPtr->tclSetEncodingSearchPath) /* 210 */ -#endif -#ifndef TclpGetEncodingNameFromEnvironment -#define TclpGetEncodingNameFromEnvironment \ - (tclIntStubsPtr->tclpGetEncodingNameFromEnvironment) /* 211 */ -#endif +/* Slot 209 is reserved */ +/* Slot 210 is reserved */ +/* Slot 211 is reserved */ #ifndef TclpFindExecutable #define TclpFindExecutable \ (tclIntStubsPtr->tclpFindExecutable) /* 212 */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 7ccef4b..45b947f 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.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: tclStubInit.c,v 1.128 2006/02/01 18:27:48 dgp Exp $ + * RCS: @(#) $Id: tclStubInit.c,v 1.129 2006/02/08 21:41:27 dgp Exp $ */ #include "tclInt.h" @@ -300,9 +300,9 @@ TclIntStubs tclIntStubs = { TclpObjStat, /* 206 */ TclpObjAccess, /* 207 */ TclpOpenFileChannel, /* 208 */ - TclGetEncodingSearchPath, /* 209 */ - TclSetEncodingSearchPath, /* 210 */ - TclpGetEncodingNameFromEnvironment, /* 211 */ + NULL, /* 209 */ + NULL, /* 210 */ + NULL, /* 211 */ TclpFindExecutable, /* 212 */ TclGetObjNameOfExecutable, /* 213 */ TclSetObjNameOfExecutable, /* 214 */ @@ -1065,6 +1065,10 @@ TclStubs tclStubs = { Tcl_InitBignumFromDouble, /* 566 */ Tcl_GetNamespaceUnknownHandler, /* 567 */ Tcl_SetNamespaceUnknownHandler, /* 568 */ + Tcl_GetEncodingFromObj, /* 569 */ + Tcl_GetEncodingSearchPath, /* 570 */ + Tcl_SetEncodingSearchPath, /* 571 */ + Tcl_GetEncodingNameFromEnvironment, /* 572 */ }; /* !END!: Do not edit above this line. */ diff --git a/generic/tclTest.c b/generic/tclTest.c index db8d558..74d430a 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclTest.c,v 1.100 2005/12/15 04:08:33 das Exp $ + * RCS: @(#) $Id: tclTest.c,v 1.101 2006/02/08 21:41:27 dgp Exp $ */ #define TCL_TEST @@ -1736,11 +1736,10 @@ TestencodingObjCmd(dummy, interp, objc, objv) char *string; TclEncoding *encodingPtr; static CONST char *optionStrings[] = { - "create", "delete", "path", - NULL + "create", "delete", NULL }; enum options { - ENC_CREATE, ENC_DELETE, ENC_PATH + ENC_CREATE, ENC_DELETE }; if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, @@ -1787,14 +1786,6 @@ TestencodingObjCmd(dummy, interp, objc, objv) Tcl_FreeEncoding(encoding); break; } - case ENC_PATH: { - if (objc == 2) { - Tcl_SetObjResult(interp, TclGetEncodingSearchPath()); - } else { - TclSetEncodingSearchPath(objv[2]); - } - break; - } } return TCL_OK; } diff --git a/library/init.tcl b/library/init.tcl index 483e79e..c67a6e9 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -3,7 +3,7 @@ # Default system startup file for Tcl-based applications. Defines # "unknown" procedure and auto-load facilities. # -# RCS: @(#) $Id: init.tcl,v 1.84 2005/09/30 18:53:33 hobbs Exp $ +# RCS: @(#) $Id: init.tcl,v 1.85 2006/02/08 21:41:28 dgp Exp $ # # Copyright (c) 1991-1993 The Regents of the University of California. # Copyright (c) 1994-1996 Sun Microsystems, Inc. @@ -66,11 +66,13 @@ namespace eval tcl { } } - variable Path [unsupported::EncodingDirs] - set Dir [file join $::tcl_library encoding] - if {$Dir ni $Path} { - lappend Path $Dir - unsupported::EncodingDirs $Path + if {![interp issafe]} { + variable Path [encoding dirs] + set Dir [file join $::tcl_library encoding] + if {$Dir ni $Path} { + lappend Path $Dir + encoding dirs $Path + } } # Set up the 'chan' ensemble (TIP #208). diff --git a/tests/cmdAH.test b/tests/cmdAH.test index 25db252..95b9f5a 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: cmdAH.test,v 1.50 2004/11/01 16:58:37 kennykb Exp $ +# RCS: @(#) $Id: cmdAH.test,v 1.51 2006/02/08 21:41:28 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2.1 @@ -124,7 +124,7 @@ test cmdAH-4.1 {Tcl_EncodingObjCmd} { } {1 {wrong # args: should be "encoding option ?arg ...?"}} test cmdAH-4.2 {Tcl_EncodingObjCmd} { list [catch {encoding foo} msg] $msg -} {1 {bad option "foo": must be convertfrom, convertto, names, or system}} +} {1 {bad option "foo": must be convertfrom, convertto, dirs, names, or system}} test cmdAH-4.3 {Tcl_EncodingObjCmd} { list [catch {encoding convertto} msg] $msg } {1 {wrong # args: should be "encoding convertto ?encoding? data"}} diff --git a/tests/encoding.test b/tests/encoding.test index dc4fd8c..1de8880 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -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: encoding.test,v 1.23 2005/05/10 18:35:18 kennykb Exp $ +# RCS: @(#) $Id: encoding.test,v 1.24 2006/02/08 21:41:28 dgp Exp $ package require tcltest 2 namespace import -force ::tcltest::* @@ -56,14 +56,14 @@ test encoding-2.1 {Tcl_FreeEncoding: refcount == 0} { } {8C} test encoding-2.2 {Tcl_FreeEncoding: refcount != 0} {testencoding} { set system [encoding system] - set path [testencoding path] + set path [encoding dirs] encoding system shiftjis ;# incr ref count - testencoding path [list [pwd]] + encoding dirs [list [pwd]] set x [encoding convertto shiftjis \u4e4e] ;# old one found encoding system identity lappend x [catch {encoding convertto shiftjis \u4e4e} msg] $msg encoding system identity - testencoding path $path + encoding dirs $path encoding system $system set x } "\u008c\u00c1 1 {unknown encoding \"shiftjis\"}" @@ -88,20 +88,20 @@ test encoding-4.1 {Tcl_GetEncodingNames} {testencoding} { makeDirectory [file join tmp encoding] makeFile {} [file join tmp encoding junk.enc] makeFile {} [file join tmp encoding junk2.enc] - set path [testencoding path] - testencoding path {} + set path [encoding dirs] + encoding dirs {} catch {unset encodings} catch {unset x} foreach encoding [encoding names] { set encodings($encoding) 1 } - testencoding path [list [file join [pwd] encoding]] + encoding dirs [list [file join [pwd] encoding]] foreach encoding [encoding names] { if {![info exists encodings($encoding)]} { lappend x $encoding } } - testencoding path $path + encoding dirs $path cd [workingDirectory] removeFile [file join tmp encoding junk2.enc] removeFile [file join tmp encoding junk.enc] @@ -209,11 +209,11 @@ proc viewable {str} { test encoding-11.1 {LoadEncodingFile: unknown encoding} {testencoding} { set system [encoding system] - set path [testencoding path] + set path [encoding dirs] encoding system iso8859-1 - testencoding path {} + encoding dirs {} set x [list [catch {encoding convertto jis0208 \u4e4e} msg] $msg] - testencoding path $path + encoding dirs $path encoding system $system lappend x [encoding convertto jis0208 \u4e4e] } {1 {unknown encoding "jis0208"} 8C} @@ -234,10 +234,10 @@ test encoding-11.5.1 {LoadEncodingFile: escape file} { } [viewable "\x1b\$B8C\x1b(B"] test encoding-11.6 {LoadEncodingFile: invalid file} {testencoding} { set system [encoding system] - set path [testencoding path] + set path [encoding dirs] encoding system identity cd [temporaryDirectory] - testencoding path [file join tmp encoding] + encoding dirs [file join tmp encoding] makeDirectory tmp makeDirectory [file join tmp encoding] set f [open [file join tmp encoding splat.enc] w] @@ -249,7 +249,7 @@ test encoding-11.6 {LoadEncodingFile: invalid file} {testencoding} { removeDirectory [file join tmp encoding] removeDirectory tmp cd [workingDirectory] - testencoding path $path + encoding dirs $path encoding system $system set x } {1 {invalid encoding file "splat"}} diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 013f270..71bd1bb 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -7,7 +7,7 @@ * Copyright (c) 1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tclUnixInit.c,v 1.62 2006/01/25 22:57:53 dkf Exp $ + * RCS: @(#) $Id: tclUnixInit.c,v 1.63 2006/02/08 21:41:28 dgp Exp $ */ #include "tclInt.h" @@ -571,7 +571,7 @@ TclpSetInitialEncodings(void) { Tcl_DString encodingName; Tcl_SetSystemEncoding(NULL, - TclpGetEncodingNameFromEnvironment(&encodingName)); + Tcl_GetEncodingNameFromEnvironment(&encodingName)); Tcl_DStringFree(&encodingName); } @@ -605,7 +605,7 @@ SearchKnownEncodings( } CONST char * -TclpGetEncodingNameFromEnvironment( +Tcl_GetEncodingNameFromEnvironment( Tcl_DString *bufPtr) { CONST char *encoding; diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 4e87090..f85448c 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinInit.c,v 1.68 2005/11/04 00:06:50 dkf Exp $ + * RCS: @(#) $Id: tclWinInit.c,v 1.69 2006/02/08 21:41:28 dgp Exp $ */ #include "tclWinInt.h" @@ -450,7 +450,7 @@ TclpSetInitialEncodings(void) TclpSetInterfaces(); Tcl_SetSystemEncoding(NULL, - TclpGetEncodingNameFromEnvironment(&encodingName)); + Tcl_GetEncodingNameFromEnvironment(&encodingName)); Tcl_DStringFree(&encodingName); } @@ -466,7 +466,7 @@ TclpSetInterfaces(void) } CONST char * -TclpGetEncodingNameFromEnvironment( +Tcl_GetEncodingNameFromEnvironment( Tcl_DString *bufPtr) { Tcl_DStringInit(bufPtr); |