summaryrefslogtreecommitdiff
path: root/jim.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-01-24 11:32:03 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 11:02:41 +1000
commitc5bf0eb2d41b437999394486dc4d7eace5dc0c27 (patch)
tree25a42d2f8a8e2419be8503c2fece94ff917e7a9d /jim.c
parentb0950211281e786a633692eee2a4096e8457ed82 (diff)
Bug fixes, documentation updates
jimsh - retry on EINTR from fgets() Fix 0 -> NULL for 64 bit systems Fix overlapping memcpy Fix jim array dereferencing bug *: Counting of parentheses was incorrect with nested array references *: The result for array dereference wasn't being used properly Add os.uptime command Documentation: autogenerated command index Fix gets when last line has no newline
Diffstat (limited to 'jim.c')
-rw-r--r--jim.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/jim.c b/jim.c
index 1f7ac3f..ffd3e6b 100644
--- a/jim.c
+++ b/jim.c
@@ -1371,11 +1371,18 @@ int JimParseVar(struct JimParserCtx *pc)
}
/* Parse [dict get] syntax sugar. */
if (*pc->p == '(') {
- while (*pc->p != ')' && pc->len) {
+ int count = 1;
+ while (count && pc->len) {
pc->p++; pc->len--;
if (*pc->p == '\\' && pc->len >= 2) {
pc->p += 2; pc->len -= 2;
}
+ else if (*pc->p == '(') {
+ count++;
+ }
+ else if (*pc->p == ')') {
+ count--;
+ }
}
if (*pc->p != '\0') {
pc->p++; pc->len--;
@@ -8913,18 +8920,18 @@ int Jim_SubstObj(Jim_Interp *interp, Jim_Obj *substObjPtr,
Jim_AppendObj(interp, resObjPtr, token[i].objPtr);
break;
case JIM_TT_VAR:
- objPtr = Jim_GetVariable(interp, token[i].objPtr, JIM_ERRMSG);
+ case JIM_TT_DICTSUGAR:
+ if (token[i].type == JIM_TT_VAR) {
+ objPtr = Jim_GetVariable(interp, token[i].objPtr, JIM_ERRMSG);
+ }
+ else {
+ objPtr = Jim_ExpandDictSugar(interp, token[i].objPtr);
+ }
if (objPtr == NULL) goto err;
Jim_IncrRefCount(objPtr);
Jim_AppendObj(interp, resObjPtr, objPtr);
Jim_DecrRefCount(interp, objPtr);
break;
- case JIM_TT_DICTSUGAR:
- objPtr = Jim_ExpandDictSugar(interp, token[i].objPtr);
- if (!objPtr) {
- goto err;
- }
- break;
case JIM_TT_CMD:
if (Jim_EvalObj(interp, token[i].objPtr) != JIM_OK)
goto err;