Changeset 15878 for trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c
- Timestamp:
- Dec 16, 2007, 2:27:00 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c
r15006 r15878 22 22 if (*Nstack == 1) { 23 23 if (stack[0].type == 'S') { 24 free (tmp_stack.name);24 clear_stack (&tmp_stack); 25 25 return (TRUE); 26 26 } … … 38 38 } 39 39 push_error ("syntax error: not a math expression"); 40 free (tmp_stack.name);40 clear_stack (&tmp_stack); 41 41 return (FALSE); 42 42 } … … 63 63 sprintf (line, "syntax error: binary operator with one operand: %s\n", stack[i].name); 64 64 push_error (line); 65 free (tmp_stack.name);65 clear_stack (&tmp_stack); 66 66 return (FALSE); 67 67 } … … 84 84 sprintf (line, "syntax error: invalid operand for binary operation: %s or %s\n", stack[i-1].name, stack[i-2].name); 85 85 push_error (line); 86 free (tmp_stack.name);86 clear_stack (&tmp_stack); 87 87 return (FALSE); 88 88 } … … 90 90 delete_stack (&stack[i-1], 2); 91 91 for (j = i + 1; j < *Nstack; j++) { 92 copy_stack (&stack[j - 2], &stack[j]);92 move_stack (&stack[j - 2], &stack[j]); 93 93 } 94 94 *Nstack -= 2; … … 103 103 if (i < 1) { /* need one variable to operate on */ 104 104 push_error ("syntax error: unary operator with no operand"); 105 free (tmp_stack.name);106 return (FALSE); 107 } 108 105 clear_stack (&tmp_stack); 106 return (FALSE); 107 } 108 109 109 ONE_OP ("M", M_unary); 110 110 ONE_OP ("V", V_unary); … … 114 114 if (!strncasecmp (&stack[i - 1].type, "W", 1)) { 115 115 push_error ("syntax error: no valid string unary ops"); 116 free (tmp_stack.name);116 clear_stack (&tmp_stack); 117 117 return (FALSE); 118 118 } … … 121 121 delete_stack (&stack[i], 1); 122 122 for (j = i + 1; j < *Nstack; j++) { 123 copy_stack (&stack[j - 1], &stack[j]);123 move_stack (&stack[j - 1], &stack[j]); 124 124 } 125 125 init_stack (&tmp_stack); … … 129 129 } 130 130 } 131 free (tmp_stack.name);131 clear_stack (&tmp_stack); 132 132 133 133 if (*Nstack > 1) { … … 153 153 /* replace data with new stack variable */ 154 154 void move_stack (StackVar *stack1, StackVar *stack2) { 155 if (stack1[0].name != (char *) NULL) 156 free (stack1[0].name); 155 clear_stack (stack1); 157 156 copy_stack (stack1, stack2); 157 stack2[0].name = NULL; 158 158 } 159 159 … … 178 178 } 179 179 if (VERBOSE) gprint (GP_ERR, "free %s (name) (%d) (%lx)\n", stack[i].name, i, (long) stack[i].name); 180 free (stack[i].name); 181 stack[i].name = NULL; 180 clear_stack (&stack[i]); 182 181 } 183 182 … … 188 187 int i; 189 188 for (i = 0; i < Nstack; i++) { 190 free (stack[i].name);189 clear_stack (&stack[i]); 191 190 } 192 191 } … … 195 194 stack[0].buffer = NULL; 196 195 stack[0].vector = NULL; 197 stack[0].name = strncreate ("tmp", NCHARS); 198 } 196 stack[0].name = NULL; 197 } 198 199 void assign_stack (StackVar *stack, char *name, int type) { 200 stack->name = strcreate (name); 201 stack->type = type; 202 } 203 204 void clear_stack (StackVar *stack) { 205 if (stack->name == NULL) return; 206 free (stack->name); 207 stack->name = NULL; 208 return; 209 }
Note:
See TracChangeset
for help on using the changeset viewer.
