Jim Tcl
Check-in [b15d214536]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:expr: Check for missing operand to operator

Reported-by: Ryan Whitworth <me@ryanwhitworth.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>

Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b15d214536a4822fbe358e09e4b43e53959d5cf7
User & Date: steveb@workware.net.au 2017-08-07 10:36:27
Context
2017-08-07
10:36
expr: Fix refcount issue converting invalid boolean

Reported-by: Ryan Whitworth <me@ryanwhitworth.com> Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: bd0203c273 user: steveb@workware.net.au tags: trunk

10:36
expr: Check for missing operand to operator

Reported-by: Ryan Whitworth <me@ryanwhitworth.com> Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: b15d214536 user: steveb@workware.net.au tags: trunk

2017-08-02
23:07
tree: Allow nodes to be deleted

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 5bc773bac3 user: steveb@workware.net.au tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to jim.c.

8895
8896
8897
8898
8899
8900
8901



8902
8903
8904




8905
8906
8907







8908
8909
8910
8911
8912
8913
8914

noargs:
            node = builder->next++;
            node->type = t->type;

            if (op->arity >= 3) {
                node->ternary = Jim_StackPop(&builder->stack);



            }
            if (op->arity >= 2) {
                node->right = Jim_StackPop(&builder->stack);




            }
            if (op->arity >= 1) {
                node->left = Jim_StackPop(&builder->stack);







            }

            /* Now push the node */
            Jim_StackPush(&builder->stack, node);
        }
        else {
            Jim_Obj *objPtr = NULL;







>
>
>



>
>
>
>



>
>
>
>
>
>
>







8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928

noargs:
            node = builder->next++;
            node->type = t->type;

            if (op->arity >= 3) {
                node->ternary = Jim_StackPop(&builder->stack);
                if (node->ternary == NULL) {
                    goto missingoperand;
                }
            }
            if (op->arity >= 2) {
                node->right = Jim_StackPop(&builder->stack);
                if (node->right == NULL) {
                    printf("missing right term to operator %s\n", op->name);
                    goto missingoperand;
                }
            }
            if (op->arity >= 1) {
                node->left = Jim_StackPop(&builder->stack);
                if (node->left == NULL) {
missingoperand:
                    Jim_SetResultFormatted(interp, "missing operand to %s in expression: \"%#s\"", op->name, builder->exprObjPtr);
                    builder->next--;
                    return JIM_ERR;

                }
            }

            /* Now push the node */
            Jim_StackPush(&builder->stack, node);
        }
        else {
            Jim_Obj *objPtr = NULL;

Changes to regtest.tcl.

336
337
338
339
340
341
342





343
344
345
puts "TEST 48 PASSED"

# REGTEST 49
# format: precision too large
catch {format %1.9999999999f 1.0}
puts "TEST 49 PASSED"






# TAKE THE FOLLOWING puts AS LAST LINE

puts "--- ALL TESTS PASSED ---"







>
>
>
>
>



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
puts "TEST 48 PASSED"

# REGTEST 49
# format: precision too large
catch {format %1.9999999999f 1.0}
puts "TEST 49 PASSED"

# REGTEST 50
# expr missing operand
catch {expr {>>-$x}}
puts "TEST 50 PASSED"

# TAKE THE FOLLOWING puts AS LAST LINE

puts "--- ALL TESTS PASSED ---"