Closed ghost closed 4 years ago
This patch fixes this error but calls another in rc. Concat fails with null list in rc.
It looks like the null list should be handled differently in rc.
if(lc!=0 || rc!=0){
if(lc==0 || rc==0){
Xerror1("null list in concatenation");
return;
}
If we omit the second if(lc==0 || rc==0)
, then the conclist()
should return only available string:
https://github.com/9fans/plan9port/blob/master/src/cmd/rc/exec.c#L555
I'm not sure if this is the right solution (exec.c), but works for me:
void
Xconc(void)
{
word *lp = runq->argv->words;
word *rp = runq->argv->next->words;
word *vp = runq->argv->next->next->words;
int lc = count(lp), rc = count(rp);
if (lc == 0 && rc != 0) {
if (rc != 1)
goto L1;
vp = newword(rp->word, vp);
poplist();
runq->argv->words = vp;
return;
}
if (lc != 0 && rc == 0) {
if (lc != 1)
goto L1;
vp = newword(lp->word, vp);
poplist()
runq->argv->words = vp;
return;
}
if (lc != 1 || rc !=1)
goto L1;
vp = conclist(lp, rp, vp);
poplist();
poplist();
runq->argv->words = vp;
return;
L1:
Xerror1("mismatched list lengths in concatenation");
}
it's require 2x poplist()
:
void
Xconc(void)
{
word *lp = runq->argv->words;
word *rp = runq->argv->next->words;
word *vp = runq->argv->next->next->words;
int lc = count(lp), rc = count(rp);
if (lc == 0 && rc != 0) {
if (rc != 1)
goto L2;
vp = newword(rp->word, vp);
goto L1;
}
if (lc != 0 && rc == 0) {
if (lc != 1)
goto L2;
vp = newword(lp->word, vp);
goto L1;
}
if (lc != 1 || rc !=1)
goto L2;
vp = conclist(lp, rp, vp);
L1:
poplist();
poplist();
runq->argv->words = vp;
return;
L2:
Xerror1("mismatched list lengths in concatenation");
}
It looks like
mk
wants to build the object*.o
on an empty$LDADD
variable. Setting this variable (eg.-lc
) solves the problem, but this is an ugly approach.In
Plan 9
linking is added by#pragma
, so there was no problem there. Does anyone have an idea how to solve this problem correctly? It should probably be added checking for empty variables in themk
code. The dependency graph should ignore such empty dependencies.Maybe this function should do this additional check and do not copy empty variables?