Attachment "1413934.patch" to
ticket [1413934fff]
added by
dgp
2006-02-09 04:29:54.
Index: doc/Encoding.3
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/Encoding.3,v
retrieving revision 1.20
diff -u -r1.20 Encoding.3
--- doc/Encoding.3 7 Oct 2004 15:15:37 -0000 1.20
+++ doc/Encoding.3 8 Feb 2006 21:25:31 -0000
@@ -21,6 +21,11 @@
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 @@
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 @@
.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 @@
.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 @@
\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 @@
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 @@
\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
Index: doc/encoding.n
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/encoding.n,v
retrieving revision 1.6
diff -u -r1.6 encoding.n
--- doc/encoding.n 27 Oct 2004 14:24:37 -0000 1.6
+++ doc/encoding.n 8 Feb 2006 21:25:31 -0000
@@ -41,6 +41,21 @@
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.
Index: generic/tcl.decls
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.decls,v
retrieving revision 1.119
diff -u -r1.119 tcl.decls
--- generic/tcl.decls 1 Feb 2006 18:27:43 -0000 1.119
+++ generic/tcl.decls 8 Feb 2006 21:25:32 -0000
@@ -2049,6 +2049,22 @@
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
Index: generic/tclBasic.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclBasic.c,v
retrieving revision 1.189
diff -u -r1.189 tclBasic.c
--- generic/tclBasic.c 1 Feb 2006 19:26:01 -0000 1.189
+++ generic/tclBasic.c 8 Feb 2006 21:25:34 -0000
@@ -493,13 +493,6 @@
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.
*/
Index: generic/tclCmdAH.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCmdAH.c,v
retrieving revision 1.71
diff -u -r1.71 tclCmdAH.c
--- generic/tclCmdAH.c 8 Dec 2005 20:20:34 -0000 1.71
+++ generic/tclCmdAH.c 8 Feb 2006 21:25:34 -0000
@@ -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 @@
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 @@
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_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 @@
/*
*----------------------------------------------------------------------
*
- * TclEncodingDirsObjCmd --
+ * EncodingDirsObjCmd --
*
* This command manipulates the encoding search path.
*
@@ -537,7 +542,7 @@
*/
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 @@
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;
Index: generic/tclDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclDecls.h,v
retrieving revision 1.121
diff -u -r1.121 tclDecls.h
--- generic/tclDecls.h 1 Feb 2006 18:27:44 -0000 1.121
+++ generic/tclDecls.h 8 Feb 2006 21:25:37 -0000
@@ -3547,6 +3547,30 @@
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 @@
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 @@
#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) */
Index: generic/tclEncoding.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclEncoding.c,v
retrieving revision 1.38
diff -u -r1.38 tclEncoding.c
--- generic/tclEncoding.c 18 Oct 2005 15:01:56 -0000 1.38
+++ generic/tclEncoding.c 8 Feb 2006 21:25:38 -0000
@@ -274,7 +274,7 @@
/*
*----------------------------------------------------------------------
*
- * 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 @@
*/
int
-TclGetEncodingFromObj(
+Tcl_GetEncodingFromObj(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
Tcl_Encoding *encodingPtr)
@@ -350,7 +350,7 @@
/*
*----------------------------------------------------------------------
*
- * TclGetEncodingSearchPath --
+ * Tcl_GetEncodingSearchPath --
*
* Keeps the per-thread copy of the encoding search path current with
* changes to the global copy.
@@ -362,7 +362,7 @@
*/
Tcl_Obj *
-TclGetEncodingSearchPath(void)
+Tcl_GetEncodingSearchPath(void)
{
return TclGetProcessGlobalValue(&encodingSearchPath);
}
@@ -370,7 +370,7 @@
/*
*----------------------------------------------------------------------
*
- * TclSetEncodingSearchPath --
+ * Tcl_SetEncodingSearchPath --
*
* Keeps the per-thread copy of the encoding search path current with
* changes to the global copy.
@@ -379,7 +379,7 @@
*/
int
-TclSetEncodingSearchPath(
+Tcl_SetEncodingSearchPath(
Tcl_Obj *searchPath)
{
int dummy;
@@ -470,7 +470,7 @@
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 @@
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 @@
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 @@
{
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 @@
*
* 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
Index: generic/tclInt.decls
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.decls,v
retrieving revision 1.94
diff -u -r1.94 tclInt.decls
--- generic/tclInt.decls 13 Dec 2005 22:43:17 -0000 1.94
+++ generic/tclInt.decls 8 Feb 2006 21:25:38 -0000
@@ -846,15 +846,16 @@
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)
}
Index: generic/tclInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
retrieving revision 1.267
diff -u -r1.267 tclInt.h
--- generic/tclInt.h 1 Feb 2006 19:26:02 -0000 1.267
+++ generic/tclInt.h 8 Feb 2006 21:25:39 -0000
@@ -2066,8 +2066,6 @@
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_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[]);
Index: generic/tclIntDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIntDecls.h,v
retrieving revision 1.85
diff -u -r1.85 tclIntDecls.h
--- generic/tclIntDecls.h 13 Dec 2005 22:43:18 -0000 1.85
+++ generic/tclIntDecls.h 8 Feb 2006 21:25:40 -0000
@@ -988,23 +988,9 @@
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 @@
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 @@
#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 */
Index: generic/tclStubInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStubInit.c,v
retrieving revision 1.128
diff -u -r1.128 tclStubInit.c
--- generic/tclStubInit.c 1 Feb 2006 18:27:48 -0000 1.128
+++ generic/tclStubInit.c 8 Feb 2006 21:25:41 -0000
@@ -300,9 +300,9 @@
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 @@
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. */
Index: generic/tclTest.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclTest.c,v
retrieving revision 1.100
diff -u -r1.100 tclTest.c
--- generic/tclTest.c 15 Dec 2005 04:08:33 -0000 1.100
+++ generic/tclTest.c 8 Feb 2006 21:25:43 -0000
@@ -1736,11 +1736,10 @@
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 @@
Tcl_FreeEncoding(encoding);
break;
}
- case ENC_PATH: {
- if (objc == 2) {
- Tcl_SetObjResult(interp, TclGetEncodingSearchPath());
- } else {
- TclSetEncodingSearchPath(objv[2]);
- }
- break;
- }
}
return TCL_OK;
}
Index: library/init.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/init.tcl,v
retrieving revision 1.84
diff -u -r1.84 init.tcl
--- library/init.tcl 30 Sep 2005 18:53:33 -0000 1.84
+++ library/init.tcl 8 Feb 2006 21:25:43 -0000
@@ -66,11 +66,13 @@
}
}
- 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).
Index: tests/cmdAH.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/cmdAH.test,v
retrieving revision 1.50
diff -u -r1.50 cmdAH.test
--- tests/cmdAH.test 1 Nov 2004 16:58:37 -0000 1.50
+++ tests/cmdAH.test 8 Feb 2006 21:25:50 -0000
@@ -124,7 +124,7 @@
} {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"}}
Index: tests/encoding.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/encoding.test,v
retrieving revision 1.23
diff -u -r1.23 encoding.test
--- tests/encoding.test 10 May 2005 18:35:18 -0000 1.23
+++ tests/encoding.test 8 Feb 2006 21:25:50 -0000
@@ -56,14 +56,14 @@
} {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 @@
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 @@
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 @@
} [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 @@
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"}}
Index: unix/tclUnixInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tclUnixInit.c,v
retrieving revision 1.62
diff -u -r1.62 tclUnixInit.c
--- unix/tclUnixInit.c 25 Jan 2006 22:57:53 -0000 1.62
+++ unix/tclUnixInit.c 8 Feb 2006 21:25:51 -0000
@@ -571,7 +571,7 @@
{
Tcl_DString encodingName;
Tcl_SetSystemEncoding(NULL,
- TclpGetEncodingNameFromEnvironment(&encodingName));
+ Tcl_GetEncodingNameFromEnvironment(&encodingName));
Tcl_DStringFree(&encodingName);
}
@@ -605,7 +605,7 @@
}
CONST char *
-TclpGetEncodingNameFromEnvironment(
+Tcl_GetEncodingNameFromEnvironment(
Tcl_DString *bufPtr)
{
CONST char *encoding;
Index: win/tclWinInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinInit.c,v
retrieving revision 1.68
diff -u -r1.68 tclWinInit.c
--- win/tclWinInit.c 4 Nov 2005 00:06:50 -0000 1.68
+++ win/tclWinInit.c 8 Feb 2006 21:25:52 -0000
@@ -450,7 +450,7 @@
TclpSetInterfaces();
Tcl_SetSystemEncoding(NULL,
- TclpGetEncodingNameFromEnvironment(&encodingName));
+ Tcl_GetEncodingNameFromEnvironment(&encodingName));
Tcl_DStringFree(&encodingName);
}
@@ -466,7 +466,7 @@
}
CONST char *
-TclpGetEncodingNameFromEnvironment(
+Tcl_GetEncodingNameFromEnvironment(
Tcl_DString *bufPtr)
{
Tcl_DStringInit(bufPtr);