IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 28, 2022, 12:14:19 PM (4 years ago)
Author:
eugene
Message:

add string unary functions (isword, isnum, isint, isflt, length)

File:
1 edited

Legend:

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

    r39558 r42080  
    11# include "opihi.h"
     2# define USE_DEPTH 1
    23
    34Variable *variables;   /* variable to store the list of all variables */
     
    2728
    2829  int i;
    29   char *local, *MacroName;
    30 
    31   /* a local variable has the form (macroname).(varname) */
    32   MacroName = GetMacroName ();
     30  char *local;
     31
     32  /* a local variable has the form (macroname).(depth).(varname) */
     33  char *MacroName = GetMacroName ();
     34  int   MacroDepth = GetMacroDepth ();
    3335
    3436  /* need to use a mutex to prevent two threads from changing variable list simultaneously */
     
    3638
    3739  /* look for existing local variable */
    38   ALLOCATE (local, char, strlen(name) + strlen(MacroName) + 2);
    39   sprintf (local, "%s.%s", MacroName, name);
     40  int maxLen = strlen(name) + strlen(MacroName) + 16;
     41  ALLOCATE (local, char, maxLen);
     42  if (USE_DEPTH) {
     43    snprintf (local, maxLen, "%s.%d.%s", MacroName, MacroDepth, name);
     44  } else {
     45    snprintf (local, maxLen, "%s.%s", MacroName, name);
     46  }
    4047  for (i = 0; i < Nvariables; i++) {
    4148    if (!strcmp (local, variables[i].name)) {
     
    5966
    6067  int i;
    61   char *local, *MacroName;
    62 
    63   MacroName = GetMacroName ();
     68  char *local;
     69
     70  char *MacroName = GetMacroName ();
     71  int   MacroDepth = GetMacroDepth ();
    6472
    6573  /* need to use a mutex to prevent two threads from changing variable list simultaneously */
     
    6775
    6876  /* look for local variable first */
    69   ALLOCATE (local, char, strlen(name) + strlen(MacroName) + 2);
    70   sprintf (local, "%s.%s", MacroName, name);
     77  int maxLen = strlen(name) + strlen(MacroName) + 16;
     78  ALLOCATE (local, char, maxLen);
     79  if (USE_DEPTH) {
     80    snprintf (local, maxLen, "%s.%d.%s", MacroName, MacroDepth, name);
     81  } else {
     82    snprintf (local, maxLen, "%s.%s", MacroName, name);
     83  }
    7184  for (i = 0; i < Nvariables; i++) {
    7285    if (!strcmp (local, variables[i].name)) {
     
    122135 
    123136  int i;
    124   char *local, *MacroName;
    125 
    126   MacroName = GetMacroName ();
     137  char *local;
     138
     139  char *MacroName = GetMacroName ();
     140  int   MacroDepth = GetMacroDepth ();
    127141
    128142  /* look for local variable first */
    129   ALLOCATE (local, char, strlen(name) + strlen(MacroName) + 2);
    130   sprintf (local, "%s.%s", MacroName, name);
     143  int maxLen = strlen(name) + strlen(MacroName) + 16;
     144  ALLOCATE (local, char, maxLen);
     145  if (USE_DEPTH) {
     146    snprintf (local, maxLen, "%s.%d.%s", MacroName, MacroDepth, name);
     147  } else {
     148    snprintf (local, maxLen, "%s.%s", MacroName, name);
     149  }
    131150
    132151  /* need to use a mutex to prevent another thread from misleading on size of Nvariables */
Note: See TracChangeset for help on using the changeset viewer.