version 1.32, 2001/05/23 12:34:42 |
version 1.33, 2001/05/27 08:34:10 |
|
|
/* Keep track of nested braces. If we hit |
/* Keep track of nested braces. If we hit |
* the right brace with bracelevel == 0, |
* the right brace with bracelevel == 0, |
* this is the end of the clause. */ |
* this is the end of the clause. */ |
const char *cp; /* Current position in brace clause */ |
|
size_t otherLen; |
size_t otherLen; |
/* The length of the non-curlied part of |
/* The length of the non-curlied part of |
* the current expansion */ |
* the current expansion */ |
|
|
free(toexpand); |
free(toexpand); |
} else |
} else |
Lst_AtEnd(expansions, toexpand); |
Lst_AtEnd(expansions, toexpand); |
} |
continue; |
|
} |
|
|
start = brace+1; |
start = brace+1; |
|
|
|
|
end++; |
end++; |
otherLen = brace - toexpand + strlen(end); |
otherLen = brace - toexpand + strlen(end); |
|
|
for (cp = start; cp < end; cp++) { |
for (;;) { |
char *file; /* To hold current expansion */ |
char *file; /* To hold current expansion */ |
|
const char *cp; |
/* Find the end of the current expansion */ |
|
bracelevel = 0; |
/* Find the end of the current expansion */ |
while (*cp != ',') { |
for (bracelevel = 0, cp = start; |
|
bracelevel != 0 || (*cp != '}' && *cp != ','); cp++) { |
if (*cp == '{') |
if (*cp == '{') |
bracelevel++; |
bracelevel++; |
else if (*cp == '}' && bracelevel-- <= 0) |
else if (*cp == '}') |
break; |
bracelevel--; |
cp++; |
|
} |
} |
|
|
/* Build the current combination and enqueue it. */ |
/* Build the current combination and enqueue it. */ |
file = emalloc(otherLen + cp - start + 1); |
file = emalloc(otherLen + cp - start + 1); |
if (brace != toexpand) |
if (brace != toexpand) |
memcpy(file, toexpand, brace-word); |
memcpy(file, toexpand, brace-toexpand); |
if (cp != start) |
if (cp != start) |
memcpy(file+(brace-toexpand), start, cp-start); |
memcpy(file+(brace-toexpand), start, cp-start); |
strcpy(file+(brace-toexpand)+(cp-start), end); |
strcpy(file+(brace-toexpand)+(cp-start), end); |
Lst_EnQueue(&curled, file); |
Lst_EnQueue(&curled, file); |
|
if (*cp == '}') |
|
break; |
|
start = cp+1; |
} |
} |
|
free(toexpand); |
} |
} |
} |
} |
|
|