aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/rc/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/rc/exec.c')
-rw-r--r--sys/cmd/rc/exec.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/sys/cmd/rc/exec.c b/sys/cmd/rc/exec.c
index 6d0c0a9..ac0dc08 100644
--- a/sys/cmd/rc/exec.c
+++ b/sys/cmd/rc/exec.c
@@ -578,6 +578,52 @@ Xword(void)
pushword(runner->code.exe[runner->code.i++].s);
}
+static
+Word*
+catlist(Word *l, Word *r, Word *tail)
+{
+ Word *w;
+ char *buf;
+
+ if(l->link || r->link)
+ tail = catlist( (!l->link)?l:l->link, (!r->link)?r:r->link, tail);
+
+ buf = emalloc(strlen(l->str)+strlen(r->str)+1);
+ strcpy(buf, l->str);
+ strcat(buf, r->str);
+
+ w = makeword(buf, tail);
+ efree(buf);
+
+ return w;
+}
+
+void
+Xconcatenate(void)
+{
+ int rn, ln;
+ Word *l = runner->args->word;
+ Word *r = runner->args->link->word;
+ Word *w = runner->args->link->link->word;
+
+ ln = count(l), rn = count(r);
+ if(ln != 0 || rn != 0) {
+ if(ln == 0 || rn == 0){
+ Xerror("null list in concatenation\n");
+ return;
+ }
+ if(ln != 1 && rn != 1 && ln != rn) {
+ Xerror("mismatched list lengths in concatenation\n");
+ return;
+ }
+ w = catlist(l, r, w);
+ }
+
+ poplist();
+ poplist();
+ runner->args->word = w;
+}
+
void
Xdollar(void)
{
@@ -638,7 +684,6 @@ Xassign(void)
poplist();
}
-
void
Xreadcmd(void)
{
@@ -982,8 +1027,6 @@ Xreturn(void)
exit(0);
}
-
-
void
Xexit(void)
{