Index: autosetup/jimsh0.c ================================================================== --- autosetup/jimsh0.c +++ autosetup/jimsh0.c @@ -185,11 +185,11 @@ #endif #define UCHAR(c) ((unsigned char)(c)) -#define JIM_VERSION 73 +#define JIM_VERSION 74 #define JIM_OK 0 #define JIM_ERR 1 #define JIM_RETURN 2 #define JIM_BREAK 3 @@ -321,14 +321,14 @@ #define Jim_GetHashTableSize(ht) ((ht)->size) #define Jim_GetHashTableUsed(ht) ((ht)->used) typedef struct Jim_Obj { - int refCount; char *bytes; - int length; const struct Jim_ObjType *typePtr; + int refCount; + int length; union { jim_wide wideValue; @@ -665,12 +665,10 @@ JIM_EXPORT Jim_Obj * Jim_NewObj (Jim_Interp *interp); JIM_EXPORT void Jim_FreeObj (Jim_Interp *interp, Jim_Obj *objPtr); JIM_EXPORT void Jim_InvalidateStringRep (Jim_Obj *objPtr); -JIM_EXPORT void Jim_InitStringRep (Jim_Obj *objPtr, const char *bytes, - int length); JIM_EXPORT Jim_Obj * Jim_DuplicateObj (Jim_Interp *interp, Jim_Obj *objPtr); JIM_EXPORT const char * Jim_GetString(Jim_Obj *objPtr, int *lenPtr); JIM_EXPORT const char *Jim_String(Jim_Obj *objPtr); @@ -877,10 +875,12 @@ JIM_EXPORT void Jim_HistoryShow(void); JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp); JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base); +JIM_EXPORT int Jim_CheckSignal(Jim_Interp *interp); +#define Jim_CheckSignal(i) ((i)->signal_level && (i)->sigmask) JIM_EXPORT int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName); JIM_EXPORT void Jim_FreeLoadHandles(Jim_Interp *interp); @@ -5671,10 +5671,13 @@ #ifdef JIM_MAINTAINER #define JIM_DEBUG_COMMAND #define JIM_DEBUG_PANIC #endif + +#define JIM_INTEGER_SPACE 24 + const char *jim_tt_name(int type); #ifdef JIM_DEBUG_PANIC static void JimPanicDump(int panic_condition, const char *fmt, ...); #define JimPanic(X) JimPanicDump X @@ -5690,10 +5693,11 @@ static int ListSetIndex(Jim_Interp *interp, Jim_Obj *listPtr, int listindex, Jim_Obj *newObjPtr, int flags); static int JimDeleteLocalProcs(Jim_Interp *interp, Jim_Stack *localCommands); static Jim_Obj *JimExpandDictSugar(Jim_Interp *interp, Jim_Obj *objPtr); static void SetDictSubstFromAny(Jim_Interp *interp, Jim_Obj *objPtr); +static Jim_Obj **JimDictPairs(Jim_Obj *dictPtr, int *len); static void JimSetFailedEnumResult(Jim_Interp *interp, const char *arg, const char *badtype, const char *prefix, const char *const *tablePtr, const char *name); static int JimCallProcedure(Jim_Interp *interp, Jim_Cmd *cmd, int argc, Jim_Obj *const *argv); static int JimGetWideNoErr(Jim_Interp *interp, Jim_Obj *objPtr, jim_wide * widePtr); static int JimSign(jim_wide w); @@ -5934,15 +5938,42 @@ } return n; } #endif -int Jim_WideToString(char *buf, jim_wide wideValue) +static int JimWideToString(char *buf, jim_wide wideValue) { - const char *fmt = "%" JIM_WIDE_MODIFIER; + int pos = 0; - return sprintf(buf, fmt, wideValue); + if (wideValue == 0) { + buf[pos++] = '0'; + } + else { + char tmp[JIM_INTEGER_SPACE]; + int num = 0; + int i; + + if (wideValue < 0) { + buf[pos++] = '-'; + + i = wideValue % 10; + tmp[num++] = (i > 0) ? (10 - i) : -i; + wideValue /= -10; + } + + while (wideValue) { + tmp[num++] = wideValue % 10; + wideValue /= 10; + } + + for (i = 0; i < num; i++) { + buf[pos++] = '0' + tmp[num - i - 1]; + } + } + buf[pos] = 0; + + return pos; } static int JimCheckConversion(const char *str, const char *endptr) { if (str[0] == '\0' || str == endptr) { @@ -6229,10 +6260,18 @@ ht->sizemask = 0; ht->used = 0; ht->collisions = 0; } +static void JimInitHashTableIterator(Jim_HashTable *ht, Jim_HashTableIterator *iter) +{ + iter->ht = ht; + iter->index = -1; + iter->entry = NULL; + iter->nextEntry = NULL; +} + int Jim_InitHashTable(Jim_HashTable *ht, const Jim_HashTableType *type, void *privDataPtr) { JimResetHashTable(ht); ht->type = type; @@ -6408,15 +6447,11 @@ } Jim_HashTableIterator *Jim_GetHashTableIterator(Jim_HashTable *ht) { Jim_HashTableIterator *iter = Jim_Alloc(sizeof(*iter)); - - iter->ht = ht; - iter->index = -1; - iter->entry = NULL; - iter->nextEntry = NULL; + JimInitHashTableIterator(ht, iter); return iter; } Jim_HashEntry *Jim_NextHashEntry(Jim_HashTableIterator *iter) { @@ -10500,12 +10535,10 @@ int Jim_GetExitCode(Jim_Interp *interp) { return interp->exitCode; } -#define JIM_INTEGER_SPACE 24 - static void UpdateStringOfInt(struct Jim_Obj *objPtr); static int SetIntFromAny(Jim_Interp *interp, Jim_Obj *objPtr, int flags); static const Jim_ObjType intObjType = { "int", @@ -10522,16 +10555,16 @@ UpdateStringOfInt, JIM_TYPE_NONE, }; -void UpdateStringOfInt(struct Jim_Obj *objPtr) +static void UpdateStringOfInt(struct Jim_Obj *objPtr) { int len; char buf[JIM_INTEGER_SPACE + 1]; - len = Jim_WideToString(buf, JimWideValue(objPtr)); + len = JimWideToString(buf, JimWideValue(objPtr)); objPtr->bytes = Jim_Alloc(len + 1); memcpy(objPtr->bytes, buf, len + 1); objPtr->length = len; } @@ -10755,11 +10788,11 @@ } #define JIM_ELESTR_SIMPLE 0 #define JIM_ELESTR_BRACE 1 #define JIM_ELESTR_QUOTE 2 -static int ListElementQuotingType(const char *s, int len) +static unsigned char ListElementQuotingType(const char *s, int len) { int i, level, blevel, trySimple = 1; if (len == 0) @@ -10903,17 +10936,23 @@ return p - q; } static void JimMakeListStringRep(Jim_Obj *objPtr, Jim_Obj **objv, int objc) { + #define STATIC_QUOTING_LEN 32 int i, bufLen, realLength; const char *strRep; char *p; - int *quotingType; + unsigned char *quotingType, staticQuoting[STATIC_QUOTING_LEN]; - quotingType = Jim_Alloc(sizeof(int) * objc + 1); + if (objc > STATIC_QUOTING_LEN) { + quotingType = Jim_Alloc(objc); + } + else { + quotingType = staticQuoting; + } bufLen = 0; for (i = 0; i < objc; i++) { int len; strRep = Jim_GetString(objv[i], &len); @@ -10975,11 +11014,14 @@ realLength++; } } *p = '\0'; objPtr->length = realLength; - Jim_Free(quotingType); + + if (quotingType != staticQuoting) { + Jim_Free(quotingType); + } } static void UpdateStringOfList(struct Jim_Obj *objPtr) { JimMakeListStringRep(objPtr, objPtr->internalRep.listValue.ele, objPtr->internalRep.listValue.len); @@ -11000,11 +11042,11 @@ if (Jim_IsDict(objPtr) && !Jim_IsShared(objPtr)) { Jim_Obj **listObjPtrPtr; int len; int i; - Jim_DictPairs(interp, objPtr, &listObjPtrPtr, &len); + listObjPtrPtr = JimDictPairs(objPtr, &len); for (i = 0; i < len; i++) { Jim_IncrRefCount(listObjPtrPtr[i]); } @@ -11225,14 +11267,22 @@ int requiredLen = currentLen + elemc; int i; Jim_Obj **point; if (requiredLen > listPtr->internalRep.listValue.maxLen) { - listPtr->internalRep.listValue.maxLen = requiredLen * 2; + if (requiredLen < 2) { + + requiredLen = 4; + } + else { + requiredLen *= 2; + } listPtr->internalRep.listValue.ele = Jim_Realloc(listPtr->internalRep.listValue.ele, - sizeof(Jim_Obj *) * listPtr->internalRep.listValue.maxLen); + sizeof(Jim_Obj *) * requiredLen); + + listPtr->internalRep.listValue.maxLen = requiredLen; } if (idx < 0) { idx = currentLen; } point = listPtr->internalRep.listValue.ele + idx; @@ -11523,55 +11573,53 @@ } void DupDictInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr) { Jim_HashTable *ht, *dupHt; - Jim_HashTableIterator *htiter; + Jim_HashTableIterator htiter; Jim_HashEntry *he; ht = srcPtr->internalRep.ptr; dupHt = Jim_Alloc(sizeof(*dupHt)); Jim_InitHashTable(dupHt, &JimDictHashTableType, interp); if (ht->size != 0) Jim_ExpandHashTable(dupHt, ht->size); - htiter = Jim_GetHashTableIterator(ht); - while ((he = Jim_NextHashEntry(htiter)) != NULL) { + JimInitHashTableIterator(ht, &htiter); + while ((he = Jim_NextHashEntry(&htiter)) != NULL) { const Jim_Obj *keyObjPtr = he->key; Jim_Obj *valObjPtr = he->u.val; Jim_IncrRefCount((Jim_Obj *)keyObjPtr); Jim_IncrRefCount(valObjPtr); Jim_AddHashEntry(dupHt, keyObjPtr, valObjPtr); } - Jim_FreeHashTableIterator(htiter); dupPtr->internalRep.ptr = dupHt; dupPtr->typePtr = &dictObjType; } static Jim_Obj **JimDictPairs(Jim_Obj *dictPtr, int *len) { Jim_HashTable *ht; - Jim_HashTableIterator *htiter; + Jim_HashTableIterator htiter; Jim_HashEntry *he; Jim_Obj **objv; int i; ht = dictPtr->internalRep.ptr; objv = Jim_Alloc((ht->used * 2) * sizeof(Jim_Obj *)); - htiter = Jim_GetHashTableIterator(ht); + JimInitHashTableIterator(ht, &htiter); i = 0; - while ((he = Jim_NextHashEntry(htiter)) != NULL) { + while ((he = Jim_NextHashEntry(&htiter)) != NULL) { objv[i++] = (Jim_Obj *)he->key; objv[i++] = he->u.val; } *len = i; - Jim_FreeHashTableIterator(htiter); return objv; } static void UpdateStringOfDict(struct Jim_Obj *objPtr) { @@ -12089,14 +12137,15 @@ typedef struct Jim_ExprOperator { const char *name; - int precedence; - int arity; int (*funcop) (Jim_Interp *interp, struct JimExprState * e); - int lazy; + unsigned char precedence; + unsigned char arity; + unsigned char lazy; + unsigned char namelen; } Jim_ExprOperator; static void ExprPush(struct JimExprState *e, Jim_Obj *obj) { Jim_IncrRefCount(obj); @@ -12774,93 +12823,96 @@ LAZY_OP, LAZY_LEFT, LAZY_RIGHT }; +#define OPRINIT(N, P, A, F, L) {N, F, P, A, L, sizeof(N) - 1} + static const struct Jim_ExprOperator Jim_ExprOperators[] = { - {"*", 200, 2, JimExprOpBin, LAZY_NONE}, - {"/", 200, 2, JimExprOpBin, LAZY_NONE}, - {"%", 200, 2, JimExprOpIntBin, LAZY_NONE}, - - {"-", 100, 2, JimExprOpBin, LAZY_NONE}, - {"+", 100, 2, JimExprOpBin, LAZY_NONE}, - - {"<<", 90, 2, JimExprOpIntBin, LAZY_NONE}, - {">>", 90, 2, JimExprOpIntBin, LAZY_NONE}, - - {"<<<", 90, 2, JimExprOpIntBin, LAZY_NONE}, - {">>>", 90, 2, JimExprOpIntBin, LAZY_NONE}, - - {"<", 80, 2, JimExprOpBin, LAZY_NONE}, - {">", 80, 2, JimExprOpBin, LAZY_NONE}, - {"<=", 80, 2, JimExprOpBin, LAZY_NONE}, - {">=", 80, 2, JimExprOpBin, LAZY_NONE}, - - {"==", 70, 2, JimExprOpBin, LAZY_NONE}, - {"!=", 70, 2, JimExprOpBin, LAZY_NONE}, - - {"&", 50, 2, JimExprOpIntBin, LAZY_NONE}, - {"^", 49, 2, JimExprOpIntBin, LAZY_NONE}, - {"|", 48, 2, JimExprOpIntBin, LAZY_NONE}, - - {"&&", 10, 2, NULL, LAZY_OP}, - {NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT}, - {NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT}, - - {"||", 9, 2, NULL, LAZY_OP}, - {NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT}, - {NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT}, - - {"?", 5, 2, JimExprOpNull, LAZY_OP}, - {NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT}, - {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT}, - - {":", 5, 2, JimExprOpNull, LAZY_OP}, - {NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT}, - {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT}, - - {"**", 250, 2, JimExprOpBin, LAZY_NONE}, - - {"eq", 60, 2, JimExprOpStrBin, LAZY_NONE}, - {"ne", 60, 2, JimExprOpStrBin, LAZY_NONE}, - - {"in", 55, 2, JimExprOpStrBin, LAZY_NONE}, - {"ni", 55, 2, JimExprOpStrBin, LAZY_NONE}, - - {"!", 300, 1, JimExprOpNumUnary, LAZY_NONE}, - {"~", 300, 1, JimExprOpIntUnary, LAZY_NONE}, - {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE}, - {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE}, - - - - {"int", 400, 1, JimExprOpNumUnary, LAZY_NONE}, - {"abs", 400, 1, JimExprOpNumUnary, LAZY_NONE}, - {"double", 400, 1, JimExprOpNumUnary, LAZY_NONE}, - {"round", 400, 1, JimExprOpNumUnary, LAZY_NONE}, - {"rand", 400, 0, JimExprOpNone, LAZY_NONE}, - {"srand", 400, 1, JimExprOpIntUnary, LAZY_NONE}, + OPRINIT("*", 110, 2, JimExprOpBin, LAZY_NONE), + OPRINIT("/", 110, 2, JimExprOpBin, LAZY_NONE), + OPRINIT("%", 110, 2, JimExprOpIntBin, LAZY_NONE), + + OPRINIT("-", 100, 2, JimExprOpBin, LAZY_NONE), + OPRINIT("+", 100, 2, JimExprOpBin, LAZY_NONE), + + OPRINIT("<<", 90, 2, JimExprOpIntBin, LAZY_NONE), + OPRINIT(">>", 90, 2, JimExprOpIntBin, LAZY_NONE), + + OPRINIT("<<<", 90, 2, JimExprOpIntBin, LAZY_NONE), + OPRINIT(">>>", 90, 2, JimExprOpIntBin, LAZY_NONE), + + OPRINIT("<", 80, 2, JimExprOpBin, LAZY_NONE), + OPRINIT(">", 80, 2, JimExprOpBin, LAZY_NONE), + OPRINIT("<=", 80, 2, JimExprOpBin, LAZY_NONE), + OPRINIT(">=", 80, 2, JimExprOpBin, LAZY_NONE), + + OPRINIT("==", 70, 2, JimExprOpBin, LAZY_NONE), + OPRINIT("!=", 70, 2, JimExprOpBin, LAZY_NONE), + + OPRINIT("&", 50, 2, JimExprOpIntBin, LAZY_NONE), + OPRINIT("^", 49, 2, JimExprOpIntBin, LAZY_NONE), + OPRINIT("|", 48, 2, JimExprOpIntBin, LAZY_NONE), + + OPRINIT("&&", 10, 2, NULL, LAZY_OP), + OPRINIT(NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT), + OPRINIT(NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT), + + OPRINIT("||", 9, 2, NULL, LAZY_OP), + OPRINIT(NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT), + OPRINIT(NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT), + + OPRINIT("?", 5, 2, JimExprOpNull, LAZY_OP), + OPRINIT(NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT), + OPRINIT(NULL, 5, 2, JimExprOpNull, LAZY_RIGHT), + + OPRINIT(":", 5, 2, JimExprOpNull, LAZY_OP), + OPRINIT(NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT), + OPRINIT(NULL, 5, 2, JimExprOpNull, LAZY_RIGHT), + + OPRINIT("**", 250, 2, JimExprOpBin, LAZY_NONE), + + OPRINIT("eq", 60, 2, JimExprOpStrBin, LAZY_NONE), + OPRINIT("ne", 60, 2, JimExprOpStrBin, LAZY_NONE), + + OPRINIT("in", 55, 2, JimExprOpStrBin, LAZY_NONE), + OPRINIT("ni", 55, 2, JimExprOpStrBin, LAZY_NONE), + + OPRINIT("!", 150, 1, JimExprOpNumUnary, LAZY_NONE), + OPRINIT("~", 150, 1, JimExprOpIntUnary, LAZY_NONE), + OPRINIT(NULL, 150, 1, JimExprOpNumUnary, LAZY_NONE), + OPRINIT(NULL, 150, 1, JimExprOpNumUnary, LAZY_NONE), + + + + OPRINIT("int", 200, 1, JimExprOpNumUnary, LAZY_NONE), + OPRINIT("abs", 200, 1, JimExprOpNumUnary, LAZY_NONE), + OPRINIT("double", 200, 1, JimExprOpNumUnary, LAZY_NONE), + OPRINIT("round", 200, 1, JimExprOpNumUnary, LAZY_NONE), + OPRINIT("rand", 200, 0, JimExprOpNone, LAZY_NONE), + OPRINIT("srand", 200, 1, JimExprOpIntUnary, LAZY_NONE), #ifdef JIM_MATH_FUNCTIONS - {"sin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"cos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"tan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"asin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"acos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"atan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"sinh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"cosh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"tanh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"ceil", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"floor", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"exp", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"log", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"log10", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"sqrt", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - {"pow", 400, 2, JimExprOpBin, LAZY_NONE}, + OPRINIT("sin", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("cos", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("tan", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("asin", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("acos", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("atan", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("sinh", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("cosh", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("tanh", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("ceil", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("floor", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("exp", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("log", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("log10", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("sqrt", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), + OPRINIT("pow", 200, 2, JimExprOpBin, LAZY_NONE), #endif }; +#undef OPRINIT #define JIM_EXPR_OPERATORS_NUM \ (sizeof(Jim_ExprOperators)/sizeof(struct Jim_ExprOperator)) static int JimParseExpression(struct JimParserCtx *pc) @@ -13026,20 +13078,18 @@ int i; int bestIdx = -1, bestLen = 0; for (i = 0; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) { - const char *opname; - int oplen; + const char * const opname = Jim_ExprOperators[i].name; + const int oplen = Jim_ExprOperators[i].namelen; - opname = Jim_ExprOperators[i].name; - if (opname == NULL) { + if (opname == NULL || opname[0] != pc->p[0]) { continue; } - oplen = strlen(opname); - if (strncmp(opname, pc->p, oplen) == 0 && oplen > bestLen) { + if (oplen > bestLen && strncmp(opname, pc->p, oplen) == 0) { bestIdx = i + JIM_TT_EXPR_OP; bestLen = oplen; } } if (bestIdx == -1) { @@ -13111,12 +13161,12 @@ }; typedef struct ExprByteCode { - int len; ScriptToken *token; + int len; int inUse; } ExprByteCode; static void ExprFreeByteCode(Jim_Interp *interp, ExprByteCode * expr) { @@ -13855,16 +13905,16 @@ typedef struct ScanFmtPartDescr { - char type; - char modifier; + char *arg; + char *prefix; size_t width; int pos; - char *arg; - char *prefix; + char type; + char modifier; } ScanFmtPartDescr; typedef struct ScanFmtStringObj { @@ -14871,12 +14921,12 @@ } if (retcode == JIM_OK && argc) { retcode = JimInvokeCommand(interp, argc, argv); - if (interp->signal_level && interp->sigmask) { - + + if (Jim_CheckSignal(interp)) { retcode = JIM_SIGNAL; } } @@ -15446,17 +15496,17 @@ if (he) { callback(interp, listObjPtr, he, type); } } else { - Jim_HashTableIterator *htiter = Jim_GetHashTableIterator(ht); - while ((he = Jim_NextHashEntry(htiter)) != NULL) { + Jim_HashTableIterator htiter; + JimInitHashTableIterator(ht, &htiter); + while ((he = Jim_NextHashEntry(&htiter)) != NULL) { if (patternObjPtr == NULL || JimGlobMatch(Jim_String(patternObjPtr), he->key, 0)) { callback(interp, listObjPtr, he, type); } } - Jim_FreeHashTableIterator(htiter); } return listObjPtr; } @@ -17795,11 +17845,11 @@ if ((ignore_mask & (1 << JIM_SIGNAL)) == 0) { sig++; } interp->signal_level += sig; - if (interp->signal_level && interp->sigmask) { + if (Jim_CheckSignal(interp)) { exitCode = JIM_SIGNAL; } else { exitCode = Jim_EvalObj(interp, argv[0]); @@ -17951,25 +18001,24 @@ static int JimInfoReferences(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { Jim_Obj *listObjPtr; - Jim_HashTableIterator *htiter; + Jim_HashTableIterator htiter; Jim_HashEntry *he; listObjPtr = Jim_NewListObj(interp, NULL, 0); - htiter = Jim_GetHashTableIterator(&interp->references); - while ((he = Jim_NextHashEntry(htiter)) != NULL) { + JimInitHashTableIterator(&interp->references, &htiter); + while ((he = Jim_NextHashEntry(&htiter)) != NULL) { char buf[JIM_REFERENCE_SPACE + 1]; Jim_Reference *refPtr = he->u.val; const unsigned long *refId = he->key; JimFormatReference(buf, refPtr, *refId); Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, buf, -1)); } - Jim_FreeHashTableIterator(htiter); Jim_SetResult(interp, listObjPtr); return JIM_OK; } #endif @@ -18005,17 +18054,17 @@ { Jim_HashEntry *he; Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0); - Jim_HashTableIterator *htiter = Jim_GetHashTableIterator(ht); - while ((he = Jim_NextHashEntry(htiter)) != NULL) { + Jim_HashTableIterator htiter; + JimInitHashTableIterator(ht, &htiter); + while ((he = Jim_NextHashEntry(&htiter)) != NULL) { if (patternObjPtr == NULL || JimGlobMatch(Jim_String(patternObjPtr), Jim_String((Jim_Obj *)he->key), 0)) { callback(interp, listObjPtr, he, type); } } - Jim_FreeHashTableIterator(htiter); return listObjPtr; }