diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-01-25 10:04:58 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-01-25 10:04:58 (GMT) |
commit | a8c158be4b6bd3dc3a0fc23faf26992246c8bcc4 (patch) | |
tree | 231d897e2ebe2880bb9a06d76226aa9808b7036b | |
parent | 6859fb45c25a8eb401e7d0decab9b77b24014627 (diff) | |
parent | f09de888df51736f6e35a190ee1eef87b39048cf (diff) | |
download | tcl-novem_unversioned_stub.zip tcl-novem_unversioned_stub.tar.gz tcl-novem_unversioned_stub.tar.bz2 |
merge novem. Some more fixes.novem_unversioned_stub
36 files changed, 269 insertions, 313 deletions
@@ -1,3 +1,11 @@ +2013-01-23 Donal K. Fellows <dkf@users.sf.net> + + * library/http/http.tcl (http::geturl): [Bug 2911139]: Do not do vwait + for connect to avoid reentrancy problems (except when operating + without a -command option). Internally, this means that all sockets + created by the http package will always be operated in asynchronous + mode. + 2013-01-18 Jan Nijtmans <nijtmans@users.sf.net> * generic/tclPort.h: [Bug 3598300]: unix: tcl.h does not include diff --git a/generic/tcl.decls b/generic/tcl.decls index 187f1d7..5a3c9ce 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -152,10 +152,11 @@ declare 35 { int Tcl_GetDoubleFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, double *doublePtr) } -declare 36 { - int Tcl_GetIndexFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, - const char *const *tablePtr, const char *msg, int flags, int *indexPtr) -} +# Removed in 9.0 +#declare 36 { +# int Tcl_GetIndexFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, +# const char *const *tablePtr, const char *msg, int flags, int *indexPtr) +#} declare 37 { int Tcl_GetInt(Tcl_Interp *interp, const char *src, int *intPtr) } diff --git a/generic/tcl.h b/generic/tcl.h index a500149..31eb193 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2202,20 +2202,16 @@ const char * Tcl_InitStubs(Tcl_Interp *interp, const char *version, const char * TclTomMathInitializeStubs(Tcl_Interp *interp, const char *version, int epoch, int revision); -/* - * When not using stubs, make it a macro. - */ - #ifdef USE_TCL_STUBS /* TODO: when merging to "novem", change != to == in the next line. */ #if TCL_RELEASE_LEVEL != TCL_FINAL_RELEASE # define Tcl_InitStubs(interp, version, exact) \ - (Tcl_InitStubs)((interp), (version), (exact)|(int)sizeof(int), \ - TCL_VERSION, TCL_STUB_MAGIC) + (Tcl_InitStubs)((interp), (version), (exact)|(int)sizeof(size_t), \ + TCL_VERSION, TCL_STUB_MAGIC) #else # define Tcl_InitStubs(interp, version, exact) \ - (Tcl_InitStubs)((interp), TCL_PATCH_LEVEL, 1|(int)sizeof(int), \ - TCL_VERSION, TCL_STUB_MAGIC) + (Tcl_InitStubs)(interp, TCL_PATCH_LEVEL, 1|(int)sizeof(size_t), \ + TCL_VERSION, TCL_STUB_MAGIC) #endif #else #define Tcl_InitStubs(interp, version, exact) \ diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 9b0b233..629319e 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2365,8 +2365,8 @@ BinaryDecodeHex( return TCL_ERROR; } for (i = 1; i < objc-1; ++i) { - if (Tcl_GetIndexFromObj(interp, objv[i], optStrings, "option", - TCL_EXACT, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], optStrings, + sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { return TCL_ERROR; } switch (index) { @@ -2485,8 +2485,8 @@ BinaryEncode64( return TCL_ERROR; } for (i = 1; i < objc-1; i += 2) { - if (Tcl_GetIndexFromObj(interp, objv[i], optStrings, "option", - TCL_EXACT, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], optStrings, + sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { return TCL_ERROR; } switch (index) { @@ -2579,8 +2579,8 @@ BinaryDecodeUu( return TCL_ERROR; } for (i = 1; i < objc-1; ++i) { - if (Tcl_GetIndexFromObj(interp, objv[i], optStrings, "option", - TCL_EXACT, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], optStrings, + sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { return TCL_ERROR; } switch (index) { @@ -2675,8 +2675,8 @@ BinaryDecode64( return TCL_ERROR; } for (i = 1; i < objc-1; ++i) { - if (Tcl_GetIndexFromObj(interp, objv[i], optStrings, "option", - TCL_EXACT, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], optStrings, + sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) { return TCL_ERROR; } switch (index) { diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c index 2268e45..ede0d67 100644 --- a/generic/tclCkalloc.c +++ b/generic/tclCkalloc.c @@ -156,6 +156,10 @@ TclInitDbCkalloc(void) if (!ckallocInit) { ckallocInit = 1; ckallocMutexPtr = Tcl_GetAllocMutex(); +#ifndef TCL_THREADS + /* Silence compiler warning */ + (void)ckallocMutexPtr; +#endif } } diff --git a/generic/tclClock.c b/generic/tclClock.c index 1257231..98ca02d 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -548,8 +548,8 @@ ClockGetjuliandayfromerayearmonthdayObjCmd( } dict = objv[1]; if (Tcl_DictObjGet(interp, dict, literals[LIT_ERA], &fieldPtr) != TCL_OK - || Tcl_GetIndexFromObj(interp, fieldPtr, eras, "era", TCL_EXACT, - &era) != TCL_OK + || Tcl_GetIndexFromObjStruct(interp, fieldPtr, eras, + sizeof(char *), "era", TCL_EXACT, &era) != TCL_OK || Tcl_DictObjGet(interp, dict, literals[LIT_YEAR], &fieldPtr) != TCL_OK || TclGetIntFromObj(interp, fieldPtr, &fields.year) != TCL_OK @@ -638,8 +638,8 @@ ClockGetjuliandayfromerayearweekdayObjCmd( } dict = objv[1]; if (Tcl_DictObjGet(interp, dict, literals[LIT_ERA], &fieldPtr) != TCL_OK - || Tcl_GetIndexFromObj(interp, fieldPtr, eras, "era", TCL_EXACT, - &era) != TCL_OK + || Tcl_GetIndexFromObjStruct(interp, fieldPtr, eras, + sizeof(char *), "era", TCL_EXACT, &era) != TCL_OK || Tcl_DictObjGet(interp, dict, literals[LIT_ISO8601YEAR], &fieldPtr) != TCL_OK || TclGetIntFromObj(interp, fieldPtr, &fields.iso8601Year)!=TCL_OK @@ -1697,8 +1697,8 @@ ClockClicksObjCmd( case 1: break; case 2: - if (Tcl_GetIndexFromObj(interp, objv[1], clicksSwitches, "switch", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], clicksSwitches, + sizeof(char *), "switch", 0, &index) != TCL_OK) { return TCL_ERROR; } break; @@ -1867,8 +1867,8 @@ ClockParseformatargsObjCmd( localeObj = litPtr[LIT_C]; timezoneObj = litPtr[LIT__NIL]; for (i = 2; i < objc; i+=2) { - if (Tcl_GetIndexFromObj(interp, objv[i], options, "switch", 0, - &optionIndex) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], options, + sizeof(char *), "switch", 0, &optionIndex) != TCL_OK) { Tcl_SetErrorCode(interp, "CLOCK", "badSwitch", Tcl_GetString(objv[i]), NULL); return TCL_ERROR; diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index fefe5a3..fd62ede 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -395,8 +395,8 @@ Tcl_EncodingObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, + sizeof(char *), "option", 0, &index) != TCL_OK) { return TCL_ERROR; } @@ -612,7 +612,7 @@ Tcl_EvalObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - return Tcl_NRCallObjProc(interp, TclNREvalObjCmd, dummy, objc, objv); + return Tcl_NRCallObjProc(interp, TclNREvalObjCmd, dummy, objc, objv); } int diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 5afe265..7fdab05 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -2962,8 +2962,8 @@ Tcl_LsearchObjCmd( } for (i = 1; i < objc-2; i++) { - if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", 0, &index) - != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], options, + sizeof(char *), "option", 0, &index) != TCL_OK) { if (startPtr != NULL) { Tcl_DecrRefCount(startPtr); } @@ -3691,8 +3691,8 @@ Tcl_LsortObjCmd( groupOffset = 0; indexPtr = NULL; for (i = 1; i < objc-1; i++) { - if (Tcl_GetIndexFromObj(interp, objv[i], switches, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], switches, + sizeof(char *), "option", 0, &index) != TCL_OK) { sortInfo.resultCode = TCL_ERROR; goto done2; } diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 95debf8..5b8f9ac 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -159,8 +159,8 @@ Tcl_RegexpObjCmd( if (name[0] != '-') { break; } - if (Tcl_GetIndexFromObj(interp, objv[i], options, "switch", TCL_EXACT, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], options, + sizeof(char *), "switch", TCL_EXACT, &index) != TCL_OK) { goto optionError; } switch ((enum options) index) { @@ -517,8 +517,8 @@ Tcl_RegsubObjCmd( if (name[0] != '-') { break; } - if (Tcl_GetIndexFromObj(interp, objv[idx], options, "switch", - TCL_EXACT, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[idx], options, + sizeof(char *), "switch", TCL_EXACT, &index) != TCL_OK) { goto optionError; } switch ((enum options) index) { @@ -1003,8 +1003,8 @@ TclNRSourceObjCmd( }; int index; - if (TCL_ERROR == Tcl_GetIndexFromObj(interp, objv[1], options, - "option", TCL_EXACT, &index)) { + if (TCL_ERROR == Tcl_GetIndexFromObjStruct(interp, objv[1], options, + sizeof(char *), "option", TCL_EXACT, &index)) { return TCL_ERROR; } encodingName = TclGetString(objv[2]); @@ -1485,8 +1485,8 @@ StringIsCmd( "class ?-strict? ?-failindex var? str"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], isClasses, "class", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], isClasses, + sizeof(char *), "class", 0, &index) != TCL_OK) { return TCL_ERROR; } @@ -1494,8 +1494,8 @@ StringIsCmd( for (i = 2; i < objc-1; i++) { int idx2; - if (Tcl_GetIndexFromObj(interp, objv[i], isOptions, "option", 0, - &idx2) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], isOptions, + sizeof(char *), "option", 0, &idx2) != TCL_OK) { return TCL_ERROR; } switch ((enum isOptions) idx2) { @@ -3388,8 +3388,8 @@ TclSubstOptions( for (i = 0; i < numOpts; i++) { int optionIndex; - if (Tcl_GetIndexFromObj(interp, opts[i], substOptions, "switch", 0, - &optionIndex) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, opts[i], substOptions, + sizeof(char *), "switch", 0, &optionIndex) != TCL_OK) { return TCL_ERROR; } switch (optionIndex) { @@ -3513,8 +3513,8 @@ TclNRSwitchObjCmd( if (TclGetString(objv[i])[0] != '-') { break; } - if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], options, + sizeof(char *), "option", 0, &index) != TCL_OK) { return TCL_ERROR; } switch ((enum options) index) { @@ -4190,8 +4190,8 @@ TclNRTryObjCmd( int type; Tcl_Obj *info[5]; - if (Tcl_GetIndexFromObj(interp, objv[i], handlerNames, "handler type", - 0, &type) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], handlerNames, + sizeof(char *), "handler type", 0, &type) != TCL_OK) { Tcl_DecrRefCount(handlersObj); return TCL_ERROR; } diff --git a/generic/tclConfig.c b/generic/tclConfig.c index fe99bbb..ce36047 100644 --- a/generic/tclConfig.c +++ b/generic/tclConfig.c @@ -223,8 +223,8 @@ QueryConfigObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?arg?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], subcmdStrings, "subcommand", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], subcmdStrings, + sizeof(char *), "subcommand", 0, &index) != TCL_OK) { return TCL_ERROR; } diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 472414c..35cdf9d 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -133,10 +133,7 @@ TCLAPI int Tcl_GetDouble(Tcl_Interp *interp, const char *src, /* 35 */ TCLAPI int Tcl_GetDoubleFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, double *doublePtr); -/* 36 */ -TCLAPI int Tcl_GetIndexFromObj(Tcl_Interp *interp, - Tcl_Obj *objPtr, const char *const *tablePtr, - const char *msg, int flags, int *indexPtr); +/* Slot 36 is reserved */ /* 37 */ TCLAPI int Tcl_GetInt(Tcl_Interp *interp, const char *src, int *intPtr); @@ -1823,7 +1820,7 @@ typedef struct TclStubs { unsigned char * (*tcl_GetByteArrayFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 33 */ int (*tcl_GetDouble) (Tcl_Interp *interp, const char *src, double *doublePtr); /* 34 */ int (*tcl_GetDoubleFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, double *doublePtr); /* 35 */ - int (*tcl_GetIndexFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, const char *const *tablePtr, const char *msg, int flags, int *indexPtr); /* 36 */ + void (*reserved36)(void); int (*tcl_GetInt) (Tcl_Interp *interp, const char *src, int *intPtr); /* 37 */ int (*tcl_GetIntFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *intPtr); /* 38 */ int (*tcl_GetLongFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, long *longPtr); /* 39 */ @@ -2526,8 +2523,7 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_GetDouble) /* 34 */ #define Tcl_GetDoubleFromObj \ (tclStubsPtr->tcl_GetDoubleFromObj) /* 35 */ -#define Tcl_GetIndexFromObj \ - (tclStubsPtr->tcl_GetIndexFromObj) /* 36 */ +/* Slot 36 is reserved */ #define Tcl_GetInt \ (tclStubsPtr->tcl_GetInt) /* 37 */ #define Tcl_GetIntFromObj \ @@ -3740,7 +3736,9 @@ TCLAPI void Tcl_MainExW(int argc, wchar_t **argv, Tcl_EvalEx((interp),(objPtr),-1,0) #define Tcl_GlobalEval(interp,objPtr) \ Tcl_EvalEx((interp),(objPtr),-1,TCL_EVAL_GLOBAL) - +#define Tcl_GetIndexFromObj(interp, objPtr, tablePtr, msg, flags, indexPtr) \ + Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, (int)sizeof(char *), \ + msg, flags, indexPtr) /* * Deprecated Tcl procedures: */ diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index 2bc5f81..e602c9f 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -621,7 +621,7 @@ SetDictFromAny( } for (i=0 ; i<objc ; i+=2) { - + /* Store key and value in the hash table we're building. */ hPtr = CreateChainEntry(dict, objv[i], &isNew); if (!isNew) { @@ -2913,8 +2913,8 @@ DictFilterCmd( Tcl_WrongNumArgs(interp, 1, objv, "dictionary filterType ?arg ...?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[2], filters, "filterType", - 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[2], filters, + sizeof(char *), "filterType", 0, &index) != TCL_OK) { return TCL_ERROR; } diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 88de9f3..821be3f 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -162,8 +162,8 @@ TclNamespaceEnsembleCmd( Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?arg ...?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], ensembleSubcommands, - "subcommand", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], ensembleSubcommands, + sizeof(char *), "subcommand", 0, &index) != TCL_OK) { return TCL_ERROR; } @@ -207,8 +207,8 @@ TclNamespaceEnsembleCmd( */ for (; objc>1 ; objc-=2,objv+=2) { - if (Tcl_GetIndexFromObj(interp, objv[0], ensembleCreateOptions, - "option", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[0], ensembleCreateOptions, + sizeof(char *), "option", 0, &index) != TCL_OK) { if (allocatedMapFlag) { Tcl_DecrRefCount(mapObj); } @@ -381,8 +381,8 @@ TclNamespaceEnsembleCmd( if (objc == 4) { Tcl_Obj *resultObj = NULL; /* silence gcc 4 warning */ - if (Tcl_GetIndexFromObj(interp, objv[3], ensembleConfigOptions, - "option", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[3], ensembleConfigOptions, + sizeof(char *), "option", 0, &index) != TCL_OK) { return TCL_ERROR; } switch ((enum EnsConfigOpts) index) { @@ -502,8 +502,8 @@ TclNamespaceEnsembleCmd( */ for (; objc>0 ; objc-=2,objv+=2) { - if (Tcl_GetIndexFromObj(interp, objv[0],ensembleConfigOptions, - "option", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[0],ensembleConfigOptions, + sizeof(char *), "option", 0, &index) != TCL_OK) { freeMapAndError: if (allocatedMapFlag) { Tcl_DecrRefCount(mapObj); diff --git a/generic/tclEvent.c b/generic/tclEvent.c index fb5e9c5..85100cb 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -891,7 +891,7 @@ Tcl_SetExitProc( *---------------------------------------------------------------------- */ static void -InvokeExitHandlers(void) +InvokeExitHandlers(void) { ExitHandler *exitPtr; @@ -967,22 +967,22 @@ Tcl_Exit( /* * Fast and deterministic exit (default behavior) */ - + InvokeExitHandlers(); - + /* * Ensure the thread-specific data is initialised as it is used in * Tcl_FinalizeThread() */ - + (void) TCL_TSD_INIT(&dataKey); - + /* * Now finalize the calling thread only (others are not safely * reachable). Among other things, this triggers a flush of the * Tcl_Channels that may have data enqueued. */ - + Tcl_FinalizeThread(); } TclpExit(status); @@ -1094,7 +1094,7 @@ Tcl_Finalize(void) * Invoke exit handlers first. */ - InvokeExitHandlers(); + InvokeExitHandlers(); TclpInitLock(); if (subsystemsInitialized == 0) { @@ -1498,8 +1498,8 @@ Tcl_UpdateObjCmd( if (objc == 1) { flags = TCL_ALL_EVENTS|TCL_DONT_WAIT; } else if (objc == 2) { - if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions, - "option", 0, &optionIndex) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], updateOptions, + sizeof(char *), "option", 0, &optionIndex) != TCL_OK) { return TCL_ERROR; } switch ((enum updateOptions) optionIndex) { diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 964f04f..00bd0ab 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -6956,7 +6956,6 @@ TEBCresume( pc += (opnd-1); PUSH_OBJECT(Tcl_NewStringObj(bytes, length)); goto instEvalStk; - NEXT_INST_F(9, 0, 0); } } diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c index 33c1496..036a82c 100644 --- a/generic/tclFCmd.c +++ b/generic/tclFCmd.c @@ -120,7 +120,7 @@ FileCopyRename( } i++; if ((objc - i) < 2) { - Tcl_WrongNumArgs(interp, 1, objv, + Tcl_WrongNumArgs(interp, 1, objv, "?-option value ...? source ?source ...? target"); return TCL_ERROR; } @@ -831,8 +831,8 @@ FileForceOption( if (TclGetString(objv[i])[0] != '-') { break; } - if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", TCL_EXACT, - &idx) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], options, + sizeof(char *), "option", TCL_EXACT, &idx) != TCL_OK) { return -1; } if (idx == 0 /* -force */) { @@ -1081,8 +1081,8 @@ TclFileAttrsCmd( goto end; } - if (Tcl_GetIndexFromObj(interp, objv[0], attributeStrings, - "option", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[0], attributeStrings, + sizeof(char *), "option", 0, &index) != TCL_OK) { goto end; } if (attributeStringsAllocated != NULL) { @@ -1109,8 +1109,8 @@ TclFileAttrsCmd( } for (i = 0; i < objc ; i += 2) { - if (Tcl_GetIndexFromObj(interp, objv[i], attributeStrings, - "option", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], attributeStrings, + sizeof(char *), "option", 0, &index) != TCL_OK) { goto end; } if (attributeStringsAllocated != NULL) { @@ -1199,8 +1199,8 @@ TclFileLinkCmd( static const char *const linkTypes[] = { "-symbolic", "-hard", NULL }; - if (Tcl_GetIndexFromObj(interp, objv[1], linkTypes, "switch", 0, - &linkAction) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], linkTypes, + sizeof(char *), "switch", 0, &linkAction) != TCL_OK) { return TCL_ERROR; } if (linkAction == 0) { diff --git a/generic/tclFileName.c b/generic/tclFileName.c index a519f0e..847a97a 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -1256,8 +1256,8 @@ Tcl_GlobObjCmd( dir = PATH_NONE; typePtr = NULL; for (i = 1; i < objc; i++) { - if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], options, + sizeof(char *), "option", 0, &index) != TCL_OK) { string = Tcl_GetStringFromObj(objv[i], &length); if (string[0] == '-') { /* diff --git a/generic/tclIO.c b/generic/tclIO.c index c9842df..0ba441a 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -398,11 +398,11 @@ TclFinalizeIOSubsystem(void) int active = 1; /* Flag == 1 while there's still work to do */ int doflushnb; - /* Fetch the pre-TIP#398 compatibility flag */ + /* Fetch the pre-TIP#398 compatibility flag */ { const char *s; Tcl_DString ds; - + s = TclGetEnv("TCL_FLUSH_NONBLOCKING_ON_EXIT", &ds); doflushnb = ((s != NULL) && strcmp(s, "0")); if (s != NULL) { @@ -454,9 +454,9 @@ TclFinalizeIOSubsystem(void) /* Set the channel back into blocking mode to ensure that we wait * for all data to flush out. */ - + (void) Tcl_SetChannelOption(NULL, (Tcl_Channel) chanPtr, - "-blocking", "on"); + "-blocking", "on"); } if ((chanPtr == (Channel *) tsdPtr->stdinChannel) || @@ -8860,8 +8860,8 @@ Tcl_FileEventObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "channelId event ?script?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[2], modeOptions, "event name", 0, - &modeIndex) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[2], modeOptions, + sizeof(char *), "event name", 0, &modeIndex) != TCL_OK) { return TCL_ERROR; } mask = maskArray[modeIndex]; diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index a4fa9a4..2ab634c 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -615,8 +615,8 @@ TclChanPushObjCmd( methods = 0; while (listc > 0) { - if (Tcl_GetIndexFromObj(interp, listv[listc-1], methodNames, - "method", TCL_EXACT, &methIndex) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, listv[listc-1], methodNames, + sizeof(char *), "method", TCL_EXACT, &methIndex) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "chan handler \"%s initialize\" returned %s", Tcl_GetString(cmdObj), @@ -943,7 +943,7 @@ ReflectClose( Tcl_EventuallyFree(rtPtr, (Tcl_FreeProc *) FreeReflectedTransform); return errorCode; - } + } #endif /* TCL_THREADS */ errorCodeSet = 1; goto cleanup; @@ -957,7 +957,7 @@ ReflectClose( Tcl_EventuallyFree(rtPtr, (Tcl_FreeProc *) FreeReflectedTransform); return errorCode; - } + } #endif /* TCL_THREADS */ errorCodeSet = 1; goto cleanup; diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index e0043f5..f325a74 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -2472,8 +2472,8 @@ TclFSFileAttrIndex( Tcl_Obj *tmpObj = Tcl_NewStringObj(attributeName, -1); int result; - result = Tcl_GetIndexFromObj(NULL, tmpObj, attrTable, NULL, TCL_EXACT, - indexPtr); + result = Tcl_GetIndexFromObjStruct(NULL, tmpObj, attrTable, + sizeof(char *), NULL, TCL_EXACT, indexPtr); TclDecrRefCount(tmpObj); if (listObj != NULL) { TclDecrRefCount(listObj); @@ -3357,7 +3357,7 @@ Tcl_LoadFile( return retVal; resolveSymbols: - /* + /* * At this point, *handlePtr is already set up to the handle for the * loaded library. We now try to resolve the symbols. */ @@ -3366,7 +3366,7 @@ Tcl_LoadFile( for (i=0 ; symbols[i] != NULL; i++) { procPtrs[i] = Tcl_FindSymbol(interp, *handlePtr, symbols[i]); if (procPtrs[i] == NULL) { - /* + /* * At least one symbol in the list was not found. Unload the * file, and report the problem back to the caller. * (Tcl_FindSymbol should already have left an appropriate @@ -3386,7 +3386,7 @@ Tcl_LoadFile( *---------------------------------------------------------------------- * * DivertFindSymbol -- - * + * * Find a symbol in a shared library loaded by copy-from-VFS. * *---------------------------------------------------------------------- diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index 7b85481..0a1f7de 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -69,74 +69,12 @@ typedef struct { * The following macros greatly simplify moving through a table... */ -#define STRING_AT(table, offset, index) \ - (*((const char *const *)(((char *)(table)) + ((offset) * (index))))) +#define STRING_AT(table, offset) \ + (*((const char *const *)(((char *)(table)) + (offset)))) #define NEXT_ENTRY(table, offset) \ - (&(STRING_AT(table, offset, 1))) + (&(STRING_AT(table, offset))) #define EXPAND_OF(indexRep) \ - STRING_AT((indexRep)->tablePtr, (indexRep)->offset, (indexRep)->index) - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetIndexFromObj -- - * - * This function looks up an object's value in a table of strings and - * returns the index of the matching string, if any. - * - * Results: - * If the value of objPtr is identical to or a unique abbreviation for - * one of the entries in tablePtr, then the return value is TCL_OK and the - * index of the matching entry is stored at *indexPtr. If there isn't a - * proper match, then TCL_ERROR is returned and an error message is left - * in interp's result (unless interp is NULL). The msg argument is used - * in the error message; for example, if msg has the value "option" then - * the error message will say something flag 'bad option "foo": must be - * ...' - * - * Side effects: - * The result of the lookup is cached as the internal rep of objPtr, so - * that repeated lookups can be done quickly. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetIndexFromObj( - Tcl_Interp *interp, /* Used for error reporting if not NULL. */ - Tcl_Obj *objPtr, /* Object containing the string to lookup. */ - const char *const*tablePtr, /* Array of strings to compare against the - * value of objPtr; last entry must be NULL - * and there must not be duplicate entries. */ - const char *msg, /* Identifying word to use in error - * messages. */ - int flags, /* 0 or TCL_EXACT */ - int *indexPtr) /* Place to store resulting integer index. */ -{ - - /* - * See if there is a valid cached result from a previous lookup (doing the - * check here saves the overhead of calling Tcl_GetIndexFromObjStruct in - * the common case where the result is cached). - */ - - if (objPtr->typePtr == &indexType) { - IndexRep *indexRep = objPtr->internalRep.otherValuePtr; - - /* - * Here's hoping we don't get hit by unfortunate packing constraints - * on odd platforms like a Cray PVP... - */ - - if (indexRep->tablePtr == (void *) tablePtr - && indexRep->offset == sizeof(char *)) { - *indexPtr = indexRep->index; - return TCL_OK; - } - } - return Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, sizeof(char *), - msg, flags, indexPtr); -} + STRING_AT((indexRep)->tablePtr, (indexRep)->offset*(indexRep)->index) /* *---------------------------------------------------------------------- @@ -238,7 +176,7 @@ GetIndexFromObjList( * a proper match, then TCL_ERROR is returned and an error message is * left in interp's result (unless interp is NULL). The msg argument is * used in the error message; for example, if msg has the value "option" - * then the error message will say something flag 'bad option "foo": must + * then the error message will say something like 'bad option "foo": must * be ...' * * Side effects: @@ -270,6 +208,10 @@ Tcl_GetIndexFromObjStruct( Tcl_Obj *resultPtr; IndexRep *indexRep; + /* Protect against invalid values, like -1 or 0. */ + if (offset < (int)sizeof(char *)) { + offset = (int)sizeof(char *); + } /* * See if there is a valid cached result from a previous lookup. */ @@ -587,8 +529,8 @@ PrefixMatchObjCmd( } for (i = 1; i < (objc - 2); i++) { - if (Tcl_GetIndexFromObj(interp, objv[i], matchOptions, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], matchOptions, + sizeof(char *), "option", 0, &index) != TCL_OK) { return TCL_ERROR; } switch ((enum matchOptions) index) { @@ -1460,8 +1402,8 @@ TclGetCompletionCodeFromObj( && TclGetIntFromObj(NULL, value, codePtr) == TCL_OK) { return TCL_OK; } - if (Tcl_GetIndexFromObj(NULL, value, returnCodes, NULL, TCL_EXACT, - codePtr) == TCL_OK) { + if (Tcl_GetIndexFromObjStruct(NULL, value, returnCodes, + sizeof(char *), NULL, TCL_EXACT, codePtr) == TCL_OK) { return TCL_OK; } diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 03e34bd..0e84dbf 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -343,7 +343,7 @@ Tcl_PushCallFrame( framePtr->clientData = NULL; framePtr->localCachePtr = NULL; framePtr->tailcallPtr = NULL; - + /* * Push the new call frame onto the interpreter's stack of procedure call * frames making it the current frame. @@ -3025,7 +3025,7 @@ NamespaceCodeCmd( */ arg = TclGetStringFromObj(objv[1], &length); - if (*arg==':' && length > 20 + if (*arg==':' && length > 20 && strncmp(arg, "::namespace inscope ", 20) == 0) { Tcl_SetObjResult(interp, objv[1]); return TCL_OK; @@ -4570,8 +4570,8 @@ NamespaceWhichCmd( * Look for a flag controlling the lookup. */ - if (Tcl_GetIndexFromObj(interp, objv[1], opts, "option", 0, - &lookupType) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], opts, + sizeof(char *), "option", 0, &lookupType) != TCL_OK) { /* * Preserve old style of error message! */ @@ -4918,7 +4918,7 @@ TclLogCommandInfo( if (Tcl_IsShared(iPtr->errorStack)) { Tcl_Obj *newObj; - + newObj = Tcl_DuplicateObj(iPtr->errorStack); Tcl_DecrRefCount(iPtr->errorStack); Tcl_IncrRefCount(newObj); @@ -4950,7 +4950,7 @@ TclLogCommandInfo( Tcl_ListObjAppendElement(NULL, iPtr->errorStack, Tcl_NewStringObj(command, length)); } - } + } if (!iPtr->framePtr->objc) { /* @@ -5003,7 +5003,7 @@ TclErrorStackResetIf( if (Tcl_IsShared(iPtr->errorStack)) { Tcl_Obj *newObj; - + newObj = Tcl_DuplicateObj(iPtr->errorStack); Tcl_DecrRefCount(iPtr->errorStack); Tcl_IncrRefCount(newObj); @@ -5023,7 +5023,7 @@ TclErrorStackResetIf( Tcl_ListObjAppendElement(NULL, iPtr->errorStack, iPtr->innerLiteral); Tcl_ListObjAppendElement(NULL, iPtr->errorStack, Tcl_NewStringObj(msg, length)); - } + } } /* diff --git a/generic/tclOOBasic.c b/generic/tclOOBasic.c index 0676618..a2a72e7 100644 --- a/generic/tclOOBasic.c +++ b/generic/tclOOBasic.c @@ -979,8 +979,8 @@ TclOOSelfObjCmd( return TCL_ERROR; } else if (objc == 1) { index = SELF_OBJECT; - } else if (Tcl_GetIndexFromObj(interp, objv[1], subcmds, "subcommand", 0, - &index) != TCL_OK) { + } else if (Tcl_GetIndexFromObjStruct(interp, objv[1], subcmds, + sizeof(char *), "subcommand", 0, &index) != TCL_OK) { return TCL_ERROR; } diff --git a/generic/tclProc.c b/generic/tclProc.c index 933e7d2..8630359 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -2881,7 +2881,8 @@ Tcl_DisassembleObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "type ..."); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], types, "type", 0, &idx)!=TCL_OK){ + if (Tcl_GetIndexFromObjStruct(interp, objv[1], types, + sizeof(char *), "type", 0, &idx) != TCL_OK){ return TCL_ERROR; } diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 680f634..da25ce0 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -690,7 +690,7 @@ const TclStubs tclStubs = { Tcl_GetByteArrayFromObj, /* 33 */ Tcl_GetDouble, /* 34 */ Tcl_GetDoubleFromObj, /* 35 */ - Tcl_GetIndexFromObj, /* 36 */ + 0, /* 36 */ Tcl_GetInt, /* 37 */ Tcl_GetIntFromObj, /* 38 */ Tcl_GetLongFromObj, /* 39 */ diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c index 42b4911..6c89562 100644 --- a/generic/tclStubLib.c +++ b/generic/tclStubLib.c @@ -82,62 +82,68 @@ Tcl_InitStubs( return NULL; } - actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 0, &pkgData); - if (actualVersion == NULL) { - return NULL; - } - if (exact&1) { - const char *p = version; - int count = 0; - - while (*p) { - count += !ISDIGIT(*p++); + if(iPtr->errorLine == TCL_STUB_MAGIC) { + actualVersion = (const char *)iPtr->objResultPtr; + tclStubsPtr = stubsPtr; + } else { + actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 0, &pkgData); + if (actualVersion == NULL) { + return NULL; } - if (count == 1) { - const char *q = actualVersion; + if (exact&1) { + const char *p = version; + int count = 0; - p = version; - while (*p && (*p == *q)) { - p++; q++; + while (*p) { + count += !ISDIGIT(*p++); } - if (*p || ISDIGIT(*q)) { - /* Construct error message */ - stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL); - return NULL; - } - } else { - actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL); - if (actualVersion == NULL) { - return NULL; + if (count == 1) { + const char *q = actualVersion; + + p = version; + while (*p && (*p == *q)) { + p++; q++; + } + if (*p || ISDIGIT(*q)) { + /* Construct error message */ + stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL); + return NULL; + } + } else { + actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 1, NULL); + if (actualVersion == NULL) { + return NULL; + } } } - } #define MASK (4+8+16) /* possible values of sizeof(size_t) */ - /* reserved77 is the location of Tcl_Backslash, which was removed - * in Tcl 9.0. If this value is NULL, we know that we have Tcl > 8 - */ - if ((exact & MASK) != (int) - ((stubsPtr->reserved77)?sizeof(int):sizeof(size_t))) { - char msg[32], *p = msg; - if (stubsPtr->reserved77) { - /* Take "version", but strip off everything after '-' */ - while (*version && *version != '-') { - *p++ = *version++; + /* We are running Tcl 8. */ + if ((exact & MASK) != (int)sizeof(int)) { + char msg[32], *p = msg; + + /* Take "version", but strip off everything after '-' */ + while (*version && *version != '-') { + *p++ = *version++; + } + *p = '\0'; + stubsPtr->tcl_AppendResult(interp, "incompatible stub library: have ", + tclversion, ", need ", msg, NULL); + return NULL; } - *p = '\0'; - + tclStubsPtr = (TclStubs *)pkgData; } else { - msg[0] = '9'; - msg[1] = '\0'; + /* We are running Tcl 9. */ + if ((exact & MASK) != (int)sizeof(size_t)) { + stubsPtr->tcl_AppendResult(interp, "incompatible stub library: have ", + tclversion, ", need 9", NULL); + return NULL; + } + tclStubsPtr = stubsPtr; } - stubsPtr->tcl_AppendResult(interp, "incompatible stub library: have ", - tclversion, ", need ", msg); - return NULL; } - tclStubsPtr = (TclStubs *)pkgData; if (tclStubsPtr->hooks) { tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs; diff --git a/generic/tclTest.c b/generic/tclTest.c index 48b1dbb..e07c5c1 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -680,8 +680,8 @@ Tcltest_Init( if (Tcl_ListObjGetElements(interp, listPtr, &objc, &objv) != TCL_OK) { return TCL_ERROR; } - if (objc && (Tcl_GetIndexFromObj(NULL, objv[0], specialOptions, NULL, - TCL_EXACT, &index) == TCL_OK)) { + if (objc && (Tcl_GetIndexFromObjStruct(NULL, objv[0], specialOptions, + sizeof(char *), NULL, TCL_EXACT, &index) == TCL_OK)) { switch (index) { case 0: return TCL_ERROR; @@ -885,7 +885,7 @@ TestasyncCmd( static int AsyncHandlerProc( - ClientData clientData, /* If of TestAsyncHandler structure. + ClientData clientData, /* If of TestAsyncHandler structure. * in global list. */ Tcl_Interp *interp, /* Interpreter in which command was * executed, or NULL. */ @@ -1693,8 +1693,8 @@ TestdoubledigitsObjCmd(ClientData unused, } if (status != TCL_OK || Tcl_GetIntFromObj(interp, objv[2], &ndigits) != TCL_OK - || Tcl_GetIndexFromObj(interp, objv[3], options, "conversion type", - TCL_EXACT, &type) != TCL_OK) { + || Tcl_GetIndexFromObjStruct(interp, objv[3], options, + sizeof(char *), "conversion type", TCL_EXACT, &type) != TCL_OK) { fprintf(stderr, "bad value? %g\n", d); return TCL_ERROR; } @@ -1880,8 +1880,8 @@ TestencodingObjCmd( ENC_CREATE, ENC_DELETE }; - if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, + sizeof(char *), "option", 0, &index) != TCL_OK) { return TCL_ERROR; } @@ -2140,8 +2140,8 @@ TesteventObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?arg ...?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], subcommands, "subcommand", - TCL_EXACT, &subCmdIndex) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], subcommands, + sizeof(char *), "subcommand", TCL_EXACT, &subCmdIndex) != TCL_OK) { return TCL_ERROR; } switch (subCmdIndex) { @@ -2150,8 +2150,8 @@ TesteventObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "name position script"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[3], positions, - "position specifier", TCL_EXACT, &posIndex) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[3], positions, + sizeof(char *), "position specifier", TCL_EXACT, &posIndex) != TCL_OK) { return TCL_ERROR; } ev = ckalloc(sizeof(TestEvent)); @@ -3254,8 +3254,8 @@ TestlocaleCmd( return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, + sizeof(char *), "option", 0, &index) != TCL_OK) { return TCL_ERROR; } @@ -3662,8 +3662,8 @@ TestregexpObjCmd( if (name[0] != '-') { break; } - if (Tcl_GetIndexFromObj(interp, objv[i], options, "switch", TCL_EXACT, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[i], options, + sizeof(char *), "switch", TCL_EXACT, &index) != TCL_OK) { return TCL_ERROR; } switch ((enum options) index) { @@ -4880,8 +4880,8 @@ TestsaveresultCmd( Tcl_WrongNumArgs(interp, 1, objv, "type script discard"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, + sizeof(char *), "option", 0, &index) != TCL_OK) { return TCL_ERROR; } if (Tcl_GetBooleanFromObj(interp, objv[3], &discard) != TCL_OK) { @@ -7158,8 +7158,8 @@ TestInterpResolverCmd( Tcl_WrongNumArgs(interp, 1, objv, "up|down"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], table, "operation", TCL_EXACT, - &idx) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], table, + sizeof(char *), "operation", TCL_EXACT, &idx) != TCL_OK) { return TCL_ERROR; } switch (idx) { diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c index e61f809..bc1834f 100644 --- a/generic/tclTestObj.c +++ b/generic/tclTestObj.c @@ -172,8 +172,8 @@ TestbignumobjCmd( Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], subcmds, "option", 0, - &index) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], subcmds, + sizeof(char *), "option", 0, &index) != TCL_OK) { return TCL_ERROR; } string = Tcl_GetString(objv[2]); @@ -554,11 +554,12 @@ TestindexobjCmd( return TCL_ERROR; } - Tcl_GetIndexFromObj(NULL, objv[1], tablePtr, "token", 0, &index); + Tcl_GetIndexFromObjStruct(NULL, objv[1], tablePtr, + sizeof(char *), "token", 0, &index); indexRep = objv[1]->internalRep.otherValuePtr; indexRep->index = index2; - result = Tcl_GetIndexFromObj(NULL, objv[1], - tablePtr, "token", 0, &index); + result = Tcl_GetIndexFromObjStruct(NULL, objv[1], + tablePtr, sizeof(char *), "token", 0, &index); if (result == TCL_OK) { Tcl_SetIntObj(Tcl_GetObjResult(interp), index); } @@ -598,8 +599,8 @@ TestindexobjCmd( } } - result = Tcl_GetIndexFromObj((setError? interp : NULL), objv[3], - argv, "token", (allowAbbrev? 0 : TCL_EXACT), &index); + result = Tcl_GetIndexFromObjStruct((setError? interp : NULL), objv[3], + argv, sizeof(char *), "token", (allowAbbrev? 0 : TCL_EXACT), &index); ckfree(argv); if (result == TCL_OK) { Tcl_SetIntObj(Tcl_GetObjResult(interp), index); @@ -864,8 +865,8 @@ TestlistobjCmd( if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) { return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], subcommands, "command", - 0, &cmdIndex) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], subcommands, + sizeof(char *), "command", 0, &cmdIndex) != TCL_OK) { return TCL_ERROR; } switch(cmdIndex) { @@ -1161,8 +1162,8 @@ TeststringobjCmd( return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], options, "option", 0, &option) - != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], options, + sizeof(char *), "option", 0, &option) != TCL_OK) { return TCL_ERROR; } switch (option) { diff --git a/generic/tclTimer.c b/generic/tclTimer.c index 735c54a..c5f11c9 100644 --- a/generic/tclTimer.c +++ b/generic/tclTimer.c @@ -823,8 +823,8 @@ Tcl_AfterObjCmd( || objv[1]->typePtr == &tclWideIntType #endif || objv[1]->typePtr == &tclBignumType - || (Tcl_GetIndexFromObj(NULL, objv[1], afterSubCmds, "", 0, - &index) != TCL_OK)) { + || (Tcl_GetIndexFromObjStruct(NULL, objv[1], afterSubCmds, + sizeof(char *), "", 0, &index) != TCL_OK)) { index = -1; if (Tcl_GetWideIntFromObj(NULL, objv[1], &ms) != TCL_OK) { const char *arg = Tcl_GetString(objv[1]); diff --git a/generic/tclVar.c b/generic/tclVar.c index 22f6fb8..3c5ee15 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -2106,7 +2106,7 @@ TclPtrIncrObjVar( if (Tcl_IsShared(varValuePtr)) { /* Copy on write */ varValuePtr = Tcl_DuplicateObj(varValuePtr); - + if (TCL_OK == TclIncrObj(interp, varValuePtr, incrPtr)) { return TclPtrSetVar(interp, varPtr, arrayPtr, part1Ptr, part2Ptr, varValuePtr, flags, index); @@ -3729,8 +3729,8 @@ ArrayNamesCmd( * Finish parsing the arguments. */ - if ((objc == 4) && Tcl_GetIndexFromObj(interp, objv[2], options, "option", - 0, &mode) != TCL_OK) { + if ((objc == 4) && Tcl_GetIndexFromObjStruct(interp, objv[2], options, + sizeof(char *), "option", 0, &mode) != TCL_OK) { return TCL_ERROR; } @@ -4372,7 +4372,7 @@ TclPtrMakeUpvar( } /* Callers must Incr myNamePtr if they plan to Decr it. */ - + int TclPtrObjMakeUpvar( Tcl_Interp *interp, /* Interpreter containing variables. Used for diff --git a/library/http/http.tcl b/library/http/http.tcl index 442cdc5..98066af 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -537,11 +537,10 @@ proc http::geturl {url args} { # If a timeout is specified we set up the after event and arrange for an # asynchronous socket connection. - set sockopts [list] + set sockopts [list -async] if {$state(-timeout) > 0} { set state(after) [after $state(-timeout) \ [list http::reset $token timeout]] - lappend sockopts -async } # If we are using the proxy, we must pass in the full URL that includes @@ -597,10 +596,15 @@ proc http::geturl {url args} { set socketmap($state(socketinfo)) $sock } - # Wait for the connection to complete. + if {![info exists phost]} { + set phost "" + } + fileevent $sock writable [list http::Connect $token $proto $phost $srvurl] - if {$state(-timeout) > 0} { - fileevent $sock writable [list http::Connect $token] + # Wait for the connection to complete. + if {![info exists state(-command)]} { + # geturl does EVERYTHING asynchronously, so if the user + # calls it synchronously, we just do a wait here. http::wait $token if {![info exists state]} { @@ -616,13 +620,29 @@ proc http::geturl {url args} { set err [lindex $state(error) 0] cleanup $token return -code error $err - } elseif {$state(status) ne "connect"} { - # Likely to be connection timeout - return $token } - set state(status) "" } + return $token +} + + +proc http::Connected { token proto phost srvurl} { + variable http + variable urlTypes + + variable $token + upvar 0 $token state + + # Set back the variables needed here + set sock $state(sock) + set isQueryChannel [info exists state(-querychannel)] + set isQuery [info exists state(-query)] + set host [lindex [split $state(socketinfo) :] 0] + set port [lindex [split $state(socketinfo) :] 1] + + set defport [lindex $urlTypes($proto) 0] + # Send data in cr-lf format, but accept any line terminators fconfigure $sock -translation {auto crlf} -buffersize $state(-blocksize) @@ -753,35 +773,17 @@ proc http::geturl {url args} { fileevent $sock readable [list http::Event $sock $token] } - if {![info exists state(-command)]} { - # geturl does EVERYTHING asynchronously, so if the user calls it - # synchronously, we just do a wait here. - - wait $token - if {$state(status) eq "error"} { - # Something went wrong, so throw the exception, and the - # enclosing catch will do cleanup. - return -code error [lindex $state(error) 0] - } - } } err]} { # The socket probably was never connected, or the connection dropped # later. - # Clean up after events and such, but DON'T call the command callback - # (if available) because we're going to throw an exception from here - # instead. - # if state(status) is error, it means someone's already called Finish # to do the above-described clean up. if {$state(status) ne "error"} { - Finish $token $err 1 + Finish $token $err } - cleanup $token - return -code error $err } - return $token } # Data access functions: @@ -865,7 +867,7 @@ proc http::cleanup {token} { # Sets the status of the connection, which unblocks # the waiting geturl call -proc http::Connect {token} { +proc http::Connect {token proto phost srvurl} { variable $token upvar 0 $token state set err "due to unexpected EOF" @@ -873,10 +875,10 @@ proc http::Connect {token} { [eof $state(sock)] || [set err [fconfigure $state(sock) -error]] ne "" } { - Finish $token "connect failed $err" 1 + Finish $token "connect failed $err" } else { - set state(status) connect fileevent $state(sock) writable {} + ::http::Connected $token $proto $phost $srvurl } return } diff --git a/tests/http.test b/tests/http.test index 9861e0e..e2de7d8 100644 --- a/tests/http.test +++ b/tests/http.test @@ -547,11 +547,10 @@ test http-4.14 {http::Event} -body { error "bogus return from http::geturl" } http::wait $token - http::status $token - # error code varies among platforms. -} -returnCodes 1 -match regexp -cleanup { + lindex [http::error $token] 0 +} -cleanup { catch {http::cleanup $token} -} -result {(connect failed|couldn't open socket)} +} -result {connect failed connection refused} # Bogus host test http-4.15 {http::Event} -body { # This test may fail if you use a proxy server. That is to be diff --git a/unix/configure b/unix/configure index 7d8028b..087cdcb 100755 --- a/unix/configure +++ b/unix/configure @@ -7138,7 +7138,7 @@ echo "$as_me: error: ${CC} is not a cygwin compiler." >&2;} echo "$as_me: error: CYGWIN compile is only supported with --enable-threads" >&2;} { (exit 1); exit 1; }; } fi - if test "x${SHARED_BUILD}" = "x1" -a ! -f "../win/tcldde14.dll" -a ! -f "../win/tk86.dll"; then + if test "x${SHARED_BUILD}" = "x1" -a ! -f "../win/dde.dll" -a ! -f "../win/tk86.dll"; then { { echo "$as_me:$LINENO: error: Please configure and make the ../win directory first." >&5 echo "$as_me: error: Please configure and make the ../win directory first." >&2;} { (exit 1); exit 1; }; } diff --git a/unix/tcl.m4 b/unix/tcl.m4 index b13fddd..e969178 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1246,7 +1246,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ if test "x${TCL_THREADS}" = "x0"; then AC_MSG_ERROR([CYGWIN compile is only supported with --enable-threads]) fi - if test "x${SHARED_BUILD}" = "x1" -a ! -f "../win/tcldde14.dll" -a ! -f "../win/tk86.dll"; then + if test "x${SHARED_BUILD}" = "x1" -a ! -f "../win/dde.dll" -a ! -f "../win/tk86.dll"; then AC_MSG_ERROR([Please configure and make the ../win directory first.]) fi ;; diff --git a/unix/tclUnixCompat.c b/unix/tclUnixCompat.c index bcf7d40..f8f0080 100644 --- a/unix/tclUnixCompat.c +++ b/unix/tclUnixCompat.c @@ -993,12 +993,11 @@ TclWinCPUID( /* See: <http://en.wikipedia.org/wiki/CPUID> */ #if defined(HAVE_CPUID) - __asm__ __volatile__("mov %%ebx, %%edi \n\t" /* save %ebx */ + __asm__ __volatile__("mov %%ebx, %%esi \n\t" /* save %ebx */ "cpuid \n\t" - "mov %%ebx, %%esi \n\t" /* save what cpuid just put in %ebx */ - "mov %%edi, %%ebx \n\t" /* restore the old %ebx */ + "xchg %%esi, %%ebx \n\t" /* restore the old %ebx */ : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3]) - : "a"(index) : "edi"); + : "a"(index)); status = TCL_OK; #endif return status; diff --git a/win/tclWinTest.c b/win/tclWinTest.c index 136c4db..773ed19 100644 --- a/win/tclWinTest.c +++ b/win/tclWinTest.c @@ -368,8 +368,8 @@ TestExceptionCmd( Tcl_WrongNumArgs(interp, 0, objv, "<type-of-exception>"); return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], cmds, "command", 0, - &cmd) != TCL_OK) { + if (Tcl_GetIndexFromObjStruct(interp, objv[1], cmds, + sizeof(char *), "command", 0, &cmd) != TCL_OK) { return TCL_ERROR; } |