IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 16, 2007, 2:27:00 PM (19 years ago)
Author:
eugene
Message:

fixed cases of hard-wired line length; some api cleanup in stack_math

File:
1 edited

Legend:

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

    r10646 r15878  
    44
    55  char *L, *N, *V0, *V1, *Val, *newline, *c, found;
    6   int done, MacroDepth;
     6  int done, MacroDepth, NLINE, Noff;
    77
    88  if (line == NULL) return (NULL);
     
    1010
    1111  found = FALSE;
    12   ALLOCATE (newline, char, 1024);  /* WARNING: this limits the length of the input line */
     12  NLINE = MAX (128, strlen(line));
     13  ALLOCATE (newline, char, NLINE);  /* WARNING: this limits the length of the input line */
    1314
    1415  V0 = thiscomm (line);
     
    3435         L++;
    3536         N++;
     37         if (N - newline >= NLINE - 5) {
     38           Noff = N - newline;
     39           NLINE += 128;
     40           REALLOCATE (newline, char, NLINE);
     41           N = newline + Noff;
     42         }
    3643      }
    3744    }
     
    4653    if (V0 == NULL) {
    4754      *N = *L;
     55      if (N - newline >= NLINE - 5) {
     56        Noff = N - newline;
     57        NLINE += 128;
     58        REALLOCATE (newline, char, NLINE);
     59        N = newline + Noff;
     60      }
    4861      continue;
    4962    }
     
    5467        *N = *L;
    5568        free (V0);
     69        if (N - newline >= NLINE - 5) {
     70          Noff = N - newline;
     71          NLINE += 128;
     72          REALLOCATE (newline, char, NLINE);
     73          N = newline + Noff;
     74        }
    5675        continue;
    5776      }
     
    6584        goto error;
    6685      } else { /* if we are executing a macro, attach the list depth to the front, pass on down the line */
     86        // XXX this is limiting!!!
    6787        ALLOCATE (c, char, 1024);
    6888        sprintf (c, "%d.%s", MacroDepth, V0);
     
    7999    for (; *Val != 0; N++, Val++)  {
    80100      *N = *Val; /* place the value of the variable in the newline */
     101      if (N - newline >= NLINE - 5) {
     102        Noff = N - newline;
     103        NLINE += 128;
     104        REALLOCATE (newline, char, NLINE);
     105        N = newline + Noff;
     106      }
    81107    }
    82108    N--; /* we overshoot on last loop */
Note: See TracChangeset for help on using the changeset viewer.