diff --git a/.gitmodules b/.gitmodules index a6ebfdef..0029bf93 100644 --- a/.gitmodules +++ b/.gitmodules @@ -289,7 +289,7 @@ url = git://git.suckless.org/quark [submodule "pkg/rc/src"] path = pkg/rc/src - url = https://github.com/benavento/rc.git + url = git://shithub.us/cinap_lenrek/rc ignore = all [submodule "pkg/samurai/src"] path = pkg/samurai/src diff --git a/pkg/rc/gen.lua b/pkg/rc/gen.lua index a0dde154..d2dbecb0 100644 --- a/pkg/rc/gen.lua +++ b/pkg/rc/gen.lua @@ -1,28 +1,20 @@ cflags{ '-Wpedantic', + '-I $srcdir', + '-I $outdir', ([['-D PREFIX="%s"']]):format(config.prefix), } -exe('rc', { - 'code.c', - 'exec.c', - 'getflags.c', - 'glob.c', - 'here.c', - 'io.c', - 'lex.c', - 'pcmd.c', - 'pfnc.c', - 'simple.c', - 'subr.c', - 'trap.c', - 'tree.c', - 'var.c', - 'y.tab.c', - 'unix.c', - 'havefork.c', - 'prompt-null.c', -}) +yacc('y', 'syn.y') + +exe('rc', [[ + code.c exec.c getflags.c glob.c + here.c io.c lex.c pcmd.c pfnc.c + simple.c subr.c trap.c tree.c + var.c unix.c havefork.c + + $outdir/y.tab.c +]]) file('bin/rc', '755', '$outdir/rc') man{'rc.1'} diff --git a/pkg/rc/patch/0001-Avoid-multiple-definitions-of-global-variables.patch b/pkg/rc/patch/0001-Avoid-multiple-definitions-of-global-variables.patch deleted file mode 100644 index d8ca6e98..00000000 --- a/pkg/rc/patch/0001-Avoid-multiple-definitions-of-global-variables.patch +++ /dev/null @@ -1,242 +0,0 @@ -From 8d15541e85b391c1cd86907089d33f70d7ca0f65 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Mon, 4 Nov 2019 20:50:08 -0800 -Subject: [PATCH] Avoid multiple definitions of global variables - ---- - exec.c | 9 ++++++++- - exec.h | 12 ++++++------ - io.c | 1 + - io.h | 2 +- - lex.c | 3 +++ - rc.h | 30 +++++++++++++++--------------- - simple.c | 2 ++ - subr.c | 1 + - var.c | 1 + - 9 files changed, 38 insertions(+), 23 deletions(-) - -diff --git a/exec.c b/exec.c -index 3ad8a0d..268f429 100644 ---- a/exec.c -+++ b/exec.c -@@ -3,10 +3,17 @@ - #include "exec.h" - #include "io.h" - #include "fns.h" -+int mypid; -+thread *runq; -+code *codebuf; -+int ntrap; -+int trap[NSIG]; -+int eflagok; -+ - /* - * Start executing the given code at the given pc with the given redirection - */ --char *argv0="rc"; -+char *argv0 = "rc"; - - void - start(code *c, int pc, var *local) -diff --git a/exec.h b/exec.h -index 06d2991..ab0bfb4 100644 ---- a/exec.h -+++ b/exec.h -@@ -56,18 +56,18 @@ struct thread{ - tree *treenodes; /* tree nodes created by this process */ - thread *ret; /* who continues when this finishes */ - }; --thread *runq; -+extern thread *runq; - code *codecopy(code*); --code *codebuf; /* compiler output */ --int ntrap; /* number of outstanding traps */ --int trap[NSIG]; /* number of outstanding traps per type */ -+extern code *codebuf; /* compiler output */ -+extern int ntrap; /* number of outstanding traps */ -+extern int trap[NSIG]; /* number of outstanding traps per type */ - struct builtin{ - char *name; - void (*fnc)(void); - }; - extern struct builtin Builtin[]; --int eflagok; /* kludge flag so that -e doesn't exit in startup */ --int havefork; -+extern int eflagok; /* kludge flag so that -e doesn't exit in startup */ -+extern int havefork; - - void execcd(void), execwhatis(void), execeval(void), execexec(void); - int execforkexec(void); -diff --git a/io.c b/io.c -index bb8af4a..228ec56 100644 ---- a/io.c -+++ b/io.c -@@ -3,6 +3,7 @@ - #include "exec.h" - #include "io.h" - #include "fns.h" -+io *err; - int pfmtnest = 0; - - void -diff --git a/io.h b/io.h -index 21cc6b8..68b9e89 100644 ---- a/io.h -+++ b/io.h -@@ -10,7 +10,7 @@ struct io{ - int fd; - char *bufp, *ebuf, *strp, buf[NBUF]; - }; --io *err; -+extern io *err; - io *openfd(int), *openstr(void), *opencore(char *, int); - int emptybuf(io*); - void pchr(io*, int); -diff --git a/lex.c b/lex.c -index d2bef32..943112a 100644 ---- a/lex.c -+++ b/lex.c -@@ -22,6 +22,7 @@ idchr(int c) - return c>' ' && !strchr("!\"#$%&'()+,-./:;<=>?@[\\]^`{|}~", c); - } - int future = EOF; -+char *promptstr; - int doprompt = 1; - int inquote; - int incomm; -@@ -36,6 +37,7 @@ nextc(void) - future = getnext(); - return future; - } -+int lastc; - /* - * Consume the lookahead character. - */ -@@ -131,6 +133,7 @@ nextis(int c) - } - return 0; - } -+char tok[NTOK]; - - char* - addtok(char *p, int val) -diff --git a/rc.h b/rc.h -index 8a6a5bb..cbec275 100644 ---- a/rc.h -+++ b/rc.h -@@ -53,7 +53,7 @@ tree *mung1(tree*, tree*), *mung2(tree*, tree*, tree*); - tree *mung3(tree*, tree*, tree*, tree*), *epimung(tree*, tree*); - tree *simplemung(tree*), *heredoc(tree*); - void freetree(tree*); --tree *cmdtree; -+extern tree *cmdtree; - /* - * The first word of any code vector is a reference count. - * Always create a new reference to a code vector by calling codecopy(.). -@@ -64,10 +64,10 @@ union code{ - int i; - char *s; - }; --char *promptstr; --int doprompt; -+extern char *promptstr; -+extern int doprompt; - #define NTOK 8192 --char tok[NTOK]; -+extern char tok[NTOK]; - #define APPEND 1 - #define WRITE 2 - #define READ 3 -@@ -87,7 +87,7 @@ struct var{ - }; - var *vlook(char*), *gvlook(char*), *newvar(char*, var*); - #define NVAR 521 --var *gvar[NVAR]; /* hash for globals */ -+extern var *gvar[NVAR]; /* hash for globals */ - #define new(type) ((type *)emalloc(sizeof(type))) - void *emalloc(long); - void *Malloc(ulong); -@@ -98,7 +98,7 @@ struct here{ - char *name; - struct here *next; - }; --int mypid; -+extern int mypid; - /* - * Glob character escape in strings: - * In a string, GLOB must be followed by *?[ or GLOB. -@@ -117,10 +117,10 @@ int mypid; - #define threebyte(c) ((c&0xf0)==0xe0) - #define fourbyte(c) ((c&0xf8)==0xf0) - --char **argp; --char **args; --int nerror; /* number of errors encountered during compilation */ --int doprompt; /* is it time for a prompt? */ -+extern char **argp; -+extern char **args; -+extern int nerror; /* number of errors encountered during compilation */ -+extern int doprompt; /* is it time for a prompt? */ - /* - * Which fds are the reading/writing end of a pipe? - * Unfortunately, this can vary from system to system. -@@ -129,14 +129,14 @@ int doprompt; /* is it time for a prompt? */ - */ - #define PRD 0 - #define PWR 1 --char *Rcmain, *Fdprefix; -+extern char *Rcmain, *Fdprefix; - #define register - /* - * How many dot commands have we executed? - * Used to ensure that -v flag doesn't print rcmain. - */ --int ndot; -+extern int ndot; - char *getstatus(void); --int lastc; --int lastword; --int kidpid; -+extern int lastc; -+extern int lastword; -+extern int kidpid; -diff --git a/simple.c b/simple.c -index d587227..7f1ee12 100644 ---- a/simple.c -+++ b/simple.c -@@ -6,6 +6,8 @@ - #include "exec.h" - #include "io.h" - #include "fns.h" -+int ndot; -+ - /* - * Search through the following code to see if we're just going to exit. - */ -diff --git a/subr.c b/subr.c -index a2d8a18..f031be5 100644 ---- a/subr.c -+++ b/subr.c -@@ -23,6 +23,7 @@ efree(void *p) - else pfmt(err, "free 0\n"); - } - extern int lastword, lastdol; -+int nerror; - - void - yyerror(char *m) -diff --git a/var.c b/var.c -index 2564ba2..b4a3ef5 100644 ---- a/var.c -+++ b/var.c -@@ -1,6 +1,7 @@ - #include "rc.h" - #include "exec.h" - #include "fns.h" -+var *gvar[NVAR]; - - int - hash(char *s, int n) --- -2.24.0 - diff --git a/pkg/rc/patch/0002-Use-proc-self-fd-0-instead-of-dev-fd-0.patch b/pkg/rc/patch/0001-Use-proc-self-fd-0-instead-of-dev-fd-0.patch similarity index 72% rename from pkg/rc/patch/0002-Use-proc-self-fd-0-instead-of-dev-fd-0.patch rename to pkg/rc/patch/0001-Use-proc-self-fd-0-instead-of-dev-fd-0.patch index 20edd9b6..c0fccb44 100644 --- a/pkg/rc/patch/0002-Use-proc-self-fd-0-instead-of-dev-fd-0.patch +++ b/pkg/rc/patch/0001-Use-proc-self-fd-0-instead-of-dev-fd-0.patch @@ -1,4 +1,4 @@ -From 56359f53946306347ef9bb1f8f3c402adb8f8a5b Mon Sep 17 00:00:00 2001 +From 40656566e36b0eb4b557a522c9c309bd5d845cec Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Mon, 4 Nov 2019 20:59:30 -0800 Subject: [PATCH] Use /proc/self/fd/0 instead of /dev/fd/0 @@ -8,11 +8,11 @@ Subject: [PATCH] Use /proc/self/fd/0 instead of /dev/fd/0 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rcmain.unix b/rcmain.unix -index 42b3be4..1b5d6d2 100644 +index 7ccbe1b..2aa9ddb 100644 --- a/rcmain.unix +++ b/rcmain.unix -@@ -25,9 +25,9 @@ if not if(flag i){ - if(flag l && test -r $profile) . $profile +@@ -29,9 +29,9 @@ if not if(flag i){ + } status='' if(! ~ $#* 0) . $* - . -i /dev/fd/0 @@ -24,5 +24,5 @@ index 42b3be4..1b5d6d2 100644 status='' . $* -- -2.24.0 +2.45.2 diff --git a/pkg/rc/patch/0002-rc-use-IOUNIT-for-io-NBUF.patch b/pkg/rc/patch/0002-rc-use-IOUNIT-for-io-NBUF.patch new file mode 100644 index 00000000..3a87990a --- /dev/null +++ b/pkg/rc/patch/0002-rc-use-IOUNIT-for-io-NBUF.patch @@ -0,0 +1,38 @@ +From 0a6a205f8cd48665527fbe4534e32b04e03ca660 Mon Sep 17 00:00:00 2001 +From: kemal +Date: Sat, 23 Sep 2023 23:52:39 +0000 +Subject: [PATCH] rc: use IOUNIT for io NBUF + +--- + io.c | 2 +- + rc.h | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/io.c b/io.c +index 7c1a27e..be8f647 100644 +--- a/io.c ++++ b/io.c +@@ -4,7 +4,7 @@ + #include "fns.h" + + enum { +- NBUF = 8192, ++ NBUF = IOUNIT, + }; + + void +diff --git a/rc.h b/rc.h +index a688663..3663a1c 100644 +--- a/rc.h ++++ b/rc.h +@@ -19,6 +19,7 @@ + #ifndef NSIG + #define NSIG 32 + #endif ++#define IOUNIT 32768 + #endif + + #define YYMAXDEPTH 500 +-- +2.45.2 + diff --git a/pkg/rc/patch/0003-rc-handle-Xeflag-in-exitnext.patch b/pkg/rc/patch/0003-rc-handle-Xeflag-in-exitnext.patch new file mode 100644 index 00000000..9c6d1524 --- /dev/null +++ b/pkg/rc/patch/0003-rc-handle-Xeflag-in-exitnext.patch @@ -0,0 +1,25 @@ +From 8cce15805da628c41a09c2fe3dbbf86c061a5ad1 Mon Sep 17 00:00:00 2001 +From: cinap_lenrek +Date: Wed, 27 Dec 2023 23:07:06 +0000 +Subject: [PATCH] rc: handle Xeflag in exitnext() + +--- + simple.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/simple.c b/simple.c +index 6f4d38b..5f325ba 100644 +--- a/simple.c ++++ b/simple.c +@@ -18,7 +18,7 @@ exitnext(void){ + loop: + c=&p->code[p->pc]; + while(1){ +- if(c->f==Xpopredir || c->f==Xunlocal) ++ if(c->f==Xpopredir || c->f==Xunlocal || c->f==Xeflag) + c++; + else if(c->f==Xsrcline) + c += 2; +-- +2.45.2 + diff --git a/pkg/rc/patch/0004-exec.c-fix-return-type-for-main.patch b/pkg/rc/patch/0004-exec.c-fix-return-type-for-main.patch new file mode 100644 index 00000000..7ce3f64d --- /dev/null +++ b/pkg/rc/patch/0004-exec.c-fix-return-type-for-main.patch @@ -0,0 +1,25 @@ +From 64d1d3403037d9ec1895555b8015825c75815f85 Mon Sep 17 00:00:00 2001 +From: hovercats +Date: Wed, 12 Mar 2025 03:36:44 +0100 +Subject: [PATCH] exec.c: fix return type for main + +--- + exec.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/exec.c b/exec.c +index 32e7644..e3d12e5 100644 +--- a/exec.c ++++ b/exec.c +@@ -221,7 +221,7 @@ shuffleredir(void) + * fabricate bootstrap code and start it (*=(argv);. -bq /usr/lib/rcmain $*) + * start interpreting code + */ +-void ++int + main(int argc, char *argv[]) + { + code bootstrap[20]; +-- +2.45.2 + diff --git a/pkg/rc/src b/pkg/rc/src index 50b729e6..a827beee 160000 --- a/pkg/rc/src +++ b/pkg/rc/src @@ -1 +1 @@ -Subproject commit 50b729e65d6f250ab9ab72487bd3c3d7c674e1fc +Subproject commit a827beee910cb143f916cf3657c45c29d904800c diff --git a/pkg/rc/ver b/pkg/rc/ver index 3bd37761..3d830e16 100644 --- a/pkg/rc/ver +++ b/pkg/rc/ver @@ -1 +1 @@ -50b729e65d r0 +a827bee r0