diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-06-27 09:53:04 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-06-27 09:53:04 (GMT) |
commit | ffbe67c65253a900b98f481ed64d4928f470adb9 (patch) | |
tree | cbefee17d73ae6aa5b48ee0bd65f8ed3162d8e46 | |
parent | d8238136ac782aaade9c86e8db5ce955a6f78937 (diff) | |
parent | a57835e07ae4443feed31888c2fdb0e44b2748e0 (diff) | |
download | tcl-ffbe67c65253a900b98f481ed64d4928f470adb9.zip tcl-ffbe67c65253a900b98f481ed64d4928f470adb9.tar.gz tcl-ffbe67c65253a900b98f481ed64d4928f470adb9.tar.bz2 |
merge trunk.
Remove Tcl_SetPanicProc from stub table; it is meant to be called by embedders, before the stub table is even initialized.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tcl.decls | 7 | ||||
-rw-r--r-- | generic/tcl.h | 3 | ||||
-rw-r--r-- | generic/tclCompExpr.c | 3 | ||||
-rw-r--r-- | generic/tclCompile.c | 11 | ||||
-rw-r--r-- | generic/tclConfig.c | 107 | ||||
-rw-r--r-- | generic/tclDecls.h | 10 | ||||
-rw-r--r-- | generic/tclEvent.c | 2 | ||||
-rw-r--r-- | generic/tclExecute.c | 2 | ||||
-rw-r--r-- | generic/tclMain.c | 3 | ||||
-rw-r--r-- | generic/tclOptimize.c | 3 | ||||
-rw-r--r-- | generic/tclPanic.c | 4 | ||||
-rw-r--r-- | generic/tclStubInit.c | 2 |
13 files changed, 90 insertions, 72 deletions
@@ -1,3 +1,8 @@ +2013-06-27 Jan Nijtmans <nijtmans@users.sf.net> + + * generic/tclConfig.c: Bug [9b2e636361]: Tcl_CreateInterp() needs initialized + * generic/tclMain.c: encodings. + 2013-06-18 Jan Nijtmans <nijtmans@users.sf.net> * generic/tclEvent.c: Bug [3611974]: InitSubsystems multiple thread issue. diff --git a/generic/tcl.decls b/generic/tcl.decls index 11f4516..734aae7 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -823,9 +823,10 @@ declare 228 { declare 229 { void Tcl_SetMaxBlockTime(const Tcl_Time *timePtr) } -declare 230 { - void Tcl_SetPanicProc(Tcl_PanicProc *panicProc) -} +# Removed (from stubtable only) in 9.0: +#declare 230 { +# void Tcl_SetPanicProc(Tcl_PanicProc *panicProc) +#} declare 231 { int Tcl_SetRecursionLimit(Tcl_Interp *interp, int depth) } diff --git a/generic/tcl.h b/generic/tcl.h index 6f597bd..f4e503c 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2220,8 +2220,9 @@ const char * TclTomMathInitializeStubs(Tcl_Interp *interp, */ #define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \ - (Tcl_FindExecutable(argv[0]), (Tcl_CreateInterp)())) + ((Tcl_CreateInterp)())) TCLAPI void Tcl_FindExecutable(const char *argv0); +TCLAPI void Tcl_SetPanicProc(Tcl_PanicProc *panicProc); TCLAPI void Tcl_MainEx(int argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); TCLAPI const char * Tcl_PkgInitStubsCheck(Tcl_Interp *interp, diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index d2c4dea..073afa3 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -2486,8 +2486,7 @@ CompileExprTree( break; } case OT_TOKENS: - TclCompileTokens(interp, tokenPtr+1, tokenPtr->numComponents, - envPtr); + CompileTokens(envPtr, tokenPtr, interp); tokenPtr += tokenPtr->numComponents + 1; break; default: diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 8cb53f5..633966e 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -1936,8 +1936,7 @@ TclCompileScript( * The word is not a simple string of characters. */ - TclCompileTokens(interp, tokenPtr+1, - tokenPtr->numComponents, envPtr); + CompileTokens(envPtr, tokenPtr, interp); if (expand && tokenPtr->type == TCL_TOKEN_EXPAND_WORD) { TclEmitInstInt4(INST_EXPAND_STKTOP, envPtr->currStackDepth, envPtr); @@ -2099,6 +2098,7 @@ TclCompileScript( * Emit an invoke instruction for the command. We skip this if a * compile procedure was found for the command. */ + assert(wordIdx > 0); if (expand) { /* @@ -2120,7 +2120,7 @@ TclCompileScript( TclEmitOpcode(INST_INVOKE_EXPANDED, envPtr); envPtr->expandCount--; TclAdjustStackDepth(1 - wordIdx, envPtr); - } else if (wordIdx > 0) { + } else { /* * Save PC -> command map for the TclArgumentBC* functions. */ @@ -2578,7 +2578,7 @@ TclCompileExprWords( wordPtr = tokenPtr; for (i = 0; i < numWords; i++) { - TclCompileTokens(interp, wordPtr+1, wordPtr->numComponents, envPtr); + CompileTokens(envPtr, wordPtr, interp); if (i < (numWords - 1)) { PushStringLiteral(envPtr, " "); } @@ -2630,8 +2630,7 @@ TclCompileNoOp( tokenPtr = tokenPtr + tokenPtr->numComponents + 1; if (tokenPtr->type != TCL_TOKEN_SIMPLE_WORD) { - TclCompileTokens(interp, tokenPtr+1, tokenPtr->numComponents, - envPtr); + CompileTokens(envPtr, tokenPtr, interp); TclEmitOpcode(INST_POP, envPtr); } } diff --git a/generic/tclConfig.c b/generic/tclConfig.c index ce36047..2b003c4 100644 --- a/generic/tclConfig.c +++ b/generic/tclConfig.c @@ -26,14 +26,15 @@ #define ASSOC_KEY "tclPackageAboutDict" /* - * A ClientData struct for the QueryConfig command. Store the two bits + * A ClientData struct for the QueryConfig command. Store the three bits * of data we need; the package name for which we store a config dict, - * and the (Tcl_Interp *) in which it is stored. + * the (Tcl_Interp *) in which it is stored, and the encoding. */ typedef struct { Tcl_Obj *pkg; Tcl_Interp *interp; + char *encoding; } QCCD; /* @@ -75,22 +76,28 @@ Tcl_RegisterConfig( const char *valEncoding) /* Name of the encoding used to store the * configuration values, ASCII, thus UTF-8. */ { + Tcl_Obj *pDB, *pkgDict; Tcl_DString cmdName; const Tcl_Config *cfg; - Tcl_Encoding venc = Tcl_GetEncoding(NULL, valEncoding); QCCD *cdPtr = ckalloc(sizeof(QCCD)); cdPtr->interp = interp; + if (valEncoding) { + cdPtr->encoding = ckalloc(strlen(valEncoding)+1); + strcpy(cdPtr->encoding, valEncoding); + } else { + cdPtr->encoding = NULL; + } cdPtr->pkg = Tcl_NewStringObj(pkgName, -1); /* * Phase I: Adding the provided information to the internal database of - * package meta data. Only if we have an ok encoding. + * package meta data. * * Phase II: Create a command for querying this database, specific to the - * package registerting its configuration. This is the approved interface + * package registering its configuration. This is the approved interface * in TIP 59. In the future a more general interface should be done, as - * followup to TIP 59. Simply because our database is now general across + * follow-up to TIP 59. Simply because our database is now general across * packages, and not a structure tied to one package. * * Note, the created command will have a reference through its clientdata. @@ -103,51 +110,35 @@ Tcl_RegisterConfig( * dictionaries visible at Tcl level. I.e. they are not filled */ - if (venc != NULL) { - Tcl_Obj *pkgDict, *pDB = GetConfigDict(interp); - - /* - * Retrieve package specific configuration... - */ - - if (Tcl_DictObjGet(interp, pDB, cdPtr->pkg, &pkgDict) != TCL_OK - || (pkgDict == NULL)) { - pkgDict = Tcl_NewDictObj(); - } else if (Tcl_IsShared(pkgDict)) { - pkgDict = Tcl_DuplicateObj(pkgDict); - } - - /* - * Extend the package configuration... - */ - - for (cfg=configuration ; cfg->key!=NULL && cfg->key[0]!='\0' ; cfg++) { - Tcl_DString conv; - const char *convValue = - Tcl_ExternalToUtfDString(venc, cfg->value, -1, &conv); + pDB = GetConfigDict(interp); - /* - * We know that the keys are in ASCII/UTF-8, so for them is no - * conversion required. - */ + /* + * Retrieve package specific configuration... + */ - Tcl_DictObjPut(interp, pkgDict, Tcl_NewStringObj(cfg->key, -1), - Tcl_NewStringObj(convValue, -1)); - Tcl_DStringFree(&conv); - } + if (Tcl_DictObjGet(interp, pDB, cdPtr->pkg, &pkgDict) != TCL_OK + || (pkgDict == NULL)) { + pkgDict = Tcl_NewDictObj(); + } else if (Tcl_IsShared(pkgDict)) { + pkgDict = Tcl_DuplicateObj(pkgDict); + } - /* - * We're now done with the encoding, so drop it. - */ + /* + * Extend the package configuration... + * We cannot assume that the encodings are initialized, therefore + * store the value as-is in a byte array. See Bug [9b2e636361]. + */ - Tcl_FreeEncoding(venc); + for (cfg=configuration ; cfg->key!=NULL && cfg->key[0]!='\0' ; cfg++) { + Tcl_DictObjPut(interp, pkgDict, Tcl_NewStringObj(cfg->key, -1), + Tcl_NewByteArrayObj((unsigned char *)cfg->value, strlen(cfg->value))); + } - /* - * Write the changes back into the overall database. - */ + /* + * Write the changes back into the overall database. + */ - Tcl_DictObjPut(interp, pDB, cdPtr->pkg, pkgDict); - } + Tcl_DictObjPut(interp, pDB, cdPtr->pkg, pkgDict); /* * Now create the interface command for retrieval of the package @@ -218,6 +209,9 @@ QueryConfigObjCmd( enum subcmds { CFG_GET, CFG_LIST }; + Tcl_DString conv; + Tcl_Encoding venc = NULL; + CONST char *value; if ((objc < 2) || (objc > 3)) { Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?arg?"); @@ -257,7 +251,21 @@ QueryConfigObjCmd( return TCL_ERROR; } - Tcl_SetObjResult(interp, val); + if (cdPtr->encoding) { + venc = Tcl_GetEncoding(interp, cdPtr->encoding); + if (!venc) { + return TCL_ERROR; + } + } + /* + * Value is stored as-is in a byte array, see Bug [9b2e636361], + * so we have to decode it first. + */ + value = (const char *) Tcl_GetByteArrayFromObj(val, &n); + value = Tcl_ExternalToUtfDString(venc, value, n, &conv); + Tcl_SetObjResult(interp, Tcl_NewStringObj(value, + Tcl_DStringLength(&conv))); + Tcl_DStringFree(&conv); return TCL_OK; case CFG_LIST: @@ -324,7 +332,10 @@ QueryConfigDelete( Tcl_DictObjRemove(NULL, pDB, pkgName); Tcl_DecrRefCount(pkgName); - ckfree(cdPtr); + if (cdPtr->encoding) { + ckfree((char *)cdPtr->encoding); + } + ckfree((char *)cdPtr); } /* @@ -366,7 +377,7 @@ GetConfigDict( * * This function is associated with the "Package About dict" assoc data * for an interpreter; it is invoked when the interpreter is deleted in - * order to free the information assoicated with any pending error + * order to free the information associated with any pending error * reports. * * Results: diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 581e889..e38f752 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -645,8 +645,7 @@ TCLAPI void Tcl_SetErrno(int err); TCLAPI void Tcl_SetErrorCode(Tcl_Interp *interp, ...); /* 229 */ TCLAPI void Tcl_SetMaxBlockTime(const Tcl_Time *timePtr); -/* 230 */ -TCLAPI void Tcl_SetPanicProc(Tcl_PanicProc *panicProc); +/* Slot 230 is reserved */ /* 231 */ TCLAPI int Tcl_SetRecursionLimit(Tcl_Interp *interp, int depth); /* 232 */ @@ -1992,7 +1991,7 @@ typedef struct TclStubs { void (*tcl_SetErrno) (int err); /* 227 */ void (*tcl_SetErrorCode) (Tcl_Interp *interp, ...); /* 228 */ void (*tcl_SetMaxBlockTime) (const Tcl_Time *timePtr); /* 229 */ - void (*tcl_SetPanicProc) (Tcl_PanicProc *panicProc); /* 230 */ + void (*reserved230)(void); int (*tcl_SetRecursionLimit) (Tcl_Interp *interp, int depth); /* 231 */ void (*tcl_SetResult) (Tcl_Interp *interp, char *result, Tcl_FreeProc *freeProc); /* 232 */ int (*tcl_SetServiceMode) (int mode); /* 233 */ @@ -2874,8 +2873,7 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_SetErrorCode) /* 228 */ #define Tcl_SetMaxBlockTime \ (tclStubsPtr->tcl_SetMaxBlockTime) /* 229 */ -#define Tcl_SetPanicProc \ - (tclStubsPtr->tcl_SetPanicProc) /* 230 */ +/* Slot 230 is reserved */ #define Tcl_SetRecursionLimit \ (tclStubsPtr->tcl_SetRecursionLimit) /* 231 */ #define Tcl_SetResult \ @@ -3666,14 +3664,12 @@ extern const TclStubs *tclStubsPtr; # undef Tcl_FindExecutable # undef Tcl_GetStringResult # undef Tcl_Init -# undef Tcl_SetPanicProc # undef Tcl_ObjSetVar2 # undef Tcl_StaticPackage # undef TclFSGetNativePath # define Tcl_CreateInterp() (tclStubsPtr->tcl_CreateInterp()) # define Tcl_GetStringResult(interp) (tclStubsPtr->tcl_GetStringResult(interp)) # define Tcl_Init(interp) (tclStubsPtr->tcl_Init(interp)) -# define Tcl_SetPanicProc(proc) (tclStubsPtr->tcl_SetPanicProc(proc)) # define Tcl_ObjSetVar2(interp, part1, part2, newValue, flags) \ (tclStubsPtr->tcl_ObjSetVar2(interp, part1, part2, newValue, flags)) #endif diff --git a/generic/tclEvent.c b/generic/tclEvent.c index 5b932e3..24bb96f 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -1171,8 +1171,6 @@ Tcl_Finalize(void) TclFinalizeEncodingSubsystem(); - Tcl_SetPanicProc(NULL); - /* * Repeat finalization of the thread local storage once more. Although * this step is already done by the Tcl_FinalizeThread call above, series diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 08e0bab..2b0053a 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -2679,7 +2679,7 @@ TEBCresume( */ auxObjList->length += objc - 1; - if ((objc > 1) && (auxObjList-length > 0)) { + if ((objc > 1) && (auxObjList->length > 0)) { length = auxObjList->length /* Total expansion room we need */ + codePtr->maxStackDepth /* Beyond the original max */ - CURR_DEPTH; /* Relative to where we are */ diff --git a/generic/tclMain.c b/generic/tclMain.c index 63e7464..875ccc3 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -317,6 +317,9 @@ Tcl_MainEx( Tcl_Channel chan; InteractiveState is; + TclpSetInitialEncodings(); + TclpFindExecutable((const char *)argv[0]); + Tcl_InitMemory(interp); is.interp = interp; diff --git a/generic/tclOptimize.c b/generic/tclOptimize.c index cd37a6a..b7f4173 100644 --- a/generic/tclOptimize.c +++ b/generic/tclOptimize.c @@ -212,7 +212,8 @@ ConvertZeroEffectToNOP( int blank = 0, i, nextInst; size = AddrLength(currentInstPtr); - while (*(currentInstPtr+size) == INST_NOP) { + while ((currentInstPtr + size < envPtr->codeNext) + && *(currentInstPtr+size) == INST_NOP) { if (IsTargetAddress(&targets, currentInstPtr + size)) { break; } diff --git a/generic/tclPanic.c b/generic/tclPanic.c index b87a8df..2a453b9 100644 --- a/generic/tclPanic.c +++ b/generic/tclPanic.c @@ -52,6 +52,10 @@ Tcl_SetPanicProc( #if defined(_WIN32) /* tclWinDebugPanic only installs if there is no panicProc yet. */ if ((proc != tclWinDebugPanic) || (panicProc == NULL)) +#elif defined(__CYGWIN__) + if (proc == NULL) + panicProc = tclWinDebugPanic; + else #endif panicProc = proc; } diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 53f14c4..5fb501a 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -954,7 +954,7 @@ const TclStubs tclStubs = { Tcl_SetErrno, /* 227 */ Tcl_SetErrorCode, /* 228 */ Tcl_SetMaxBlockTime, /* 229 */ - Tcl_SetPanicProc, /* 230 */ + 0, /* 230 */ Tcl_SetRecursionLimit, /* 231 */ Tcl_SetResult, /* 232 */ Tcl_SetServiceMode, /* 233 */ |