IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 13, 2006, 9:27:46 AM (20 years ago)
Author:
eugene
Message:

various minor fixes

File:
1 edited

Legend:

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

    r2598 r6424  
    9494char *thisvar (char *string) {
    9595
    96   int i;
     96  int i, start;
    9797  char *word;
    9898
     
    100100  if (string[0] != '$') return ((char *) NULL);
    101101
    102   for (i = 1; ISVAR(string[i]); i++);
    103   if (i == 1) return ((char *) NULL);
    104 
     102  /* special case $?name : check that name is valid */
     103  start = 1;
     104  if (string[1] == '?') start = 2;
     105
     106  for (i = start; ISVAR(string[i]); i++);
     107  if (i == start) return ((char *) NULL);
     108
     109  /* the ? is part of the variable */
    105110  word = strncreate (&string[1], i - 1);
    106111  return (word);
     
    207212char *aftervar (char *string) {
    208213
    209   int i, j;
     214  int i, j, start;
    210215
    211216  if (string == (char *) NULL) return ((char *) NULL);
    212217  if (string[0] != '$') return ((char *) NULL);
    213218
    214   for (i = 1; ISVAR(string[i]); i++);
    215   if (i == 1) return ((char *) NULL);
     219  /* special case: $?name : test only name */
     220  start = 1;
     221  if (string[1] == '?') start = 2;
     222
     223  for (i = start; ISVAR(string[i]); i++);
     224  if (i == start) return ((char *) NULL);
    216225
    217226  for (j = i; whitespace (string[j]); j++);
Note: See TracChangeset for help on using the changeset viewer.