IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 9, 2021, 10:49:12 AM (5 years ago)
Author:
eugene
Message:

fix library order for pcontrol linkage; report buffer dimensions and NAXIS3 size; add file stats; allow string vector element assignment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/parse.c

    r41341 r41489  
    200200    }
    201201
    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)*/
    216203    if (isBuffer) {
     204      // unknown buffer name
    217205      if ((buf = SelectBuffer (V0, OLDBUFFER, TRUE)) == NULL) goto error;
    218206      free (V0); V0 = (char *) NULL;
     
    229217      if (Nx < 0) Nx += buf[0].header.Naxis[0];
    230218      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);
    234219    } else {
    235220      if ((vec = SelectVector (V0, OLDVECTOR, TRUE)) == NULL) goto error;
     
    244229      }
    245230      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 {
    246257      if (vec[0].type == OPIHI_FLT) {
    247258        vec[0].elements.Flt[Nx] = atof (val);
    248       } else {
     259      }
     260      if (vec[0].type == OPIHI_INT) {
    249261        vec[0].elements.Int[Nx] = atoll (val);
    250262      }
     263      if (vec[0].type == OPIHI_STR) {
     264        vec[0].elements.Str[Nx] = strcreate (val);
     265      }
    251266    }
    252267    goto escape;
     
    359374
    360375/* case 3: we hunt for '{', and then the first '}' and pass everything
    361    inbetween.  no nested {{}}s are allowed! */
     376   in between.  no nested {{}}s are allowed! */
    362377 
    363378/* thisword ALLOCATES
Note: See TracChangeset for help on using the changeset viewer.