- Timestamp:
- Jan 19, 2011, 3:19:06 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 */
Note:
See TracChangeset
for help on using the changeset viewer.
