copy all the tokens from the tokenrows with a paste.
if we do 'CAT(foo bar, baz quux)', the resulting token row should have 3 tokens: 'foo', 'barbaz', 'quux'. tested by jonasa, rebuilding /sys/src, perl, netsurf, and nuklear.
This commit is contained in:
parent
8ebe958ddf
commit
c6f7989176
2 changed files with 15 additions and 6 deletions
|
@ -350,7 +350,7 @@ ispaste(Tokenrow *rtr, Token **ap, Token **an, int *ntok)
|
|||
void
|
||||
substargs(Nlist *np, Tokenrow *rtr, Tokenrow **atr)
|
||||
{
|
||||
Tokenrow ttr;
|
||||
Tokenrow ttr, rp, rn;
|
||||
Token *tp, *ap, *an, *pp, *pn;
|
||||
int ntok, argno, hs;
|
||||
|
||||
|
@ -369,19 +369,25 @@ substargs(Nlist *np, Tokenrow *rtr, Tokenrow **atr)
|
|||
insertrow(rtr, ntok, stringify(atr[argno]));
|
||||
} else if (ispaste(rtr, &ap, &an, &ntok)) { /* first token, just do the next one */
|
||||
pp = ap;
|
||||
memset(&rp, 0, sizeof(rp));
|
||||
pn = an;
|
||||
memset(&rn, 0, sizeof(rp));
|
||||
if (ap && (argno = lookuparg(np, ap)) >= 0){
|
||||
pp = nil;
|
||||
if(atr[argno]->tp != atr[argno]->lp)
|
||||
pp = atr[argno]->lp - 1;
|
||||
rp = *atr[argno];
|
||||
if(rp.tp != rp.lp)
|
||||
pp = --rp.lp;
|
||||
}
|
||||
if (an && (argno = lookuparg(np, an)) >= 0) {
|
||||
pn = nil;
|
||||
if(atr[argno]->tp != atr[argno]->lp)
|
||||
pn = atr[argno]->lp - 1;
|
||||
rn = *atr[argno];
|
||||
if(rn.tp != rn.lp)
|
||||
pn = rn.bp++;
|
||||
}
|
||||
glue(&ttr, pp, pn);
|
||||
insertrow(rtr, 0, &rp);
|
||||
insertrow(rtr, ntok, &ttr);
|
||||
insertrow(rtr, 0, &rn);
|
||||
free(ttr.bp);
|
||||
} else if (rtr->tp->type==NAME) {
|
||||
if((argno = lookuparg(np, rtr->tp)) >= 0) {
|
||||
|
|
|
@ -21,6 +21,9 @@ CAT3(blah)
|
|||
#define FOO CAT(BAR, 3)
|
||||
FOO
|
||||
|
||||
/* Expected: a bc d */
|
||||
CAT(a b, c d)
|
||||
|
||||
/*
|
||||
* CURRENTLY BROKEN:
|
||||
* __VA_ARGS__ requires at least one item.
|
||||
|
@ -58,4 +61,4 @@ g(x+(3,4)-w) | h 5) & m
|
|||
* It should treat no args as a single empty arg list.
|
||||
p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
|
||||
char c[2][6] = { str(hello), str() };
|
||||
*/
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue