Changeset 41489 for trunk/Ohana/src/opihi/lib.shell/parse.c
- Timestamp:
- Feb 9, 2021, 10:49:12 AM (5 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/parse.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/parse.c
r41341 r41489 200 200 } 201 201 202 /* find value for assignment */ 203 V1 = nextcomm (line); 204 if (V1 == (char *) NULL) goto error; 205 if (V1[0] != '=') goto error; 206 V1 ++; 207 208 /*** assign vector element to value ***/ 209 val = dvomath (1, &V1, &size, 0); 210 if (val == (char *) NULL) { 211 print_error (); 212 goto error; 213 } 214 215 /* find vector */ 202 /* find vector or buffer (check for valid element)*/ 216 203 if (isBuffer) { 204 // unknown buffer name 217 205 if ((buf = SelectBuffer (V0, OLDBUFFER, TRUE)) == NULL) goto error; 218 206 free (V0); V0 = (char *) NULL; … … 229 217 if (Nx < 0) Nx += buf[0].header.Naxis[0]; 230 218 if (Ny < 0) Ny += buf[0].header.Naxis[1]; 231 232 fptr = (float *) buf[0].matrix.buffer;233 fptr[Nx + Ny*buf[0].header.Naxis[0]] = atof (val);234 219 } else { 235 220 if ((vec = SelectVector (V0, OLDVECTOR, TRUE)) == NULL) goto error; … … 244 229 } 245 230 if (Nx < 0) Nx += vec[0].Nelements; 231 } 232 233 /* find value for assignment */ 234 V1 = nextcomm (line); 235 if (V1 == (char *) NULL) goto error; 236 if (V1[0] != '=') goto error; 237 V1 ++; 238 239 /*** assign vector (or buffer) element to value ***/ 240 val = dvomath (1, &V1, &size, 0); 241 if (val == NULL) { 242 if (!isBuffer && (vec->type == OPIHI_STR)) { 243 while (OHANA_WHITESPACE (*V1)) V1++; 244 val = strcreate (V1); 245 init_error (); 246 } else { 247 print_error (); 248 goto error; 249 } 250 } 251 252 /* find vector */ 253 if (isBuffer) { 254 fptr = (float *) buf[0].matrix.buffer; 255 fptr[Nx + Ny*buf[0].header.Naxis[0]] = atof (val); 256 } else { 246 257 if (vec[0].type == OPIHI_FLT) { 247 258 vec[0].elements.Flt[Nx] = atof (val); 248 } else { 259 } 260 if (vec[0].type == OPIHI_INT) { 249 261 vec[0].elements.Int[Nx] = atoll (val); 250 262 } 263 if (vec[0].type == OPIHI_STR) { 264 vec[0].elements.Str[Nx] = strcreate (val); 265 } 251 266 } 252 267 goto escape; … … 359 374 360 375 /* case 3: we hunt for '{', and then the first '}' and pass everything 361 in between. no nested {{}}s are allowed! */376 in between. no nested {{}}s are allowed! */ 362 377 363 378 /* thisword ALLOCATES
Note:
See TracChangeset
for help on using the changeset viewer.
