IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2019, 5:05:27 AM (7 years ago)
Author:
eugene
Message:

allow nested variables in lists (e.g., $ref = foo, $foo:n = a, $$ref:n = a); add list -file option

File:
1 edited

Legend:

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

    r37049 r40652  
    114114}
    115115
     116/* take a pointer to the beginning of a variable (ie $foo)
     117and extract only the variable name (eg, foo) */
     118
     119char *thisref (char *string) {
     120
     121  int i, start;
     122  char *word;
     123
     124  if (string == (char *) NULL) return ((char *) NULL);
     125  if (string[0] != '$') return ((char *) NULL);
     126
     127  /* special case $?name : check that name is valid */
     128  start = 1;
     129  if (string[1] == '?') start = 2;
     130
     131  for (i = start; ISREF(string[i]); i++);
     132  if (i == start) return ((char *) NULL);
     133
     134  /* the ? is part of the variable */
     135  word = strncreate (&string[1], i - 1);
     136  return (word);
     137
     138}
    116139
    117140/**********************************************************************/
Note: See TracChangeset for help on using the changeset viewer.