Changeset 4306 for trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c
- Timestamp:
- Jun 17, 2005, 12:53:55 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c
r4305 r4306 1 1 # include "opihi.h" 2 2 # define VERBOSE 0 3 4 # define TWO_OP(A,B,FUNC) \ 5 if (!strncasecmp (&stack[i - 2].type, A, 1) && !strncasecmp (&stack[i - 1].type, B, 1)) \ 6 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); 7 8 # define ONE_OP(A,FUNC) \ 9 if (!strncasecmp (&stack[i - 1].type, A, 1)) \ 10 status = FUNC (&tmp_stack, &stack[i - 1], stack[i].name); 3 11 4 12 int evaluate_stack (StackVar *stack, int *Nstack) { … … 48 56 49 57 /***** binary operators *****/ 50 if ((stack[i].type == 3) || (stack[i].type == 4) || (stack[i].type == 5) || (stack[i].type == 6)) {58 if ((stack[i].type >= 3) && (stack[i].type <= 8)) { 51 59 52 60 if (i < 2) { /* need two variables to operate on */ … … 56 64 return (FALSE); 57 65 } 58 59 /* this could be macro generated... */60 # define TWO_OP(A,B,FUNC) \61 if (!strncasecmp (&stack[i - 2].type, A, 1) && !strncasecmp (&stack[i - 1].type, B, 1)) \62 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);63 66 64 67 TWO_OP ("M","M",MM_binary); … … 91 94 92 95 /***** unary operators **/ 93 if (stack[i].type == 7) {96 if (stack[i].type == 9) { 94 97 95 98 if (i < 1) { /* need one variable to operate on */ … … 99 102 } 100 103 101 if (!strncasecmp (&stack[i - 1].type, "M", 1)) 102 M_unary (&tmp_stack, &stack[i - 1], stack[i].name); 103 if (!strncasecmp (&stack[i - 1].type, "V", 1)) 104 V_unary (&tmp_stack, &stack[i - 1], stack[i].name); 105 if (!strncasecmp (&stack[i - 1].type, "S", 1)) 106 S_unary (&tmp_stack, &stack[i - 1], stack[i].name); 104 ONE_OP ("M", M_unary); 105 ONE_OP ("V", V_unary); 106 ONE_OP ("S", S_unary); 107 107 108 108 /* there are no valid unary string operators */
Note:
See TracChangeset
for help on using the changeset viewer.
