Changeset 30300
- Timestamp:
- Jan 19, 2011, 3:19:06 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell
- Files:
-
- 3 edited
-
expand_vars.c (modified) (1 diff)
-
parse.c (modified) (3 diffs)
-
stack_math.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell/expand_vars.c
r15878 r30300 64 64 /* variable assignment (skip these variables) */ 65 65 if ((L == line) && (V1 != NULL)) { 66 if ((*V1 == '=') || !strcmp (V1, "++") || !strcmp (V1, "--")) { 66 int isAssignment; 67 68 isAssignment = FALSE; 69 isAssignment |= (V1[0] == '='); 70 isAssignment |= (V1[0] == '+') && (V1[1] == '='); 71 isAssignment |= (V1[0] == '-') && (V1[1] == '='); 72 isAssignment |= (V1[0] == '+') && (V1[1] == '+'); 73 isAssignment |= (V1[0] == '-') && (V1[1] == '-'); 74 75 if (isAssignment) { 67 76 *N = *L; 68 77 free (V0); -
branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell/parse.c
r30115 r30300 51 51 } 52 52 53 if (!strncmp (V1, "+=", 2)) { 54 V1 ++; 55 if (*V1 == 0) goto error; 56 V1 ++; 57 if (*V1 == 0) goto error; 58 59 val = get_variable (V0); 60 if (val == NULL) { 61 fval = 0.0; 62 } else { 63 fval = atof (val); 64 } 65 66 /* dvomath returns a new string, or NULL, with the result of the expression */ 67 val = dvomath (1, &V1, &size, 0); 68 if (val == NULL) goto error; 69 fval += atof(val); 70 // save the result 71 set_variable (V0, fval); 72 goto escape; 73 } 74 75 if (!strncmp (V1, "-=", 2)) { 76 V1 ++; 77 if (*V1 == 0) goto error; 78 V1 ++; 79 if (*V1 == 0) goto error; 80 81 val = get_variable (V0); 82 if (val == NULL) { 83 fval = 0.0; 84 } else { 85 fval = atof (val); 86 } 87 88 /* dvomath returns a new string, or NULL, with the result of the expression */ 89 val = dvomath (1, &V1, &size, 0); 90 if (val == NULL) goto error; 91 fval -= atof(val); 92 // save the result 93 set_variable (V0, fval); 94 goto escape; 95 } 96 53 97 /* not an assignement, syntax error */ 54 98 if (*V1 != '=') goto error; … … 90 134 } 91 135 } 92 } 136 // save the resulting value 137 set_str_variable (V0, val); 138 goto escape; /* frees temp variables */ 139 } 93 140 94 141 /* simple variable assignment */ … … 99 146 val = strcreate (V1); 100 147 } 101 / * both dvomath and command replacement create (char *) val */148 // save the result 102 149 set_str_variable (V0, val); 103 150 goto escape; /* frees temp variables */ -
branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell/stack_math.c
r27435 r30300 972 972 *out = OP; \ 973 973 } \ 974 clear_stack (V1); \ 975 return (TRUE); \ 974 goto escape; \ 976 975 } \ 977 976 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 'S')) { \ … … 982 981 *out = OP; \ 983 982 } \ 984 clear_stack (V1); \ 985 return (TRUE); \ 983 goto escape; \ 986 984 } \ 987 985 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 's')) { \ … … 992 990 *out = OP; \ 993 991 } \ 994 clear_stack (V1); \ 995 return (TRUE); \ 992 goto escape; \ 996 993 } } 997 994 … … 1035 1032 # undef V_FUNC 1036 1033 1034 escape: 1035 1037 1036 if (V1[0].type == 'v') { 1038 1037 free (V1[0].vector[0].elements.Ptr);
Note:
See TracChangeset
for help on using the changeset viewer.
