Fossil SCM
Upgrade the included Jim Tcl to 0.74.
Commit
753f4d9a0426f24e2ef72f74b5960930e3c10eec
Parent
f7c022c1416daee…
1 file changed
+186
-137
+186
-137
| --- autosetup/jimsh0.c | ||
| +++ autosetup/jimsh0.c | ||
| @@ -185,11 +185,11 @@ | ||
| 185 | 185 | #endif |
| 186 | 186 | |
| 187 | 187 | #define UCHAR(c) ((unsigned char)(c)) |
| 188 | 188 | |
| 189 | 189 | |
| 190 | -#define JIM_VERSION 73 | |
| 190 | +#define JIM_VERSION 74 | |
| 191 | 191 | |
| 192 | 192 | #define JIM_OK 0 |
| 193 | 193 | #define JIM_ERR 1 |
| 194 | 194 | #define JIM_RETURN 2 |
| 195 | 195 | #define JIM_BREAK 3 |
| @@ -321,14 +321,14 @@ | ||
| 321 | 321 | #define Jim_GetHashTableSize(ht) ((ht)->size) |
| 322 | 322 | #define Jim_GetHashTableUsed(ht) ((ht)->used) |
| 323 | 323 | |
| 324 | 324 | |
| 325 | 325 | typedef struct Jim_Obj { |
| 326 | - int refCount; | |
| 327 | 326 | char *bytes; |
| 328 | - int length; | |
| 329 | 327 | const struct Jim_ObjType *typePtr; |
| 328 | + int refCount; | |
| 329 | + int length; | |
| 330 | 330 | |
| 331 | 331 | union { |
| 332 | 332 | |
| 333 | 333 | jim_wide wideValue; |
| 334 | 334 | |
| @@ -665,12 +665,10 @@ | ||
| 665 | 665 | |
| 666 | 666 | |
| 667 | 667 | JIM_EXPORT Jim_Obj * Jim_NewObj (Jim_Interp *interp); |
| 668 | 668 | JIM_EXPORT void Jim_FreeObj (Jim_Interp *interp, Jim_Obj *objPtr); |
| 669 | 669 | JIM_EXPORT void Jim_InvalidateStringRep (Jim_Obj *objPtr); |
| 670 | -JIM_EXPORT void Jim_InitStringRep (Jim_Obj *objPtr, const char *bytes, | |
| 671 | - int length); | |
| 672 | 670 | JIM_EXPORT Jim_Obj * Jim_DuplicateObj (Jim_Interp *interp, |
| 673 | 671 | Jim_Obj *objPtr); |
| 674 | 672 | JIM_EXPORT const char * Jim_GetString(Jim_Obj *objPtr, |
| 675 | 673 | int *lenPtr); |
| 676 | 674 | JIM_EXPORT const char *Jim_String(Jim_Obj *objPtr); |
| @@ -877,10 +875,12 @@ | ||
| 877 | 875 | JIM_EXPORT void Jim_HistoryShow(void); |
| 878 | 876 | |
| 879 | 877 | |
| 880 | 878 | JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp); |
| 881 | 879 | JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base); |
| 880 | +JIM_EXPORT int Jim_CheckSignal(Jim_Interp *interp); | |
| 881 | +#define Jim_CheckSignal(i) ((i)->signal_level && (i)->sigmask) | |
| 882 | 882 | |
| 883 | 883 | |
| 884 | 884 | JIM_EXPORT int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName); |
| 885 | 885 | JIM_EXPORT void Jim_FreeLoadHandles(Jim_Interp *interp); |
| 886 | 886 | |
| @@ -5671,10 +5671,13 @@ | ||
| 5671 | 5671 | #ifdef JIM_MAINTAINER |
| 5672 | 5672 | #define JIM_DEBUG_COMMAND |
| 5673 | 5673 | #define JIM_DEBUG_PANIC |
| 5674 | 5674 | #endif |
| 5675 | 5675 | |
| 5676 | + | |
| 5677 | +#define JIM_INTEGER_SPACE 24 | |
| 5678 | + | |
| 5676 | 5679 | const char *jim_tt_name(int type); |
| 5677 | 5680 | |
| 5678 | 5681 | #ifdef JIM_DEBUG_PANIC |
| 5679 | 5682 | static void JimPanicDump(int panic_condition, const char *fmt, ...); |
| 5680 | 5683 | #define JimPanic(X) JimPanicDump X |
| @@ -5690,10 +5693,11 @@ | ||
| 5690 | 5693 | static int ListSetIndex(Jim_Interp *interp, Jim_Obj *listPtr, int listindex, Jim_Obj *newObjPtr, |
| 5691 | 5694 | int flags); |
| 5692 | 5695 | static int JimDeleteLocalProcs(Jim_Interp *interp, Jim_Stack *localCommands); |
| 5693 | 5696 | static Jim_Obj *JimExpandDictSugar(Jim_Interp *interp, Jim_Obj *objPtr); |
| 5694 | 5697 | static void SetDictSubstFromAny(Jim_Interp *interp, Jim_Obj *objPtr); |
| 5698 | +static Jim_Obj **JimDictPairs(Jim_Obj *dictPtr, int *len); | |
| 5695 | 5699 | static void JimSetFailedEnumResult(Jim_Interp *interp, const char *arg, const char *badtype, |
| 5696 | 5700 | const char *prefix, const char *const *tablePtr, const char *name); |
| 5697 | 5701 | static int JimCallProcedure(Jim_Interp *interp, Jim_Cmd *cmd, int argc, Jim_Obj *const *argv); |
| 5698 | 5702 | static int JimGetWideNoErr(Jim_Interp *interp, Jim_Obj *objPtr, jim_wide * widePtr); |
| 5699 | 5703 | static int JimSign(jim_wide w); |
| @@ -5934,15 +5938,42 @@ | ||
| 5934 | 5938 | } |
| 5935 | 5939 | return n; |
| 5936 | 5940 | } |
| 5937 | 5941 | #endif |
| 5938 | 5942 | |
| 5939 | -int Jim_WideToString(char *buf, jim_wide wideValue) | |
| 5943 | +static int JimWideToString(char *buf, jim_wide wideValue) | |
| 5940 | 5944 | { |
| 5941 | - const char *fmt = "%" JIM_WIDE_MODIFIER; | |
| 5945 | + int pos = 0; | |
| 5942 | 5946 | |
| 5943 | - return sprintf(buf, fmt, wideValue); | |
| 5947 | + if (wideValue == 0) { | |
| 5948 | + buf[pos++] = '0'; | |
| 5949 | + } | |
| 5950 | + else { | |
| 5951 | + char tmp[JIM_INTEGER_SPACE]; | |
| 5952 | + int num = 0; | |
| 5953 | + int i; | |
| 5954 | + | |
| 5955 | + if (wideValue < 0) { | |
| 5956 | + buf[pos++] = '-'; | |
| 5957 | + | |
| 5958 | + i = wideValue % 10; | |
| 5959 | + tmp[num++] = (i > 0) ? (10 - i) : -i; | |
| 5960 | + wideValue /= -10; | |
| 5961 | + } | |
| 5962 | + | |
| 5963 | + while (wideValue) { | |
| 5964 | + tmp[num++] = wideValue % 10; | |
| 5965 | + wideValue /= 10; | |
| 5966 | + } | |
| 5967 | + | |
| 5968 | + for (i = 0; i < num; i++) { | |
| 5969 | + buf[pos++] = '0' + tmp[num - i - 1]; | |
| 5970 | + } | |
| 5971 | + } | |
| 5972 | + buf[pos] = 0; | |
| 5973 | + | |
| 5974 | + return pos; | |
| 5944 | 5975 | } |
| 5945 | 5976 | |
| 5946 | 5977 | static int JimCheckConversion(const char *str, const char *endptr) |
| 5947 | 5978 | { |
| 5948 | 5979 | if (str[0] == '\0' || str == endptr) { |
| @@ -6229,10 +6260,18 @@ | ||
| 6229 | 6260 | ht->sizemask = 0; |
| 6230 | 6261 | ht->used = 0; |
| 6231 | 6262 | ht->collisions = 0; |
| 6232 | 6263 | } |
| 6233 | 6264 | |
| 6265 | +static void JimInitHashTableIterator(Jim_HashTable *ht, Jim_HashTableIterator *iter) | |
| 6266 | +{ | |
| 6267 | + iter->ht = ht; | |
| 6268 | + iter->index = -1; | |
| 6269 | + iter->entry = NULL; | |
| 6270 | + iter->nextEntry = NULL; | |
| 6271 | +} | |
| 6272 | + | |
| 6234 | 6273 | |
| 6235 | 6274 | int Jim_InitHashTable(Jim_HashTable *ht, const Jim_HashTableType *type, void *privDataPtr) |
| 6236 | 6275 | { |
| 6237 | 6276 | JimResetHashTable(ht); |
| 6238 | 6277 | ht->type = type; |
| @@ -6408,15 +6447,11 @@ | ||
| 6408 | 6447 | } |
| 6409 | 6448 | |
| 6410 | 6449 | Jim_HashTableIterator *Jim_GetHashTableIterator(Jim_HashTable *ht) |
| 6411 | 6450 | { |
| 6412 | 6451 | Jim_HashTableIterator *iter = Jim_Alloc(sizeof(*iter)); |
| 6413 | - | |
| 6414 | - iter->ht = ht; | |
| 6415 | - iter->index = -1; | |
| 6416 | - iter->entry = NULL; | |
| 6417 | - iter->nextEntry = NULL; | |
| 6452 | + JimInitHashTableIterator(ht, iter); | |
| 6418 | 6453 | return iter; |
| 6419 | 6454 | } |
| 6420 | 6455 | |
| 6421 | 6456 | Jim_HashEntry *Jim_NextHashEntry(Jim_HashTableIterator *iter) |
| 6422 | 6457 | { |
| @@ -10500,12 +10535,10 @@ | ||
| 10500 | 10535 | int Jim_GetExitCode(Jim_Interp *interp) |
| 10501 | 10536 | { |
| 10502 | 10537 | return interp->exitCode; |
| 10503 | 10538 | } |
| 10504 | 10539 | |
| 10505 | -#define JIM_INTEGER_SPACE 24 | |
| 10506 | - | |
| 10507 | 10540 | static void UpdateStringOfInt(struct Jim_Obj *objPtr); |
| 10508 | 10541 | static int SetIntFromAny(Jim_Interp *interp, Jim_Obj *objPtr, int flags); |
| 10509 | 10542 | |
| 10510 | 10543 | static const Jim_ObjType intObjType = { |
| 10511 | 10544 | "int", |
| @@ -10522,16 +10555,16 @@ | ||
| 10522 | 10555 | UpdateStringOfInt, |
| 10523 | 10556 | JIM_TYPE_NONE, |
| 10524 | 10557 | }; |
| 10525 | 10558 | |
| 10526 | 10559 | |
| 10527 | -void UpdateStringOfInt(struct Jim_Obj *objPtr) | |
| 10560 | +static void UpdateStringOfInt(struct Jim_Obj *objPtr) | |
| 10528 | 10561 | { |
| 10529 | 10562 | int len; |
| 10530 | 10563 | char buf[JIM_INTEGER_SPACE + 1]; |
| 10531 | 10564 | |
| 10532 | - len = Jim_WideToString(buf, JimWideValue(objPtr)); | |
| 10565 | + len = JimWideToString(buf, JimWideValue(objPtr)); | |
| 10533 | 10566 | objPtr->bytes = Jim_Alloc(len + 1); |
| 10534 | 10567 | memcpy(objPtr->bytes, buf, len + 1); |
| 10535 | 10568 | objPtr->length = len; |
| 10536 | 10569 | } |
| 10537 | 10570 | |
| @@ -10755,11 +10788,11 @@ | ||
| 10755 | 10788 | } |
| 10756 | 10789 | |
| 10757 | 10790 | #define JIM_ELESTR_SIMPLE 0 |
| 10758 | 10791 | #define JIM_ELESTR_BRACE 1 |
| 10759 | 10792 | #define JIM_ELESTR_QUOTE 2 |
| 10760 | -static int ListElementQuotingType(const char *s, int len) | |
| 10793 | +static unsigned char ListElementQuotingType(const char *s, int len) | |
| 10761 | 10794 | { |
| 10762 | 10795 | int i, level, blevel, trySimple = 1; |
| 10763 | 10796 | |
| 10764 | 10797 | |
| 10765 | 10798 | if (len == 0) |
| @@ -10903,17 +10936,23 @@ | ||
| 10903 | 10936 | return p - q; |
| 10904 | 10937 | } |
| 10905 | 10938 | |
| 10906 | 10939 | static void JimMakeListStringRep(Jim_Obj *objPtr, Jim_Obj **objv, int objc) |
| 10907 | 10940 | { |
| 10941 | + #define STATIC_QUOTING_LEN 32 | |
| 10908 | 10942 | int i, bufLen, realLength; |
| 10909 | 10943 | const char *strRep; |
| 10910 | 10944 | char *p; |
| 10911 | - int *quotingType; | |
| 10945 | + unsigned char *quotingType, staticQuoting[STATIC_QUOTING_LEN]; | |
| 10912 | 10946 | |
| 10913 | 10947 | |
| 10914 | - quotingType = Jim_Alloc(sizeof(int) * objc + 1); | |
| 10948 | + if (objc > STATIC_QUOTING_LEN) { | |
| 10949 | + quotingType = Jim_Alloc(objc); | |
| 10950 | + } | |
| 10951 | + else { | |
| 10952 | + quotingType = staticQuoting; | |
| 10953 | + } | |
| 10915 | 10954 | bufLen = 0; |
| 10916 | 10955 | for (i = 0; i < objc; i++) { |
| 10917 | 10956 | int len; |
| 10918 | 10957 | |
| 10919 | 10958 | strRep = Jim_GetString(objv[i], &len); |
| @@ -10975,11 +11014,14 @@ | ||
| 10975 | 11014 | realLength++; |
| 10976 | 11015 | } |
| 10977 | 11016 | } |
| 10978 | 11017 | *p = '\0'; |
| 10979 | 11018 | objPtr->length = realLength; |
| 10980 | - Jim_Free(quotingType); | |
| 11019 | + | |
| 11020 | + if (quotingType != staticQuoting) { | |
| 11021 | + Jim_Free(quotingType); | |
| 11022 | + } | |
| 10981 | 11023 | } |
| 10982 | 11024 | |
| 10983 | 11025 | static void UpdateStringOfList(struct Jim_Obj *objPtr) |
| 10984 | 11026 | { |
| 10985 | 11027 | JimMakeListStringRep(objPtr, objPtr->internalRep.listValue.ele, objPtr->internalRep.listValue.len); |
| @@ -11000,11 +11042,11 @@ | ||
| 11000 | 11042 | if (Jim_IsDict(objPtr) && !Jim_IsShared(objPtr)) { |
| 11001 | 11043 | Jim_Obj **listObjPtrPtr; |
| 11002 | 11044 | int len; |
| 11003 | 11045 | int i; |
| 11004 | 11046 | |
| 11005 | - Jim_DictPairs(interp, objPtr, &listObjPtrPtr, &len); | |
| 11047 | + listObjPtrPtr = JimDictPairs(objPtr, &len); | |
| 11006 | 11048 | for (i = 0; i < len; i++) { |
| 11007 | 11049 | Jim_IncrRefCount(listObjPtrPtr[i]); |
| 11008 | 11050 | } |
| 11009 | 11051 | |
| 11010 | 11052 | |
| @@ -11225,14 +11267,22 @@ | ||
| 11225 | 11267 | int requiredLen = currentLen + elemc; |
| 11226 | 11268 | int i; |
| 11227 | 11269 | Jim_Obj **point; |
| 11228 | 11270 | |
| 11229 | 11271 | if (requiredLen > listPtr->internalRep.listValue.maxLen) { |
| 11230 | - listPtr->internalRep.listValue.maxLen = requiredLen * 2; | |
| 11272 | + if (requiredLen < 2) { | |
| 11273 | + | |
| 11274 | + requiredLen = 4; | |
| 11275 | + } | |
| 11276 | + else { | |
| 11277 | + requiredLen *= 2; | |
| 11278 | + } | |
| 11231 | 11279 | |
| 11232 | 11280 | listPtr->internalRep.listValue.ele = Jim_Realloc(listPtr->internalRep.listValue.ele, |
| 11233 | - sizeof(Jim_Obj *) * listPtr->internalRep.listValue.maxLen); | |
| 11281 | + sizeof(Jim_Obj *) * requiredLen); | |
| 11282 | + | |
| 11283 | + listPtr->internalRep.listValue.maxLen = requiredLen; | |
| 11234 | 11284 | } |
| 11235 | 11285 | if (idx < 0) { |
| 11236 | 11286 | idx = currentLen; |
| 11237 | 11287 | } |
| 11238 | 11288 | point = listPtr->internalRep.listValue.ele + idx; |
| @@ -11523,55 +11573,53 @@ | ||
| 11523 | 11573 | } |
| 11524 | 11574 | |
| 11525 | 11575 | void DupDictInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr) |
| 11526 | 11576 | { |
| 11527 | 11577 | Jim_HashTable *ht, *dupHt; |
| 11528 | - Jim_HashTableIterator *htiter; | |
| 11578 | + Jim_HashTableIterator htiter; | |
| 11529 | 11579 | Jim_HashEntry *he; |
| 11530 | 11580 | |
| 11531 | 11581 | |
| 11532 | 11582 | ht = srcPtr->internalRep.ptr; |
| 11533 | 11583 | dupHt = Jim_Alloc(sizeof(*dupHt)); |
| 11534 | 11584 | Jim_InitHashTable(dupHt, &JimDictHashTableType, interp); |
| 11535 | 11585 | if (ht->size != 0) |
| 11536 | 11586 | Jim_ExpandHashTable(dupHt, ht->size); |
| 11537 | 11587 | |
| 11538 | - htiter = Jim_GetHashTableIterator(ht); | |
| 11539 | - while ((he = Jim_NextHashEntry(htiter)) != NULL) { | |
| 11588 | + JimInitHashTableIterator(ht, &htiter); | |
| 11589 | + while ((he = Jim_NextHashEntry(&htiter)) != NULL) { | |
| 11540 | 11590 | const Jim_Obj *keyObjPtr = he->key; |
| 11541 | 11591 | Jim_Obj *valObjPtr = he->u.val; |
| 11542 | 11592 | |
| 11543 | 11593 | Jim_IncrRefCount((Jim_Obj *)keyObjPtr); |
| 11544 | 11594 | Jim_IncrRefCount(valObjPtr); |
| 11545 | 11595 | Jim_AddHashEntry(dupHt, keyObjPtr, valObjPtr); |
| 11546 | 11596 | } |
| 11547 | - Jim_FreeHashTableIterator(htiter); | |
| 11548 | 11597 | |
| 11549 | 11598 | dupPtr->internalRep.ptr = dupHt; |
| 11550 | 11599 | dupPtr->typePtr = &dictObjType; |
| 11551 | 11600 | } |
| 11552 | 11601 | |
| 11553 | 11602 | static Jim_Obj **JimDictPairs(Jim_Obj *dictPtr, int *len) |
| 11554 | 11603 | { |
| 11555 | 11604 | Jim_HashTable *ht; |
| 11556 | - Jim_HashTableIterator *htiter; | |
| 11605 | + Jim_HashTableIterator htiter; | |
| 11557 | 11606 | Jim_HashEntry *he; |
| 11558 | 11607 | Jim_Obj **objv; |
| 11559 | 11608 | int i; |
| 11560 | 11609 | |
| 11561 | 11610 | ht = dictPtr->internalRep.ptr; |
| 11562 | 11611 | |
| 11563 | 11612 | |
| 11564 | 11613 | objv = Jim_Alloc((ht->used * 2) * sizeof(Jim_Obj *)); |
| 11565 | - htiter = Jim_GetHashTableIterator(ht); | |
| 11614 | + JimInitHashTableIterator(ht, &htiter); | |
| 11566 | 11615 | i = 0; |
| 11567 | - while ((he = Jim_NextHashEntry(htiter)) != NULL) { | |
| 11616 | + while ((he = Jim_NextHashEntry(&htiter)) != NULL) { | |
| 11568 | 11617 | objv[i++] = (Jim_Obj *)he->key; |
| 11569 | 11618 | objv[i++] = he->u.val; |
| 11570 | 11619 | } |
| 11571 | 11620 | *len = i; |
| 11572 | - Jim_FreeHashTableIterator(htiter); | |
| 11573 | 11621 | return objv; |
| 11574 | 11622 | } |
| 11575 | 11623 | |
| 11576 | 11624 | static void UpdateStringOfDict(struct Jim_Obj *objPtr) |
| 11577 | 11625 | { |
| @@ -12089,14 +12137,15 @@ | ||
| 12089 | 12137 | |
| 12090 | 12138 | |
| 12091 | 12139 | typedef struct Jim_ExprOperator |
| 12092 | 12140 | { |
| 12093 | 12141 | const char *name; |
| 12094 | - int precedence; | |
| 12095 | - int arity; | |
| 12096 | 12142 | int (*funcop) (Jim_Interp *interp, struct JimExprState * e); |
| 12097 | - int lazy; | |
| 12143 | + unsigned char precedence; | |
| 12144 | + unsigned char arity; | |
| 12145 | + unsigned char lazy; | |
| 12146 | + unsigned char namelen; | |
| 12098 | 12147 | } Jim_ExprOperator; |
| 12099 | 12148 | |
| 12100 | 12149 | static void ExprPush(struct JimExprState *e, Jim_Obj *obj) |
| 12101 | 12150 | { |
| 12102 | 12151 | Jim_IncrRefCount(obj); |
| @@ -12774,93 +12823,96 @@ | ||
| 12774 | 12823 | LAZY_OP, |
| 12775 | 12824 | LAZY_LEFT, |
| 12776 | 12825 | LAZY_RIGHT |
| 12777 | 12826 | }; |
| 12778 | 12827 | |
| 12828 | +#define OPRINIT(N, P, A, F, L) {N, F, P, A, L, sizeof(N) - 1} | |
| 12829 | + | |
| 12779 | 12830 | static const struct Jim_ExprOperator Jim_ExprOperators[] = { |
| 12780 | - {"*", 200, 2, JimExprOpBin, LAZY_NONE}, | |
| 12781 | - {"/", 200, 2, JimExprOpBin, LAZY_NONE}, | |
| 12782 | - {"%", 200, 2, JimExprOpIntBin, LAZY_NONE}, | |
| 12783 | - | |
| 12784 | - {"-", 100, 2, JimExprOpBin, LAZY_NONE}, | |
| 12785 | - {"+", 100, 2, JimExprOpBin, LAZY_NONE}, | |
| 12786 | - | |
| 12787 | - {"<<", 90, 2, JimExprOpIntBin, LAZY_NONE}, | |
| 12788 | - {">>", 90, 2, JimExprOpIntBin, LAZY_NONE}, | |
| 12789 | - | |
| 12790 | - {"<<<", 90, 2, JimExprOpIntBin, LAZY_NONE}, | |
| 12791 | - {">>>", 90, 2, JimExprOpIntBin, LAZY_NONE}, | |
| 12792 | - | |
| 12793 | - {"<", 80, 2, JimExprOpBin, LAZY_NONE}, | |
| 12794 | - {">", 80, 2, JimExprOpBin, LAZY_NONE}, | |
| 12795 | - {"<=", 80, 2, JimExprOpBin, LAZY_NONE}, | |
| 12796 | - {">=", 80, 2, JimExprOpBin, LAZY_NONE}, | |
| 12797 | - | |
| 12798 | - {"==", 70, 2, JimExprOpBin, LAZY_NONE}, | |
| 12799 | - {"!=", 70, 2, JimExprOpBin, LAZY_NONE}, | |
| 12800 | - | |
| 12801 | - {"&", 50, 2, JimExprOpIntBin, LAZY_NONE}, | |
| 12802 | - {"^", 49, 2, JimExprOpIntBin, LAZY_NONE}, | |
| 12803 | - {"|", 48, 2, JimExprOpIntBin, LAZY_NONE}, | |
| 12804 | - | |
| 12805 | - {"&&", 10, 2, NULL, LAZY_OP}, | |
| 12806 | - {NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT}, | |
| 12807 | - {NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT}, | |
| 12808 | - | |
| 12809 | - {"||", 9, 2, NULL, LAZY_OP}, | |
| 12810 | - {NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT}, | |
| 12811 | - {NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT}, | |
| 12812 | - | |
| 12813 | - {"?", 5, 2, JimExprOpNull, LAZY_OP}, | |
| 12814 | - {NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT}, | |
| 12815 | - {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT}, | |
| 12816 | - | |
| 12817 | - {":", 5, 2, JimExprOpNull, LAZY_OP}, | |
| 12818 | - {NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT}, | |
| 12819 | - {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT}, | |
| 12820 | - | |
| 12821 | - {"**", 250, 2, JimExprOpBin, LAZY_NONE}, | |
| 12822 | - | |
| 12823 | - {"eq", 60, 2, JimExprOpStrBin, LAZY_NONE}, | |
| 12824 | - {"ne", 60, 2, JimExprOpStrBin, LAZY_NONE}, | |
| 12825 | - | |
| 12826 | - {"in", 55, 2, JimExprOpStrBin, LAZY_NONE}, | |
| 12827 | - {"ni", 55, 2, JimExprOpStrBin, LAZY_NONE}, | |
| 12828 | - | |
| 12829 | - {"!", 300, 1, JimExprOpNumUnary, LAZY_NONE}, | |
| 12830 | - {"~", 300, 1, JimExprOpIntUnary, LAZY_NONE}, | |
| 12831 | - {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE}, | |
| 12832 | - {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE}, | |
| 12833 | - | |
| 12834 | - | |
| 12835 | - | |
| 12836 | - {"int", 400, 1, JimExprOpNumUnary, LAZY_NONE}, | |
| 12837 | - {"abs", 400, 1, JimExprOpNumUnary, LAZY_NONE}, | |
| 12838 | - {"double", 400, 1, JimExprOpNumUnary, LAZY_NONE}, | |
| 12839 | - {"round", 400, 1, JimExprOpNumUnary, LAZY_NONE}, | |
| 12840 | - {"rand", 400, 0, JimExprOpNone, LAZY_NONE}, | |
| 12841 | - {"srand", 400, 1, JimExprOpIntUnary, LAZY_NONE}, | |
| 12831 | + OPRINIT("*", 110, 2, JimExprOpBin, LAZY_NONE), | |
| 12832 | + OPRINIT("/", 110, 2, JimExprOpBin, LAZY_NONE), | |
| 12833 | + OPRINIT("%", 110, 2, JimExprOpIntBin, LAZY_NONE), | |
| 12834 | + | |
| 12835 | + OPRINIT("-", 100, 2, JimExprOpBin, LAZY_NONE), | |
| 12836 | + OPRINIT("+", 100, 2, JimExprOpBin, LAZY_NONE), | |
| 12837 | + | |
| 12838 | + OPRINIT("<<", 90, 2, JimExprOpIntBin, LAZY_NONE), | |
| 12839 | + OPRINIT(">>", 90, 2, JimExprOpIntBin, LAZY_NONE), | |
| 12840 | + | |
| 12841 | + OPRINIT("<<<", 90, 2, JimExprOpIntBin, LAZY_NONE), | |
| 12842 | + OPRINIT(">>>", 90, 2, JimExprOpIntBin, LAZY_NONE), | |
| 12843 | + | |
| 12844 | + OPRINIT("<", 80, 2, JimExprOpBin, LAZY_NONE), | |
| 12845 | + OPRINIT(">", 80, 2, JimExprOpBin, LAZY_NONE), | |
| 12846 | + OPRINIT("<=", 80, 2, JimExprOpBin, LAZY_NONE), | |
| 12847 | + OPRINIT(">=", 80, 2, JimExprOpBin, LAZY_NONE), | |
| 12848 | + | |
| 12849 | + OPRINIT("==", 70, 2, JimExprOpBin, LAZY_NONE), | |
| 12850 | + OPRINIT("!=", 70, 2, JimExprOpBin, LAZY_NONE), | |
| 12851 | + | |
| 12852 | + OPRINIT("&", 50, 2, JimExprOpIntBin, LAZY_NONE), | |
| 12853 | + OPRINIT("^", 49, 2, JimExprOpIntBin, LAZY_NONE), | |
| 12854 | + OPRINIT("|", 48, 2, JimExprOpIntBin, LAZY_NONE), | |
| 12855 | + | |
| 12856 | + OPRINIT("&&", 10, 2, NULL, LAZY_OP), | |
| 12857 | + OPRINIT(NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT), | |
| 12858 | + OPRINIT(NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT), | |
| 12859 | + | |
| 12860 | + OPRINIT("||", 9, 2, NULL, LAZY_OP), | |
| 12861 | + OPRINIT(NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT), | |
| 12862 | + OPRINIT(NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT), | |
| 12863 | + | |
| 12864 | + OPRINIT("?", 5, 2, JimExprOpNull, LAZY_OP), | |
| 12865 | + OPRINIT(NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT), | |
| 12866 | + OPRINIT(NULL, 5, 2, JimExprOpNull, LAZY_RIGHT), | |
| 12867 | + | |
| 12868 | + OPRINIT(":", 5, 2, JimExprOpNull, LAZY_OP), | |
| 12869 | + OPRINIT(NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT), | |
| 12870 | + OPRINIT(NULL, 5, 2, JimExprOpNull, LAZY_RIGHT), | |
| 12871 | + | |
| 12872 | + OPRINIT("**", 250, 2, JimExprOpBin, LAZY_NONE), | |
| 12873 | + | |
| 12874 | + OPRINIT("eq", 60, 2, JimExprOpStrBin, LAZY_NONE), | |
| 12875 | + OPRINIT("ne", 60, 2, JimExprOpStrBin, LAZY_NONE), | |
| 12876 | + | |
| 12877 | + OPRINIT("in", 55, 2, JimExprOpStrBin, LAZY_NONE), | |
| 12878 | + OPRINIT("ni", 55, 2, JimExprOpStrBin, LAZY_NONE), | |
| 12879 | + | |
| 12880 | + OPRINIT("!", 150, 1, JimExprOpNumUnary, LAZY_NONE), | |
| 12881 | + OPRINIT("~", 150, 1, JimExprOpIntUnary, LAZY_NONE), | |
| 12882 | + OPRINIT(NULL, 150, 1, JimExprOpNumUnary, LAZY_NONE), | |
| 12883 | + OPRINIT(NULL, 150, 1, JimExprOpNumUnary, LAZY_NONE), | |
| 12884 | + | |
| 12885 | + | |
| 12886 | + | |
| 12887 | + OPRINIT("int", 200, 1, JimExprOpNumUnary, LAZY_NONE), | |
| 12888 | + OPRINIT("abs", 200, 1, JimExprOpNumUnary, LAZY_NONE), | |
| 12889 | + OPRINIT("double", 200, 1, JimExprOpNumUnary, LAZY_NONE), | |
| 12890 | + OPRINIT("round", 200, 1, JimExprOpNumUnary, LAZY_NONE), | |
| 12891 | + OPRINIT("rand", 200, 0, JimExprOpNone, LAZY_NONE), | |
| 12892 | + OPRINIT("srand", 200, 1, JimExprOpIntUnary, LAZY_NONE), | |
| 12842 | 12893 | |
| 12843 | 12894 | #ifdef JIM_MATH_FUNCTIONS |
| 12844 | - {"sin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12845 | - {"cos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12846 | - {"tan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12847 | - {"asin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12848 | - {"acos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12849 | - {"atan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12850 | - {"sinh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12851 | - {"cosh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12852 | - {"tanh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12853 | - {"ceil", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12854 | - {"floor", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12855 | - {"exp", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12856 | - {"log", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12857 | - {"log10", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12858 | - {"sqrt", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, | |
| 12859 | - {"pow", 400, 2, JimExprOpBin, LAZY_NONE}, | |
| 12895 | + OPRINIT("sin", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12896 | + OPRINIT("cos", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12897 | + OPRINIT("tan", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12898 | + OPRINIT("asin", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12899 | + OPRINIT("acos", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12900 | + OPRINIT("atan", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12901 | + OPRINIT("sinh", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12902 | + OPRINIT("cosh", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12903 | + OPRINIT("tanh", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12904 | + OPRINIT("ceil", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12905 | + OPRINIT("floor", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12906 | + OPRINIT("exp", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12907 | + OPRINIT("log", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12908 | + OPRINIT("log10", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12909 | + OPRINIT("sqrt", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), | |
| 12910 | + OPRINIT("pow", 200, 2, JimExprOpBin, LAZY_NONE), | |
| 12860 | 12911 | #endif |
| 12861 | 12912 | }; |
| 12913 | +#undef OPRINIT | |
| 12862 | 12914 | |
| 12863 | 12915 | #define JIM_EXPR_OPERATORS_NUM \ |
| 12864 | 12916 | (sizeof(Jim_ExprOperators)/sizeof(struct Jim_ExprOperator)) |
| 12865 | 12917 | |
| 12866 | 12918 | static int JimParseExpression(struct JimParserCtx *pc) |
| @@ -13026,20 +13078,18 @@ | ||
| 13026 | 13078 | int i; |
| 13027 | 13079 | int bestIdx = -1, bestLen = 0; |
| 13028 | 13080 | |
| 13029 | 13081 | |
| 13030 | 13082 | for (i = 0; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) { |
| 13031 | - const char *opname; | |
| 13032 | - int oplen; | |
| 13083 | + const char * const opname = Jim_ExprOperators[i].name; | |
| 13084 | + const int oplen = Jim_ExprOperators[i].namelen; | |
| 13033 | 13085 | |
| 13034 | - opname = Jim_ExprOperators[i].name; | |
| 13035 | - if (opname == NULL) { | |
| 13086 | + if (opname == NULL || opname[0] != pc->p[0]) { | |
| 13036 | 13087 | continue; |
| 13037 | 13088 | } |
| 13038 | - oplen = strlen(opname); | |
| 13039 | 13089 | |
| 13040 | - if (strncmp(opname, pc->p, oplen) == 0 && oplen > bestLen) { | |
| 13090 | + if (oplen > bestLen && strncmp(opname, pc->p, oplen) == 0) { | |
| 13041 | 13091 | bestIdx = i + JIM_TT_EXPR_OP; |
| 13042 | 13092 | bestLen = oplen; |
| 13043 | 13093 | } |
| 13044 | 13094 | } |
| 13045 | 13095 | if (bestIdx == -1) { |
| @@ -13111,12 +13161,12 @@ | ||
| 13111 | 13161 | }; |
| 13112 | 13162 | |
| 13113 | 13163 | |
| 13114 | 13164 | typedef struct ExprByteCode |
| 13115 | 13165 | { |
| 13116 | - int len; | |
| 13117 | 13166 | ScriptToken *token; |
| 13167 | + int len; | |
| 13118 | 13168 | int inUse; |
| 13119 | 13169 | } ExprByteCode; |
| 13120 | 13170 | |
| 13121 | 13171 | static void ExprFreeByteCode(Jim_Interp *interp, ExprByteCode * expr) |
| 13122 | 13172 | { |
| @@ -13855,16 +13905,16 @@ | ||
| 13855 | 13905 | |
| 13856 | 13906 | |
| 13857 | 13907 | |
| 13858 | 13908 | typedef struct ScanFmtPartDescr |
| 13859 | 13909 | { |
| 13860 | - char type; | |
| 13861 | - char modifier; | |
| 13910 | + char *arg; | |
| 13911 | + char *prefix; | |
| 13862 | 13912 | size_t width; |
| 13863 | 13913 | int pos; |
| 13864 | - char *arg; | |
| 13865 | - char *prefix; | |
| 13914 | + char type; | |
| 13915 | + char modifier; | |
| 13866 | 13916 | } ScanFmtPartDescr; |
| 13867 | 13917 | |
| 13868 | 13918 | |
| 13869 | 13919 | typedef struct ScanFmtStringObj |
| 13870 | 13920 | { |
| @@ -14871,12 +14921,12 @@ | ||
| 14871 | 14921 | } |
| 14872 | 14922 | |
| 14873 | 14923 | if (retcode == JIM_OK && argc) { |
| 14874 | 14924 | |
| 14875 | 14925 | retcode = JimInvokeCommand(interp, argc, argv); |
| 14876 | - if (interp->signal_level && interp->sigmask) { | |
| 14877 | - | |
| 14926 | + | |
| 14927 | + if (Jim_CheckSignal(interp)) { | |
| 14878 | 14928 | retcode = JIM_SIGNAL; |
| 14879 | 14929 | } |
| 14880 | 14930 | } |
| 14881 | 14931 | |
| 14882 | 14932 | |
| @@ -15446,17 +15496,17 @@ | ||
| 15446 | 15496 | if (he) { |
| 15447 | 15497 | callback(interp, listObjPtr, he, type); |
| 15448 | 15498 | } |
| 15449 | 15499 | } |
| 15450 | 15500 | else { |
| 15451 | - Jim_HashTableIterator *htiter = Jim_GetHashTableIterator(ht); | |
| 15452 | - while ((he = Jim_NextHashEntry(htiter)) != NULL) { | |
| 15501 | + Jim_HashTableIterator htiter; | |
| 15502 | + JimInitHashTableIterator(ht, &htiter); | |
| 15503 | + while ((he = Jim_NextHashEntry(&htiter)) != NULL) { | |
| 15453 | 15504 | if (patternObjPtr == NULL || JimGlobMatch(Jim_String(patternObjPtr), he->key, 0)) { |
| 15454 | 15505 | callback(interp, listObjPtr, he, type); |
| 15455 | 15506 | } |
| 15456 | 15507 | } |
| 15457 | - Jim_FreeHashTableIterator(htiter); | |
| 15458 | 15508 | } |
| 15459 | 15509 | return listObjPtr; |
| 15460 | 15510 | } |
| 15461 | 15511 | |
| 15462 | 15512 | |
| @@ -17795,11 +17845,11 @@ | ||
| 17795 | 17845 | if ((ignore_mask & (1 << JIM_SIGNAL)) == 0) { |
| 17796 | 17846 | sig++; |
| 17797 | 17847 | } |
| 17798 | 17848 | |
| 17799 | 17849 | interp->signal_level += sig; |
| 17800 | - if (interp->signal_level && interp->sigmask) { | |
| 17850 | + if (Jim_CheckSignal(interp)) { | |
| 17801 | 17851 | |
| 17802 | 17852 | exitCode = JIM_SIGNAL; |
| 17803 | 17853 | } |
| 17804 | 17854 | else { |
| 17805 | 17855 | exitCode = Jim_EvalObj(interp, argv[0]); |
| @@ -17951,25 +18001,24 @@ | ||
| 17951 | 18001 | |
| 17952 | 18002 | |
| 17953 | 18003 | static int JimInfoReferences(Jim_Interp *interp, int argc, Jim_Obj *const *argv) |
| 17954 | 18004 | { |
| 17955 | 18005 | Jim_Obj *listObjPtr; |
| 17956 | - Jim_HashTableIterator *htiter; | |
| 18006 | + Jim_HashTableIterator htiter; | |
| 17957 | 18007 | Jim_HashEntry *he; |
| 17958 | 18008 | |
| 17959 | 18009 | listObjPtr = Jim_NewListObj(interp, NULL, 0); |
| 17960 | 18010 | |
| 17961 | - htiter = Jim_GetHashTableIterator(&interp->references); | |
| 17962 | - while ((he = Jim_NextHashEntry(htiter)) != NULL) { | |
| 18011 | + JimInitHashTableIterator(&interp->references, &htiter); | |
| 18012 | + while ((he = Jim_NextHashEntry(&htiter)) != NULL) { | |
| 17963 | 18013 | char buf[JIM_REFERENCE_SPACE + 1]; |
| 17964 | 18014 | Jim_Reference *refPtr = he->u.val; |
| 17965 | 18015 | const unsigned long *refId = he->key; |
| 17966 | 18016 | |
| 17967 | 18017 | JimFormatReference(buf, refPtr, *refId); |
| 17968 | 18018 | Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, buf, -1)); |
| 17969 | 18019 | } |
| 17970 | - Jim_FreeHashTableIterator(htiter); | |
| 17971 | 18020 | Jim_SetResult(interp, listObjPtr); |
| 17972 | 18021 | return JIM_OK; |
| 17973 | 18022 | } |
| 17974 | 18023 | #endif |
| 17975 | 18024 | |
| @@ -18005,17 +18054,17 @@ | ||
| 18005 | 18054 | { |
| 18006 | 18055 | Jim_HashEntry *he; |
| 18007 | 18056 | Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0); |
| 18008 | 18057 | |
| 18009 | 18058 | |
| 18010 | - Jim_HashTableIterator *htiter = Jim_GetHashTableIterator(ht); | |
| 18011 | - while ((he = Jim_NextHashEntry(htiter)) != NULL) { | |
| 18059 | + Jim_HashTableIterator htiter; | |
| 18060 | + JimInitHashTableIterator(ht, &htiter); | |
| 18061 | + while ((he = Jim_NextHashEntry(&htiter)) != NULL) { | |
| 18012 | 18062 | if (patternObjPtr == NULL || JimGlobMatch(Jim_String(patternObjPtr), Jim_String((Jim_Obj *)he->key), 0)) { |
| 18013 | 18063 | callback(interp, listObjPtr, he, type); |
| 18014 | 18064 | } |
| 18015 | 18065 | } |
| 18016 | - Jim_FreeHashTableIterator(htiter); | |
| 18017 | 18066 | |
| 18018 | 18067 | return listObjPtr; |
| 18019 | 18068 | } |
| 18020 | 18069 | |
| 18021 | 18070 | |
| 18022 | 18071 |
| --- autosetup/jimsh0.c | |
| +++ autosetup/jimsh0.c | |
| @@ -185,11 +185,11 @@ | |
| 185 | #endif |
| 186 | |
| 187 | #define UCHAR(c) ((unsigned char)(c)) |
| 188 | |
| 189 | |
| 190 | #define JIM_VERSION 73 |
| 191 | |
| 192 | #define JIM_OK 0 |
| 193 | #define JIM_ERR 1 |
| 194 | #define JIM_RETURN 2 |
| 195 | #define JIM_BREAK 3 |
| @@ -321,14 +321,14 @@ | |
| 321 | #define Jim_GetHashTableSize(ht) ((ht)->size) |
| 322 | #define Jim_GetHashTableUsed(ht) ((ht)->used) |
| 323 | |
| 324 | |
| 325 | typedef struct Jim_Obj { |
| 326 | int refCount; |
| 327 | char *bytes; |
| 328 | int length; |
| 329 | const struct Jim_ObjType *typePtr; |
| 330 | |
| 331 | union { |
| 332 | |
| 333 | jim_wide wideValue; |
| 334 | |
| @@ -665,12 +665,10 @@ | |
| 665 | |
| 666 | |
| 667 | JIM_EXPORT Jim_Obj * Jim_NewObj (Jim_Interp *interp); |
| 668 | JIM_EXPORT void Jim_FreeObj (Jim_Interp *interp, Jim_Obj *objPtr); |
| 669 | JIM_EXPORT void Jim_InvalidateStringRep (Jim_Obj *objPtr); |
| 670 | JIM_EXPORT void Jim_InitStringRep (Jim_Obj *objPtr, const char *bytes, |
| 671 | int length); |
| 672 | JIM_EXPORT Jim_Obj * Jim_DuplicateObj (Jim_Interp *interp, |
| 673 | Jim_Obj *objPtr); |
| 674 | JIM_EXPORT const char * Jim_GetString(Jim_Obj *objPtr, |
| 675 | int *lenPtr); |
| 676 | JIM_EXPORT const char *Jim_String(Jim_Obj *objPtr); |
| @@ -877,10 +875,12 @@ | |
| 877 | JIM_EXPORT void Jim_HistoryShow(void); |
| 878 | |
| 879 | |
| 880 | JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp); |
| 881 | JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base); |
| 882 | |
| 883 | |
| 884 | JIM_EXPORT int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName); |
| 885 | JIM_EXPORT void Jim_FreeLoadHandles(Jim_Interp *interp); |
| 886 | |
| @@ -5671,10 +5671,13 @@ | |
| 5671 | #ifdef JIM_MAINTAINER |
| 5672 | #define JIM_DEBUG_COMMAND |
| 5673 | #define JIM_DEBUG_PANIC |
| 5674 | #endif |
| 5675 | |
| 5676 | const char *jim_tt_name(int type); |
| 5677 | |
| 5678 | #ifdef JIM_DEBUG_PANIC |
| 5679 | static void JimPanicDump(int panic_condition, const char *fmt, ...); |
| 5680 | #define JimPanic(X) JimPanicDump X |
| @@ -5690,10 +5693,11 @@ | |
| 5690 | static int ListSetIndex(Jim_Interp *interp, Jim_Obj *listPtr, int listindex, Jim_Obj *newObjPtr, |
| 5691 | int flags); |
| 5692 | static int JimDeleteLocalProcs(Jim_Interp *interp, Jim_Stack *localCommands); |
| 5693 | static Jim_Obj *JimExpandDictSugar(Jim_Interp *interp, Jim_Obj *objPtr); |
| 5694 | static void SetDictSubstFromAny(Jim_Interp *interp, Jim_Obj *objPtr); |
| 5695 | static void JimSetFailedEnumResult(Jim_Interp *interp, const char *arg, const char *badtype, |
| 5696 | const char *prefix, const char *const *tablePtr, const char *name); |
| 5697 | static int JimCallProcedure(Jim_Interp *interp, Jim_Cmd *cmd, int argc, Jim_Obj *const *argv); |
| 5698 | static int JimGetWideNoErr(Jim_Interp *interp, Jim_Obj *objPtr, jim_wide * widePtr); |
| 5699 | static int JimSign(jim_wide w); |
| @@ -5934,15 +5938,42 @@ | |
| 5934 | } |
| 5935 | return n; |
| 5936 | } |
| 5937 | #endif |
| 5938 | |
| 5939 | int Jim_WideToString(char *buf, jim_wide wideValue) |
| 5940 | { |
| 5941 | const char *fmt = "%" JIM_WIDE_MODIFIER; |
| 5942 | |
| 5943 | return sprintf(buf, fmt, wideValue); |
| 5944 | } |
| 5945 | |
| 5946 | static int JimCheckConversion(const char *str, const char *endptr) |
| 5947 | { |
| 5948 | if (str[0] == '\0' || str == endptr) { |
| @@ -6229,10 +6260,18 @@ | |
| 6229 | ht->sizemask = 0; |
| 6230 | ht->used = 0; |
| 6231 | ht->collisions = 0; |
| 6232 | } |
| 6233 | |
| 6234 | |
| 6235 | int Jim_InitHashTable(Jim_HashTable *ht, const Jim_HashTableType *type, void *privDataPtr) |
| 6236 | { |
| 6237 | JimResetHashTable(ht); |
| 6238 | ht->type = type; |
| @@ -6408,15 +6447,11 @@ | |
| 6408 | } |
| 6409 | |
| 6410 | Jim_HashTableIterator *Jim_GetHashTableIterator(Jim_HashTable *ht) |
| 6411 | { |
| 6412 | Jim_HashTableIterator *iter = Jim_Alloc(sizeof(*iter)); |
| 6413 | |
| 6414 | iter->ht = ht; |
| 6415 | iter->index = -1; |
| 6416 | iter->entry = NULL; |
| 6417 | iter->nextEntry = NULL; |
| 6418 | return iter; |
| 6419 | } |
| 6420 | |
| 6421 | Jim_HashEntry *Jim_NextHashEntry(Jim_HashTableIterator *iter) |
| 6422 | { |
| @@ -10500,12 +10535,10 @@ | |
| 10500 | int Jim_GetExitCode(Jim_Interp *interp) |
| 10501 | { |
| 10502 | return interp->exitCode; |
| 10503 | } |
| 10504 | |
| 10505 | #define JIM_INTEGER_SPACE 24 |
| 10506 | |
| 10507 | static void UpdateStringOfInt(struct Jim_Obj *objPtr); |
| 10508 | static int SetIntFromAny(Jim_Interp *interp, Jim_Obj *objPtr, int flags); |
| 10509 | |
| 10510 | static const Jim_ObjType intObjType = { |
| 10511 | "int", |
| @@ -10522,16 +10555,16 @@ | |
| 10522 | UpdateStringOfInt, |
| 10523 | JIM_TYPE_NONE, |
| 10524 | }; |
| 10525 | |
| 10526 | |
| 10527 | void UpdateStringOfInt(struct Jim_Obj *objPtr) |
| 10528 | { |
| 10529 | int len; |
| 10530 | char buf[JIM_INTEGER_SPACE + 1]; |
| 10531 | |
| 10532 | len = Jim_WideToString(buf, JimWideValue(objPtr)); |
| 10533 | objPtr->bytes = Jim_Alloc(len + 1); |
| 10534 | memcpy(objPtr->bytes, buf, len + 1); |
| 10535 | objPtr->length = len; |
| 10536 | } |
| 10537 | |
| @@ -10755,11 +10788,11 @@ | |
| 10755 | } |
| 10756 | |
| 10757 | #define JIM_ELESTR_SIMPLE 0 |
| 10758 | #define JIM_ELESTR_BRACE 1 |
| 10759 | #define JIM_ELESTR_QUOTE 2 |
| 10760 | static int ListElementQuotingType(const char *s, int len) |
| 10761 | { |
| 10762 | int i, level, blevel, trySimple = 1; |
| 10763 | |
| 10764 | |
| 10765 | if (len == 0) |
| @@ -10903,17 +10936,23 @@ | |
| 10903 | return p - q; |
| 10904 | } |
| 10905 | |
| 10906 | static void JimMakeListStringRep(Jim_Obj *objPtr, Jim_Obj **objv, int objc) |
| 10907 | { |
| 10908 | int i, bufLen, realLength; |
| 10909 | const char *strRep; |
| 10910 | char *p; |
| 10911 | int *quotingType; |
| 10912 | |
| 10913 | |
| 10914 | quotingType = Jim_Alloc(sizeof(int) * objc + 1); |
| 10915 | bufLen = 0; |
| 10916 | for (i = 0; i < objc; i++) { |
| 10917 | int len; |
| 10918 | |
| 10919 | strRep = Jim_GetString(objv[i], &len); |
| @@ -10975,11 +11014,14 @@ | |
| 10975 | realLength++; |
| 10976 | } |
| 10977 | } |
| 10978 | *p = '\0'; |
| 10979 | objPtr->length = realLength; |
| 10980 | Jim_Free(quotingType); |
| 10981 | } |
| 10982 | |
| 10983 | static void UpdateStringOfList(struct Jim_Obj *objPtr) |
| 10984 | { |
| 10985 | JimMakeListStringRep(objPtr, objPtr->internalRep.listValue.ele, objPtr->internalRep.listValue.len); |
| @@ -11000,11 +11042,11 @@ | |
| 11000 | if (Jim_IsDict(objPtr) && !Jim_IsShared(objPtr)) { |
| 11001 | Jim_Obj **listObjPtrPtr; |
| 11002 | int len; |
| 11003 | int i; |
| 11004 | |
| 11005 | Jim_DictPairs(interp, objPtr, &listObjPtrPtr, &len); |
| 11006 | for (i = 0; i < len; i++) { |
| 11007 | Jim_IncrRefCount(listObjPtrPtr[i]); |
| 11008 | } |
| 11009 | |
| 11010 | |
| @@ -11225,14 +11267,22 @@ | |
| 11225 | int requiredLen = currentLen + elemc; |
| 11226 | int i; |
| 11227 | Jim_Obj **point; |
| 11228 | |
| 11229 | if (requiredLen > listPtr->internalRep.listValue.maxLen) { |
| 11230 | listPtr->internalRep.listValue.maxLen = requiredLen * 2; |
| 11231 | |
| 11232 | listPtr->internalRep.listValue.ele = Jim_Realloc(listPtr->internalRep.listValue.ele, |
| 11233 | sizeof(Jim_Obj *) * listPtr->internalRep.listValue.maxLen); |
| 11234 | } |
| 11235 | if (idx < 0) { |
| 11236 | idx = currentLen; |
| 11237 | } |
| 11238 | point = listPtr->internalRep.listValue.ele + idx; |
| @@ -11523,55 +11573,53 @@ | |
| 11523 | } |
| 11524 | |
| 11525 | void DupDictInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr) |
| 11526 | { |
| 11527 | Jim_HashTable *ht, *dupHt; |
| 11528 | Jim_HashTableIterator *htiter; |
| 11529 | Jim_HashEntry *he; |
| 11530 | |
| 11531 | |
| 11532 | ht = srcPtr->internalRep.ptr; |
| 11533 | dupHt = Jim_Alloc(sizeof(*dupHt)); |
| 11534 | Jim_InitHashTable(dupHt, &JimDictHashTableType, interp); |
| 11535 | if (ht->size != 0) |
| 11536 | Jim_ExpandHashTable(dupHt, ht->size); |
| 11537 | |
| 11538 | htiter = Jim_GetHashTableIterator(ht); |
| 11539 | while ((he = Jim_NextHashEntry(htiter)) != NULL) { |
| 11540 | const Jim_Obj *keyObjPtr = he->key; |
| 11541 | Jim_Obj *valObjPtr = he->u.val; |
| 11542 | |
| 11543 | Jim_IncrRefCount((Jim_Obj *)keyObjPtr); |
| 11544 | Jim_IncrRefCount(valObjPtr); |
| 11545 | Jim_AddHashEntry(dupHt, keyObjPtr, valObjPtr); |
| 11546 | } |
| 11547 | Jim_FreeHashTableIterator(htiter); |
| 11548 | |
| 11549 | dupPtr->internalRep.ptr = dupHt; |
| 11550 | dupPtr->typePtr = &dictObjType; |
| 11551 | } |
| 11552 | |
| 11553 | static Jim_Obj **JimDictPairs(Jim_Obj *dictPtr, int *len) |
| 11554 | { |
| 11555 | Jim_HashTable *ht; |
| 11556 | Jim_HashTableIterator *htiter; |
| 11557 | Jim_HashEntry *he; |
| 11558 | Jim_Obj **objv; |
| 11559 | int i; |
| 11560 | |
| 11561 | ht = dictPtr->internalRep.ptr; |
| 11562 | |
| 11563 | |
| 11564 | objv = Jim_Alloc((ht->used * 2) * sizeof(Jim_Obj *)); |
| 11565 | htiter = Jim_GetHashTableIterator(ht); |
| 11566 | i = 0; |
| 11567 | while ((he = Jim_NextHashEntry(htiter)) != NULL) { |
| 11568 | objv[i++] = (Jim_Obj *)he->key; |
| 11569 | objv[i++] = he->u.val; |
| 11570 | } |
| 11571 | *len = i; |
| 11572 | Jim_FreeHashTableIterator(htiter); |
| 11573 | return objv; |
| 11574 | } |
| 11575 | |
| 11576 | static void UpdateStringOfDict(struct Jim_Obj *objPtr) |
| 11577 | { |
| @@ -12089,14 +12137,15 @@ | |
| 12089 | |
| 12090 | |
| 12091 | typedef struct Jim_ExprOperator |
| 12092 | { |
| 12093 | const char *name; |
| 12094 | int precedence; |
| 12095 | int arity; |
| 12096 | int (*funcop) (Jim_Interp *interp, struct JimExprState * e); |
| 12097 | int lazy; |
| 12098 | } Jim_ExprOperator; |
| 12099 | |
| 12100 | static void ExprPush(struct JimExprState *e, Jim_Obj *obj) |
| 12101 | { |
| 12102 | Jim_IncrRefCount(obj); |
| @@ -12774,93 +12823,96 @@ | |
| 12774 | LAZY_OP, |
| 12775 | LAZY_LEFT, |
| 12776 | LAZY_RIGHT |
| 12777 | }; |
| 12778 | |
| 12779 | static const struct Jim_ExprOperator Jim_ExprOperators[] = { |
| 12780 | {"*", 200, 2, JimExprOpBin, LAZY_NONE}, |
| 12781 | {"/", 200, 2, JimExprOpBin, LAZY_NONE}, |
| 12782 | {"%", 200, 2, JimExprOpIntBin, LAZY_NONE}, |
| 12783 | |
| 12784 | {"-", 100, 2, JimExprOpBin, LAZY_NONE}, |
| 12785 | {"+", 100, 2, JimExprOpBin, LAZY_NONE}, |
| 12786 | |
| 12787 | {"<<", 90, 2, JimExprOpIntBin, LAZY_NONE}, |
| 12788 | {">>", 90, 2, JimExprOpIntBin, LAZY_NONE}, |
| 12789 | |
| 12790 | {"<<<", 90, 2, JimExprOpIntBin, LAZY_NONE}, |
| 12791 | {">>>", 90, 2, JimExprOpIntBin, LAZY_NONE}, |
| 12792 | |
| 12793 | {"<", 80, 2, JimExprOpBin, LAZY_NONE}, |
| 12794 | {">", 80, 2, JimExprOpBin, LAZY_NONE}, |
| 12795 | {"<=", 80, 2, JimExprOpBin, LAZY_NONE}, |
| 12796 | {">=", 80, 2, JimExprOpBin, LAZY_NONE}, |
| 12797 | |
| 12798 | {"==", 70, 2, JimExprOpBin, LAZY_NONE}, |
| 12799 | {"!=", 70, 2, JimExprOpBin, LAZY_NONE}, |
| 12800 | |
| 12801 | {"&", 50, 2, JimExprOpIntBin, LAZY_NONE}, |
| 12802 | {"^", 49, 2, JimExprOpIntBin, LAZY_NONE}, |
| 12803 | {"|", 48, 2, JimExprOpIntBin, LAZY_NONE}, |
| 12804 | |
| 12805 | {"&&", 10, 2, NULL, LAZY_OP}, |
| 12806 | {NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT}, |
| 12807 | {NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT}, |
| 12808 | |
| 12809 | {"||", 9, 2, NULL, LAZY_OP}, |
| 12810 | {NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT}, |
| 12811 | {NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT}, |
| 12812 | |
| 12813 | {"?", 5, 2, JimExprOpNull, LAZY_OP}, |
| 12814 | {NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT}, |
| 12815 | {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT}, |
| 12816 | |
| 12817 | {":", 5, 2, JimExprOpNull, LAZY_OP}, |
| 12818 | {NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT}, |
| 12819 | {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT}, |
| 12820 | |
| 12821 | {"**", 250, 2, JimExprOpBin, LAZY_NONE}, |
| 12822 | |
| 12823 | {"eq", 60, 2, JimExprOpStrBin, LAZY_NONE}, |
| 12824 | {"ne", 60, 2, JimExprOpStrBin, LAZY_NONE}, |
| 12825 | |
| 12826 | {"in", 55, 2, JimExprOpStrBin, LAZY_NONE}, |
| 12827 | {"ni", 55, 2, JimExprOpStrBin, LAZY_NONE}, |
| 12828 | |
| 12829 | {"!", 300, 1, JimExprOpNumUnary, LAZY_NONE}, |
| 12830 | {"~", 300, 1, JimExprOpIntUnary, LAZY_NONE}, |
| 12831 | {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE}, |
| 12832 | {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE}, |
| 12833 | |
| 12834 | |
| 12835 | |
| 12836 | {"int", 400, 1, JimExprOpNumUnary, LAZY_NONE}, |
| 12837 | {"abs", 400, 1, JimExprOpNumUnary, LAZY_NONE}, |
| 12838 | {"double", 400, 1, JimExprOpNumUnary, LAZY_NONE}, |
| 12839 | {"round", 400, 1, JimExprOpNumUnary, LAZY_NONE}, |
| 12840 | {"rand", 400, 0, JimExprOpNone, LAZY_NONE}, |
| 12841 | {"srand", 400, 1, JimExprOpIntUnary, LAZY_NONE}, |
| 12842 | |
| 12843 | #ifdef JIM_MATH_FUNCTIONS |
| 12844 | {"sin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12845 | {"cos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12846 | {"tan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12847 | {"asin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12848 | {"acos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12849 | {"atan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12850 | {"sinh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12851 | {"cosh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12852 | {"tanh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12853 | {"ceil", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12854 | {"floor", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12855 | {"exp", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12856 | {"log", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12857 | {"log10", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12858 | {"sqrt", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, |
| 12859 | {"pow", 400, 2, JimExprOpBin, LAZY_NONE}, |
| 12860 | #endif |
| 12861 | }; |
| 12862 | |
| 12863 | #define JIM_EXPR_OPERATORS_NUM \ |
| 12864 | (sizeof(Jim_ExprOperators)/sizeof(struct Jim_ExprOperator)) |
| 12865 | |
| 12866 | static int JimParseExpression(struct JimParserCtx *pc) |
| @@ -13026,20 +13078,18 @@ | |
| 13026 | int i; |
| 13027 | int bestIdx = -1, bestLen = 0; |
| 13028 | |
| 13029 | |
| 13030 | for (i = 0; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) { |
| 13031 | const char *opname; |
| 13032 | int oplen; |
| 13033 | |
| 13034 | opname = Jim_ExprOperators[i].name; |
| 13035 | if (opname == NULL) { |
| 13036 | continue; |
| 13037 | } |
| 13038 | oplen = strlen(opname); |
| 13039 | |
| 13040 | if (strncmp(opname, pc->p, oplen) == 0 && oplen > bestLen) { |
| 13041 | bestIdx = i + JIM_TT_EXPR_OP; |
| 13042 | bestLen = oplen; |
| 13043 | } |
| 13044 | } |
| 13045 | if (bestIdx == -1) { |
| @@ -13111,12 +13161,12 @@ | |
| 13111 | }; |
| 13112 | |
| 13113 | |
| 13114 | typedef struct ExprByteCode |
| 13115 | { |
| 13116 | int len; |
| 13117 | ScriptToken *token; |
| 13118 | int inUse; |
| 13119 | } ExprByteCode; |
| 13120 | |
| 13121 | static void ExprFreeByteCode(Jim_Interp *interp, ExprByteCode * expr) |
| 13122 | { |
| @@ -13855,16 +13905,16 @@ | |
| 13855 | |
| 13856 | |
| 13857 | |
| 13858 | typedef struct ScanFmtPartDescr |
| 13859 | { |
| 13860 | char type; |
| 13861 | char modifier; |
| 13862 | size_t width; |
| 13863 | int pos; |
| 13864 | char *arg; |
| 13865 | char *prefix; |
| 13866 | } ScanFmtPartDescr; |
| 13867 | |
| 13868 | |
| 13869 | typedef struct ScanFmtStringObj |
| 13870 | { |
| @@ -14871,12 +14921,12 @@ | |
| 14871 | } |
| 14872 | |
| 14873 | if (retcode == JIM_OK && argc) { |
| 14874 | |
| 14875 | retcode = JimInvokeCommand(interp, argc, argv); |
| 14876 | if (interp->signal_level && interp->sigmask) { |
| 14877 | |
| 14878 | retcode = JIM_SIGNAL; |
| 14879 | } |
| 14880 | } |
| 14881 | |
| 14882 | |
| @@ -15446,17 +15496,17 @@ | |
| 15446 | if (he) { |
| 15447 | callback(interp, listObjPtr, he, type); |
| 15448 | } |
| 15449 | } |
| 15450 | else { |
| 15451 | Jim_HashTableIterator *htiter = Jim_GetHashTableIterator(ht); |
| 15452 | while ((he = Jim_NextHashEntry(htiter)) != NULL) { |
| 15453 | if (patternObjPtr == NULL || JimGlobMatch(Jim_String(patternObjPtr), he->key, 0)) { |
| 15454 | callback(interp, listObjPtr, he, type); |
| 15455 | } |
| 15456 | } |
| 15457 | Jim_FreeHashTableIterator(htiter); |
| 15458 | } |
| 15459 | return listObjPtr; |
| 15460 | } |
| 15461 | |
| 15462 | |
| @@ -17795,11 +17845,11 @@ | |
| 17795 | if ((ignore_mask & (1 << JIM_SIGNAL)) == 0) { |
| 17796 | sig++; |
| 17797 | } |
| 17798 | |
| 17799 | interp->signal_level += sig; |
| 17800 | if (interp->signal_level && interp->sigmask) { |
| 17801 | |
| 17802 | exitCode = JIM_SIGNAL; |
| 17803 | } |
| 17804 | else { |
| 17805 | exitCode = Jim_EvalObj(interp, argv[0]); |
| @@ -17951,25 +18001,24 @@ | |
| 17951 | |
| 17952 | |
| 17953 | static int JimInfoReferences(Jim_Interp *interp, int argc, Jim_Obj *const *argv) |
| 17954 | { |
| 17955 | Jim_Obj *listObjPtr; |
| 17956 | Jim_HashTableIterator *htiter; |
| 17957 | Jim_HashEntry *he; |
| 17958 | |
| 17959 | listObjPtr = Jim_NewListObj(interp, NULL, 0); |
| 17960 | |
| 17961 | htiter = Jim_GetHashTableIterator(&interp->references); |
| 17962 | while ((he = Jim_NextHashEntry(htiter)) != NULL) { |
| 17963 | char buf[JIM_REFERENCE_SPACE + 1]; |
| 17964 | Jim_Reference *refPtr = he->u.val; |
| 17965 | const unsigned long *refId = he->key; |
| 17966 | |
| 17967 | JimFormatReference(buf, refPtr, *refId); |
| 17968 | Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, buf, -1)); |
| 17969 | } |
| 17970 | Jim_FreeHashTableIterator(htiter); |
| 17971 | Jim_SetResult(interp, listObjPtr); |
| 17972 | return JIM_OK; |
| 17973 | } |
| 17974 | #endif |
| 17975 | |
| @@ -18005,17 +18054,17 @@ | |
| 18005 | { |
| 18006 | Jim_HashEntry *he; |
| 18007 | Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0); |
| 18008 | |
| 18009 | |
| 18010 | Jim_HashTableIterator *htiter = Jim_GetHashTableIterator(ht); |
| 18011 | while ((he = Jim_NextHashEntry(htiter)) != NULL) { |
| 18012 | if (patternObjPtr == NULL || JimGlobMatch(Jim_String(patternObjPtr), Jim_String((Jim_Obj *)he->key), 0)) { |
| 18013 | callback(interp, listObjPtr, he, type); |
| 18014 | } |
| 18015 | } |
| 18016 | Jim_FreeHashTableIterator(htiter); |
| 18017 | |
| 18018 | return listObjPtr; |
| 18019 | } |
| 18020 | |
| 18021 | |
| 18022 |
| --- autosetup/jimsh0.c | |
| +++ autosetup/jimsh0.c | |
| @@ -185,11 +185,11 @@ | |
| 185 | #endif |
| 186 | |
| 187 | #define UCHAR(c) ((unsigned char)(c)) |
| 188 | |
| 189 | |
| 190 | #define JIM_VERSION 74 |
| 191 | |
| 192 | #define JIM_OK 0 |
| 193 | #define JIM_ERR 1 |
| 194 | #define JIM_RETURN 2 |
| 195 | #define JIM_BREAK 3 |
| @@ -321,14 +321,14 @@ | |
| 321 | #define Jim_GetHashTableSize(ht) ((ht)->size) |
| 322 | #define Jim_GetHashTableUsed(ht) ((ht)->used) |
| 323 | |
| 324 | |
| 325 | typedef struct Jim_Obj { |
| 326 | char *bytes; |
| 327 | const struct Jim_ObjType *typePtr; |
| 328 | int refCount; |
| 329 | int length; |
| 330 | |
| 331 | union { |
| 332 | |
| 333 | jim_wide wideValue; |
| 334 | |
| @@ -665,12 +665,10 @@ | |
| 665 | |
| 666 | |
| 667 | JIM_EXPORT Jim_Obj * Jim_NewObj (Jim_Interp *interp); |
| 668 | JIM_EXPORT void Jim_FreeObj (Jim_Interp *interp, Jim_Obj *objPtr); |
| 669 | JIM_EXPORT void Jim_InvalidateStringRep (Jim_Obj *objPtr); |
| 670 | JIM_EXPORT Jim_Obj * Jim_DuplicateObj (Jim_Interp *interp, |
| 671 | Jim_Obj *objPtr); |
| 672 | JIM_EXPORT const char * Jim_GetString(Jim_Obj *objPtr, |
| 673 | int *lenPtr); |
| 674 | JIM_EXPORT const char *Jim_String(Jim_Obj *objPtr); |
| @@ -877,10 +875,12 @@ | |
| 875 | JIM_EXPORT void Jim_HistoryShow(void); |
| 876 | |
| 877 | |
| 878 | JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp); |
| 879 | JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base); |
| 880 | JIM_EXPORT int Jim_CheckSignal(Jim_Interp *interp); |
| 881 | #define Jim_CheckSignal(i) ((i)->signal_level && (i)->sigmask) |
| 882 | |
| 883 | |
| 884 | JIM_EXPORT int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName); |
| 885 | JIM_EXPORT void Jim_FreeLoadHandles(Jim_Interp *interp); |
| 886 | |
| @@ -5671,10 +5671,13 @@ | |
| 5671 | #ifdef JIM_MAINTAINER |
| 5672 | #define JIM_DEBUG_COMMAND |
| 5673 | #define JIM_DEBUG_PANIC |
| 5674 | #endif |
| 5675 | |
| 5676 | |
| 5677 | #define JIM_INTEGER_SPACE 24 |
| 5678 | |
| 5679 | const char *jim_tt_name(int type); |
| 5680 | |
| 5681 | #ifdef JIM_DEBUG_PANIC |
| 5682 | static void JimPanicDump(int panic_condition, const char *fmt, ...); |
| 5683 | #define JimPanic(X) JimPanicDump X |
| @@ -5690,10 +5693,11 @@ | |
| 5693 | static int ListSetIndex(Jim_Interp *interp, Jim_Obj *listPtr, int listindex, Jim_Obj *newObjPtr, |
| 5694 | int flags); |
| 5695 | static int JimDeleteLocalProcs(Jim_Interp *interp, Jim_Stack *localCommands); |
| 5696 | static Jim_Obj *JimExpandDictSugar(Jim_Interp *interp, Jim_Obj *objPtr); |
| 5697 | static void SetDictSubstFromAny(Jim_Interp *interp, Jim_Obj *objPtr); |
| 5698 | static Jim_Obj **JimDictPairs(Jim_Obj *dictPtr, int *len); |
| 5699 | static void JimSetFailedEnumResult(Jim_Interp *interp, const char *arg, const char *badtype, |
| 5700 | const char *prefix, const char *const *tablePtr, const char *name); |
| 5701 | static int JimCallProcedure(Jim_Interp *interp, Jim_Cmd *cmd, int argc, Jim_Obj *const *argv); |
| 5702 | static int JimGetWideNoErr(Jim_Interp *interp, Jim_Obj *objPtr, jim_wide * widePtr); |
| 5703 | static int JimSign(jim_wide w); |
| @@ -5934,15 +5938,42 @@ | |
| 5938 | } |
| 5939 | return n; |
| 5940 | } |
| 5941 | #endif |
| 5942 | |
| 5943 | static int JimWideToString(char *buf, jim_wide wideValue) |
| 5944 | { |
| 5945 | int pos = 0; |
| 5946 | |
| 5947 | if (wideValue == 0) { |
| 5948 | buf[pos++] = '0'; |
| 5949 | } |
| 5950 | else { |
| 5951 | char tmp[JIM_INTEGER_SPACE]; |
| 5952 | int num = 0; |
| 5953 | int i; |
| 5954 | |
| 5955 | if (wideValue < 0) { |
| 5956 | buf[pos++] = '-'; |
| 5957 | |
| 5958 | i = wideValue % 10; |
| 5959 | tmp[num++] = (i > 0) ? (10 - i) : -i; |
| 5960 | wideValue /= -10; |
| 5961 | } |
| 5962 | |
| 5963 | while (wideValue) { |
| 5964 | tmp[num++] = wideValue % 10; |
| 5965 | wideValue /= 10; |
| 5966 | } |
| 5967 | |
| 5968 | for (i = 0; i < num; i++) { |
| 5969 | buf[pos++] = '0' + tmp[num - i - 1]; |
| 5970 | } |
| 5971 | } |
| 5972 | buf[pos] = 0; |
| 5973 | |
| 5974 | return pos; |
| 5975 | } |
| 5976 | |
| 5977 | static int JimCheckConversion(const char *str, const char *endptr) |
| 5978 | { |
| 5979 | if (str[0] == '\0' || str == endptr) { |
| @@ -6229,10 +6260,18 @@ | |
| 6260 | ht->sizemask = 0; |
| 6261 | ht->used = 0; |
| 6262 | ht->collisions = 0; |
| 6263 | } |
| 6264 | |
| 6265 | static void JimInitHashTableIterator(Jim_HashTable *ht, Jim_HashTableIterator *iter) |
| 6266 | { |
| 6267 | iter->ht = ht; |
| 6268 | iter->index = -1; |
| 6269 | iter->entry = NULL; |
| 6270 | iter->nextEntry = NULL; |
| 6271 | } |
| 6272 | |
| 6273 | |
| 6274 | int Jim_InitHashTable(Jim_HashTable *ht, const Jim_HashTableType *type, void *privDataPtr) |
| 6275 | { |
| 6276 | JimResetHashTable(ht); |
| 6277 | ht->type = type; |
| @@ -6408,15 +6447,11 @@ | |
| 6447 | } |
| 6448 | |
| 6449 | Jim_HashTableIterator *Jim_GetHashTableIterator(Jim_HashTable *ht) |
| 6450 | { |
| 6451 | Jim_HashTableIterator *iter = Jim_Alloc(sizeof(*iter)); |
| 6452 | JimInitHashTableIterator(ht, iter); |
| 6453 | return iter; |
| 6454 | } |
| 6455 | |
| 6456 | Jim_HashEntry *Jim_NextHashEntry(Jim_HashTableIterator *iter) |
| 6457 | { |
| @@ -10500,12 +10535,10 @@ | |
| 10535 | int Jim_GetExitCode(Jim_Interp *interp) |
| 10536 | { |
| 10537 | return interp->exitCode; |
| 10538 | } |
| 10539 | |
| 10540 | static void UpdateStringOfInt(struct Jim_Obj *objPtr); |
| 10541 | static int SetIntFromAny(Jim_Interp *interp, Jim_Obj *objPtr, int flags); |
| 10542 | |
| 10543 | static const Jim_ObjType intObjType = { |
| 10544 | "int", |
| @@ -10522,16 +10555,16 @@ | |
| 10555 | UpdateStringOfInt, |
| 10556 | JIM_TYPE_NONE, |
| 10557 | }; |
| 10558 | |
| 10559 | |
| 10560 | static void UpdateStringOfInt(struct Jim_Obj *objPtr) |
| 10561 | { |
| 10562 | int len; |
| 10563 | char buf[JIM_INTEGER_SPACE + 1]; |
| 10564 | |
| 10565 | len = JimWideToString(buf, JimWideValue(objPtr)); |
| 10566 | objPtr->bytes = Jim_Alloc(len + 1); |
| 10567 | memcpy(objPtr->bytes, buf, len + 1); |
| 10568 | objPtr->length = len; |
| 10569 | } |
| 10570 | |
| @@ -10755,11 +10788,11 @@ | |
| 10788 | } |
| 10789 | |
| 10790 | #define JIM_ELESTR_SIMPLE 0 |
| 10791 | #define JIM_ELESTR_BRACE 1 |
| 10792 | #define JIM_ELESTR_QUOTE 2 |
| 10793 | static unsigned char ListElementQuotingType(const char *s, int len) |
| 10794 | { |
| 10795 | int i, level, blevel, trySimple = 1; |
| 10796 | |
| 10797 | |
| 10798 | if (len == 0) |
| @@ -10903,17 +10936,23 @@ | |
| 10936 | return p - q; |
| 10937 | } |
| 10938 | |
| 10939 | static void JimMakeListStringRep(Jim_Obj *objPtr, Jim_Obj **objv, int objc) |
| 10940 | { |
| 10941 | #define STATIC_QUOTING_LEN 32 |
| 10942 | int i, bufLen, realLength; |
| 10943 | const char *strRep; |
| 10944 | char *p; |
| 10945 | unsigned char *quotingType, staticQuoting[STATIC_QUOTING_LEN]; |
| 10946 | |
| 10947 | |
| 10948 | if (objc > STATIC_QUOTING_LEN) { |
| 10949 | quotingType = Jim_Alloc(objc); |
| 10950 | } |
| 10951 | else { |
| 10952 | quotingType = staticQuoting; |
| 10953 | } |
| 10954 | bufLen = 0; |
| 10955 | for (i = 0; i < objc; i++) { |
| 10956 | int len; |
| 10957 | |
| 10958 | strRep = Jim_GetString(objv[i], &len); |
| @@ -10975,11 +11014,14 @@ | |
| 11014 | realLength++; |
| 11015 | } |
| 11016 | } |
| 11017 | *p = '\0'; |
| 11018 | objPtr->length = realLength; |
| 11019 | |
| 11020 | if (quotingType != staticQuoting) { |
| 11021 | Jim_Free(quotingType); |
| 11022 | } |
| 11023 | } |
| 11024 | |
| 11025 | static void UpdateStringOfList(struct Jim_Obj *objPtr) |
| 11026 | { |
| 11027 | JimMakeListStringRep(objPtr, objPtr->internalRep.listValue.ele, objPtr->internalRep.listValue.len); |
| @@ -11000,11 +11042,11 @@ | |
| 11042 | if (Jim_IsDict(objPtr) && !Jim_IsShared(objPtr)) { |
| 11043 | Jim_Obj **listObjPtrPtr; |
| 11044 | int len; |
| 11045 | int i; |
| 11046 | |
| 11047 | listObjPtrPtr = JimDictPairs(objPtr, &len); |
| 11048 | for (i = 0; i < len; i++) { |
| 11049 | Jim_IncrRefCount(listObjPtrPtr[i]); |
| 11050 | } |
| 11051 | |
| 11052 | |
| @@ -11225,14 +11267,22 @@ | |
| 11267 | int requiredLen = currentLen + elemc; |
| 11268 | int i; |
| 11269 | Jim_Obj **point; |
| 11270 | |
| 11271 | if (requiredLen > listPtr->internalRep.listValue.maxLen) { |
| 11272 | if (requiredLen < 2) { |
| 11273 | |
| 11274 | requiredLen = 4; |
| 11275 | } |
| 11276 | else { |
| 11277 | requiredLen *= 2; |
| 11278 | } |
| 11279 | |
| 11280 | listPtr->internalRep.listValue.ele = Jim_Realloc(listPtr->internalRep.listValue.ele, |
| 11281 | sizeof(Jim_Obj *) * requiredLen); |
| 11282 | |
| 11283 | listPtr->internalRep.listValue.maxLen = requiredLen; |
| 11284 | } |
| 11285 | if (idx < 0) { |
| 11286 | idx = currentLen; |
| 11287 | } |
| 11288 | point = listPtr->internalRep.listValue.ele + idx; |
| @@ -11523,55 +11573,53 @@ | |
| 11573 | } |
| 11574 | |
| 11575 | void DupDictInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr) |
| 11576 | { |
| 11577 | Jim_HashTable *ht, *dupHt; |
| 11578 | Jim_HashTableIterator htiter; |
| 11579 | Jim_HashEntry *he; |
| 11580 | |
| 11581 | |
| 11582 | ht = srcPtr->internalRep.ptr; |
| 11583 | dupHt = Jim_Alloc(sizeof(*dupHt)); |
| 11584 | Jim_InitHashTable(dupHt, &JimDictHashTableType, interp); |
| 11585 | if (ht->size != 0) |
| 11586 | Jim_ExpandHashTable(dupHt, ht->size); |
| 11587 | |
| 11588 | JimInitHashTableIterator(ht, &htiter); |
| 11589 | while ((he = Jim_NextHashEntry(&htiter)) != NULL) { |
| 11590 | const Jim_Obj *keyObjPtr = he->key; |
| 11591 | Jim_Obj *valObjPtr = he->u.val; |
| 11592 | |
| 11593 | Jim_IncrRefCount((Jim_Obj *)keyObjPtr); |
| 11594 | Jim_IncrRefCount(valObjPtr); |
| 11595 | Jim_AddHashEntry(dupHt, keyObjPtr, valObjPtr); |
| 11596 | } |
| 11597 | |
| 11598 | dupPtr->internalRep.ptr = dupHt; |
| 11599 | dupPtr->typePtr = &dictObjType; |
| 11600 | } |
| 11601 | |
| 11602 | static Jim_Obj **JimDictPairs(Jim_Obj *dictPtr, int *len) |
| 11603 | { |
| 11604 | Jim_HashTable *ht; |
| 11605 | Jim_HashTableIterator htiter; |
| 11606 | Jim_HashEntry *he; |
| 11607 | Jim_Obj **objv; |
| 11608 | int i; |
| 11609 | |
| 11610 | ht = dictPtr->internalRep.ptr; |
| 11611 | |
| 11612 | |
| 11613 | objv = Jim_Alloc((ht->used * 2) * sizeof(Jim_Obj *)); |
| 11614 | JimInitHashTableIterator(ht, &htiter); |
| 11615 | i = 0; |
| 11616 | while ((he = Jim_NextHashEntry(&htiter)) != NULL) { |
| 11617 | objv[i++] = (Jim_Obj *)he->key; |
| 11618 | objv[i++] = he->u.val; |
| 11619 | } |
| 11620 | *len = i; |
| 11621 | return objv; |
| 11622 | } |
| 11623 | |
| 11624 | static void UpdateStringOfDict(struct Jim_Obj *objPtr) |
| 11625 | { |
| @@ -12089,14 +12137,15 @@ | |
| 12137 | |
| 12138 | |
| 12139 | typedef struct Jim_ExprOperator |
| 12140 | { |
| 12141 | const char *name; |
| 12142 | int (*funcop) (Jim_Interp *interp, struct JimExprState * e); |
| 12143 | unsigned char precedence; |
| 12144 | unsigned char arity; |
| 12145 | unsigned char lazy; |
| 12146 | unsigned char namelen; |
| 12147 | } Jim_ExprOperator; |
| 12148 | |
| 12149 | static void ExprPush(struct JimExprState *e, Jim_Obj *obj) |
| 12150 | { |
| 12151 | Jim_IncrRefCount(obj); |
| @@ -12774,93 +12823,96 @@ | |
| 12823 | LAZY_OP, |
| 12824 | LAZY_LEFT, |
| 12825 | LAZY_RIGHT |
| 12826 | }; |
| 12827 | |
| 12828 | #define OPRINIT(N, P, A, F, L) {N, F, P, A, L, sizeof(N) - 1} |
| 12829 | |
| 12830 | static const struct Jim_ExprOperator Jim_ExprOperators[] = { |
| 12831 | OPRINIT("*", 110, 2, JimExprOpBin, LAZY_NONE), |
| 12832 | OPRINIT("/", 110, 2, JimExprOpBin, LAZY_NONE), |
| 12833 | OPRINIT("%", 110, 2, JimExprOpIntBin, LAZY_NONE), |
| 12834 | |
| 12835 | OPRINIT("-", 100, 2, JimExprOpBin, LAZY_NONE), |
| 12836 | OPRINIT("+", 100, 2, JimExprOpBin, LAZY_NONE), |
| 12837 | |
| 12838 | OPRINIT("<<", 90, 2, JimExprOpIntBin, LAZY_NONE), |
| 12839 | OPRINIT(">>", 90, 2, JimExprOpIntBin, LAZY_NONE), |
| 12840 | |
| 12841 | OPRINIT("<<<", 90, 2, JimExprOpIntBin, LAZY_NONE), |
| 12842 | OPRINIT(">>>", 90, 2, JimExprOpIntBin, LAZY_NONE), |
| 12843 | |
| 12844 | OPRINIT("<", 80, 2, JimExprOpBin, LAZY_NONE), |
| 12845 | OPRINIT(">", 80, 2, JimExprOpBin, LAZY_NONE), |
| 12846 | OPRINIT("<=", 80, 2, JimExprOpBin, LAZY_NONE), |
| 12847 | OPRINIT(">=", 80, 2, JimExprOpBin, LAZY_NONE), |
| 12848 | |
| 12849 | OPRINIT("==", 70, 2, JimExprOpBin, LAZY_NONE), |
| 12850 | OPRINIT("!=", 70, 2, JimExprOpBin, LAZY_NONE), |
| 12851 | |
| 12852 | OPRINIT("&", 50, 2, JimExprOpIntBin, LAZY_NONE), |
| 12853 | OPRINIT("^", 49, 2, JimExprOpIntBin, LAZY_NONE), |
| 12854 | OPRINIT("|", 48, 2, JimExprOpIntBin, LAZY_NONE), |
| 12855 | |
| 12856 | OPRINIT("&&", 10, 2, NULL, LAZY_OP), |
| 12857 | OPRINIT(NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT), |
| 12858 | OPRINIT(NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT), |
| 12859 | |
| 12860 | OPRINIT("||", 9, 2, NULL, LAZY_OP), |
| 12861 | OPRINIT(NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT), |
| 12862 | OPRINIT(NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT), |
| 12863 | |
| 12864 | OPRINIT("?", 5, 2, JimExprOpNull, LAZY_OP), |
| 12865 | OPRINIT(NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT), |
| 12866 | OPRINIT(NULL, 5, 2, JimExprOpNull, LAZY_RIGHT), |
| 12867 | |
| 12868 | OPRINIT(":", 5, 2, JimExprOpNull, LAZY_OP), |
| 12869 | OPRINIT(NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT), |
| 12870 | OPRINIT(NULL, 5, 2, JimExprOpNull, LAZY_RIGHT), |
| 12871 | |
| 12872 | OPRINIT("**", 250, 2, JimExprOpBin, LAZY_NONE), |
| 12873 | |
| 12874 | OPRINIT("eq", 60, 2, JimExprOpStrBin, LAZY_NONE), |
| 12875 | OPRINIT("ne", 60, 2, JimExprOpStrBin, LAZY_NONE), |
| 12876 | |
| 12877 | OPRINIT("in", 55, 2, JimExprOpStrBin, LAZY_NONE), |
| 12878 | OPRINIT("ni", 55, 2, JimExprOpStrBin, LAZY_NONE), |
| 12879 | |
| 12880 | OPRINIT("!", 150, 1, JimExprOpNumUnary, LAZY_NONE), |
| 12881 | OPRINIT("~", 150, 1, JimExprOpIntUnary, LAZY_NONE), |
| 12882 | OPRINIT(NULL, 150, 1, JimExprOpNumUnary, LAZY_NONE), |
| 12883 | OPRINIT(NULL, 150, 1, JimExprOpNumUnary, LAZY_NONE), |
| 12884 | |
| 12885 | |
| 12886 | |
| 12887 | OPRINIT("int", 200, 1, JimExprOpNumUnary, LAZY_NONE), |
| 12888 | OPRINIT("abs", 200, 1, JimExprOpNumUnary, LAZY_NONE), |
| 12889 | OPRINIT("double", 200, 1, JimExprOpNumUnary, LAZY_NONE), |
| 12890 | OPRINIT("round", 200, 1, JimExprOpNumUnary, LAZY_NONE), |
| 12891 | OPRINIT("rand", 200, 0, JimExprOpNone, LAZY_NONE), |
| 12892 | OPRINIT("srand", 200, 1, JimExprOpIntUnary, LAZY_NONE), |
| 12893 | |
| 12894 | #ifdef JIM_MATH_FUNCTIONS |
| 12895 | OPRINIT("sin", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12896 | OPRINIT("cos", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12897 | OPRINIT("tan", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12898 | OPRINIT("asin", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12899 | OPRINIT("acos", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12900 | OPRINIT("atan", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12901 | OPRINIT("sinh", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12902 | OPRINIT("cosh", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12903 | OPRINIT("tanh", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12904 | OPRINIT("ceil", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12905 | OPRINIT("floor", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12906 | OPRINIT("exp", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12907 | OPRINIT("log", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12908 | OPRINIT("log10", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12909 | OPRINIT("sqrt", 200, 1, JimExprOpDoubleUnary, LAZY_NONE), |
| 12910 | OPRINIT("pow", 200, 2, JimExprOpBin, LAZY_NONE), |
| 12911 | #endif |
| 12912 | }; |
| 12913 | #undef OPRINIT |
| 12914 | |
| 12915 | #define JIM_EXPR_OPERATORS_NUM \ |
| 12916 | (sizeof(Jim_ExprOperators)/sizeof(struct Jim_ExprOperator)) |
| 12917 | |
| 12918 | static int JimParseExpression(struct JimParserCtx *pc) |
| @@ -13026,20 +13078,18 @@ | |
| 13078 | int i; |
| 13079 | int bestIdx = -1, bestLen = 0; |
| 13080 | |
| 13081 | |
| 13082 | for (i = 0; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) { |
| 13083 | const char * const opname = Jim_ExprOperators[i].name; |
| 13084 | const int oplen = Jim_ExprOperators[i].namelen; |
| 13085 | |
| 13086 | if (opname == NULL || opname[0] != pc->p[0]) { |
| 13087 | continue; |
| 13088 | } |
| 13089 | |
| 13090 | if (oplen > bestLen && strncmp(opname, pc->p, oplen) == 0) { |
| 13091 | bestIdx = i + JIM_TT_EXPR_OP; |
| 13092 | bestLen = oplen; |
| 13093 | } |
| 13094 | } |
| 13095 | if (bestIdx == -1) { |
| @@ -13111,12 +13161,12 @@ | |
| 13161 | }; |
| 13162 | |
| 13163 | |
| 13164 | typedef struct ExprByteCode |
| 13165 | { |
| 13166 | ScriptToken *token; |
| 13167 | int len; |
| 13168 | int inUse; |
| 13169 | } ExprByteCode; |
| 13170 | |
| 13171 | static void ExprFreeByteCode(Jim_Interp *interp, ExprByteCode * expr) |
| 13172 | { |
| @@ -13855,16 +13905,16 @@ | |
| 13905 | |
| 13906 | |
| 13907 | |
| 13908 | typedef struct ScanFmtPartDescr |
| 13909 | { |
| 13910 | char *arg; |
| 13911 | char *prefix; |
| 13912 | size_t width; |
| 13913 | int pos; |
| 13914 | char type; |
| 13915 | char modifier; |
| 13916 | } ScanFmtPartDescr; |
| 13917 | |
| 13918 | |
| 13919 | typedef struct ScanFmtStringObj |
| 13920 | { |
| @@ -14871,12 +14921,12 @@ | |
| 14921 | } |
| 14922 | |
| 14923 | if (retcode == JIM_OK && argc) { |
| 14924 | |
| 14925 | retcode = JimInvokeCommand(interp, argc, argv); |
| 14926 | |
| 14927 | if (Jim_CheckSignal(interp)) { |
| 14928 | retcode = JIM_SIGNAL; |
| 14929 | } |
| 14930 | } |
| 14931 | |
| 14932 | |
| @@ -15446,17 +15496,17 @@ | |
| 15496 | if (he) { |
| 15497 | callback(interp, listObjPtr, he, type); |
| 15498 | } |
| 15499 | } |
| 15500 | else { |
| 15501 | Jim_HashTableIterator htiter; |
| 15502 | JimInitHashTableIterator(ht, &htiter); |
| 15503 | while ((he = Jim_NextHashEntry(&htiter)) != NULL) { |
| 15504 | if (patternObjPtr == NULL || JimGlobMatch(Jim_String(patternObjPtr), he->key, 0)) { |
| 15505 | callback(interp, listObjPtr, he, type); |
| 15506 | } |
| 15507 | } |
| 15508 | } |
| 15509 | return listObjPtr; |
| 15510 | } |
| 15511 | |
| 15512 | |
| @@ -17795,11 +17845,11 @@ | |
| 17845 | if ((ignore_mask & (1 << JIM_SIGNAL)) == 0) { |
| 17846 | sig++; |
| 17847 | } |
| 17848 | |
| 17849 | interp->signal_level += sig; |
| 17850 | if (Jim_CheckSignal(interp)) { |
| 17851 | |
| 17852 | exitCode = JIM_SIGNAL; |
| 17853 | } |
| 17854 | else { |
| 17855 | exitCode = Jim_EvalObj(interp, argv[0]); |
| @@ -17951,25 +18001,24 @@ | |
| 18001 | |
| 18002 | |
| 18003 | static int JimInfoReferences(Jim_Interp *interp, int argc, Jim_Obj *const *argv) |
| 18004 | { |
| 18005 | Jim_Obj *listObjPtr; |
| 18006 | Jim_HashTableIterator htiter; |
| 18007 | Jim_HashEntry *he; |
| 18008 | |
| 18009 | listObjPtr = Jim_NewListObj(interp, NULL, 0); |
| 18010 | |
| 18011 | JimInitHashTableIterator(&interp->references, &htiter); |
| 18012 | while ((he = Jim_NextHashEntry(&htiter)) != NULL) { |
| 18013 | char buf[JIM_REFERENCE_SPACE + 1]; |
| 18014 | Jim_Reference *refPtr = he->u.val; |
| 18015 | const unsigned long *refId = he->key; |
| 18016 | |
| 18017 | JimFormatReference(buf, refPtr, *refId); |
| 18018 | Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, buf, -1)); |
| 18019 | } |
| 18020 | Jim_SetResult(interp, listObjPtr); |
| 18021 | return JIM_OK; |
| 18022 | } |
| 18023 | #endif |
| 18024 | |
| @@ -18005,17 +18054,17 @@ | |
| 18054 | { |
| 18055 | Jim_HashEntry *he; |
| 18056 | Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0); |
| 18057 | |
| 18058 | |
| 18059 | Jim_HashTableIterator htiter; |
| 18060 | JimInitHashTableIterator(ht, &htiter); |
| 18061 | while ((he = Jim_NextHashEntry(&htiter)) != NULL) { |
| 18062 | if (patternObjPtr == NULL || JimGlobMatch(Jim_String(patternObjPtr), Jim_String((Jim_Obj *)he->key), 0)) { |
| 18063 | callback(interp, listObjPtr, he, type); |
| 18064 | } |
| 18065 | } |
| 18066 | |
| 18067 | return listObjPtr; |
| 18068 | } |
| 18069 | |
| 18070 | |
| 18071 |