- for (prev = NULL, bp = list; bp != NULL; prev = bp, bp = bp->b_next) {
- again:
- cp = index(bp->b_name, '$');
- if (cp == NULL)
- continue;
- *cp++ = '\0';
- if (*cp == '\0')
- fatal("no variable name after '$'");
- if (*cp == '{') {
- cp++;
- if ((tail = index(cp, '}')) == NULL)
- fatal("missing '}'");
- *tail++ = c = '\0';
- if (*cp == '\0')
- fatal("no variable name after '$'");
- } else {
- tail = cp + 1;
- c = *tail;
- *tail = '\0';
- }
- tp = lookup(cp, NULL, 0);
- if (c != '\0')
- *tail = c;
- if ((tp = tp->b_args) != NULL) {
- struct block *first = bp;
-
- for (bp = prev; tp != NULL; tp = tp->b_next) {
- if (bp == NULL)
- list = bp = copy(tp, first->b_name, tail);
- else {
- bp->b_next = copy(tp, first->b_name, tail);
- bp = bp->b_next;
- }
- }
- bp->b_next = first->b_next;
- free(first->b_name);
- free(first);
- if (prev == NULL)
- bp = list;
- else
- bp = prev->b_next;
- goto again;
- } else {
- if (prev == NULL)
- list = tp = bp->b_next;
- else
- prev->b_next = tp = bp->b_next;
- free(bp->b_name);
- free(bp);
- if (tp != NULL) {
- bp = tp;
- goto again;
- }
- break;
- }
- }
-
- if (noshexp)