IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 8, 2022, 5:01:57 PM (4 years ago)
Author:
eugene
Message:

fix string-vector assignment; fix while loop logic involving vector or matrix sizes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/lib.shell/stack_math.c

    r42080 r42165  
    17061706  char line[512]; // this is only used to report an error
    17071707  snprintf (line, 512, "error: op %s not defined as unary vector op!", op);
     1708  push_error (line);
     1709  return (FALSE);
     1710
     1711escape:
     1712
     1713  if (V1[0].type == ST_VECTOR_TMP) {
     1714    free (V1[0].vector[0].elements.Ptr);
     1715    free (V1[0].vector);
     1716    V1[0].vector = NULL;
     1717  } 
     1718
     1719  clear_stack (V1);
     1720  return (TRUE);
     1721
     1722}
     1723
     1724// vector string operations
     1725int L_unary (StackVar *OUT, StackVar *V1, char *op) {
     1726
     1727  int Nx = V1[0].vector[0].Nelements;
     1728
     1729  OUT[0].vector = InitVector ();
     1730  OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/
     1731
     1732  ResetVector (OUT[0].vector, OPIHI_STR, V1[0].vector[0].Nelements);
     1733  char **Iv =  V1[0].vector[0].elements.Str;
     1734  char **Ov = OUT[0].vector[0].elements.Str;
     1735  if (!strcmp (op, "=")) {
     1736    for (int i = 0; i < Nx; i++) {                     
     1737      Ov[i] = strcreate (Iv[i]);
     1738    }                                                                   
     1739    goto escape;                                                       
     1740  }
     1741
     1742  // free the temp vector if needed
     1743  if (V1[0].type == ST_VECTOR_TMP) {
     1744    // XXX this probably does not free the strings
     1745    free (V1[0].vector[0].elements.Ptr);
     1746    free (V1[0].vector);
     1747    V1[0].vector = NULL;
     1748  } 
     1749
     1750  clear_stack (V1);
     1751
     1752  char line[512]; // this is only used to report an error
     1753  snprintf (line, 512, "error: op %s not defined as unary string vector op!", op);
    17081754  push_error (line);
    17091755  return (FALSE);
Note: See TracChangeset for help on using the changeset viewer.