Changeset 15878 for trunk/Ohana/src/opihi/lib.shell/expand_vars.c
- Timestamp:
- Dec 16, 2007, 2:27:00 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/expand_vars.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/expand_vars.c
r10646 r15878 4 4 5 5 char *L, *N, *V0, *V1, *Val, *newline, *c, found; 6 int done, MacroDepth ;6 int done, MacroDepth, NLINE, Noff; 7 7 8 8 if (line == NULL) return (NULL); … … 10 10 11 11 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 */ 13 14 14 15 V0 = thiscomm (line); … … 34 35 L++; 35 36 N++; 37 if (N - newline >= NLINE - 5) { 38 Noff = N - newline; 39 NLINE += 128; 40 REALLOCATE (newline, char, NLINE); 41 N = newline + Noff; 42 } 36 43 } 37 44 } … … 46 53 if (V0 == NULL) { 47 54 *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 } 48 61 continue; 49 62 } … … 54 67 *N = *L; 55 68 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 } 56 75 continue; 57 76 } … … 65 84 goto error; 66 85 } else { /* if we are executing a macro, attach the list depth to the front, pass on down the line */ 86 // XXX this is limiting!!! 67 87 ALLOCATE (c, char, 1024); 68 88 sprintf (c, "%d.%s", MacroDepth, V0); … … 79 99 for (; *Val != 0; N++, Val++) { 80 100 *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 } 81 107 } 82 108 N--; /* we overshoot on last loop */
Note:
See TracChangeset
for help on using the changeset viewer.
