commit 4b55311
hovercats
·
2025-03-12 02:52:49 +0000 UTC
parent 0bdb4b2
rc: switch to cinap_lenrek repo this is a port pulled from 9fronts sourcetree, and more or less follows 9fronts changes
8 files changed,
+42,
-287
+1,
-1
1@@ -88,7 +88,7 @@
2 url = https://github.com/madler/pigz
3 [submodule "pkg/rc/src"]
4 path = pkg/rc/src
5- url = https://github.com/benavento/rc.git
6+ url = git://shithub.us/cinap_lenrek/rc
7 ignore = all
8 [submodule "pkg/rcinit/src"]
9 path = pkg/rcinit/src
+9,
-3
1@@ -1,8 +1,14 @@
2 cflags{
3 '-Wpedantic',
4+ '-I $srcdir',
5+ '-I $outdir',
6 ([['-D PREFIX="%s"']]):format(config.prefix),
7 }
8
9+pkg.deps = {'$outdir/y.tab.h'}
10+
11+yacc('y', 'syn.y')
12+
13 exe('rc', {
14 'code.c',
15 'exec.c',
16@@ -18,10 +24,10 @@ exe('rc', {
17 'trap.c',
18 'tree.c',
19 'var.c',
20- 'y.tab.c',
21- 'unix.c',
22 'havefork.c',
23- 'prompt-null.c',
24+ 'unix.c',
25+
26+ '$outdir/y.tab.c',
27 })
28 file('bin/rc', '755', '$outdir/rc')
29 man{'rc.1'}
1@@ -1,242 +0,0 @@
2-From 8d15541e85b391c1cd86907089d33f70d7ca0f65 Mon Sep 17 00:00:00 2001
3-From: Michael Forney <mforney@mforney.org>
4-Date: Mon, 4 Nov 2019 20:50:08 -0800
5-Subject: [PATCH] Avoid multiple definitions of global variables
6-
7----
8- exec.c | 9 ++++++++-
9- exec.h | 12 ++++++------
10- io.c | 1 +
11- io.h | 2 +-
12- lex.c | 3 +++
13- rc.h | 30 +++++++++++++++---------------
14- simple.c | 2 ++
15- subr.c | 1 +
16- var.c | 1 +
17- 9 files changed, 38 insertions(+), 23 deletions(-)
18-
19-diff --git a/exec.c b/exec.c
20-index 3ad8a0d..268f429 100644
21---- a/exec.c
22-+++ b/exec.c
23-@@ -3,10 +3,17 @@
24- #include "exec.h"
25- #include "io.h"
26- #include "fns.h"
27-+int mypid;
28-+thread *runq;
29-+code *codebuf;
30-+int ntrap;
31-+int trap[NSIG];
32-+int eflagok;
33-+
34- /*
35- * Start executing the given code at the given pc with the given redirection
36- */
37--char *argv0="rc";
38-+char *argv0 = "rc";
39-
40- void
41- start(code *c, int pc, var *local)
42-diff --git a/exec.h b/exec.h
43-index 06d2991..ab0bfb4 100644
44---- a/exec.h
45-+++ b/exec.h
46-@@ -56,18 +56,18 @@ struct thread{
47- tree *treenodes; /* tree nodes created by this process */
48- thread *ret; /* who continues when this finishes */
49- };
50--thread *runq;
51-+extern thread *runq;
52- code *codecopy(code*);
53--code *codebuf; /* compiler output */
54--int ntrap; /* number of outstanding traps */
55--int trap[NSIG]; /* number of outstanding traps per type */
56-+extern code *codebuf; /* compiler output */
57-+extern int ntrap; /* number of outstanding traps */
58-+extern int trap[NSIG]; /* number of outstanding traps per type */
59- struct builtin{
60- char *name;
61- void (*fnc)(void);
62- };
63- extern struct builtin Builtin[];
64--int eflagok; /* kludge flag so that -e doesn't exit in startup */
65--int havefork;
66-+extern int eflagok; /* kludge flag so that -e doesn't exit in startup */
67-+extern int havefork;
68-
69- void execcd(void), execwhatis(void), execeval(void), execexec(void);
70- int execforkexec(void);
71-diff --git a/io.c b/io.c
72-index bb8af4a..228ec56 100644
73---- a/io.c
74-+++ b/io.c
75-@@ -3,6 +3,7 @@
76- #include "exec.h"
77- #include "io.h"
78- #include "fns.h"
79-+io *err;
80- int pfmtnest = 0;
81-
82- void
83-diff --git a/io.h b/io.h
84-index 21cc6b8..68b9e89 100644
85---- a/io.h
86-+++ b/io.h
87-@@ -10,7 +10,7 @@ struct io{
88- int fd;
89- char *bufp, *ebuf, *strp, buf[NBUF];
90- };
91--io *err;
92-+extern io *err;
93- io *openfd(int), *openstr(void), *opencore(char *, int);
94- int emptybuf(io*);
95- void pchr(io*, int);
96-diff --git a/lex.c b/lex.c
97-index d2bef32..943112a 100644
98---- a/lex.c
99-+++ b/lex.c
100-@@ -22,6 +22,7 @@ idchr(int c)
101- return c>' ' && !strchr("!\"#$%&'()+,-./:;<=>?@[\\]^`{|}~", c);
102- }
103- int future = EOF;
104-+char *promptstr;
105- int doprompt = 1;
106- int inquote;
107- int incomm;
108-@@ -36,6 +37,7 @@ nextc(void)
109- future = getnext();
110- return future;
111- }
112-+int lastc;
113- /*
114- * Consume the lookahead character.
115- */
116-@@ -131,6 +133,7 @@ nextis(int c)
117- }
118- return 0;
119- }
120-+char tok[NTOK];
121-
122- char*
123- addtok(char *p, int val)
124-diff --git a/rc.h b/rc.h
125-index 8a6a5bb..cbec275 100644
126---- a/rc.h
127-+++ b/rc.h
128-@@ -53,7 +53,7 @@ tree *mung1(tree*, tree*), *mung2(tree*, tree*, tree*);
129- tree *mung3(tree*, tree*, tree*, tree*), *epimung(tree*, tree*);
130- tree *simplemung(tree*), *heredoc(tree*);
131- void freetree(tree*);
132--tree *cmdtree;
133-+extern tree *cmdtree;
134- /*
135- * The first word of any code vector is a reference count.
136- * Always create a new reference to a code vector by calling codecopy(.).
137-@@ -64,10 +64,10 @@ union code{
138- int i;
139- char *s;
140- };
141--char *promptstr;
142--int doprompt;
143-+extern char *promptstr;
144-+extern int doprompt;
145- #define NTOK 8192
146--char tok[NTOK];
147-+extern char tok[NTOK];
148- #define APPEND 1
149- #define WRITE 2
150- #define READ 3
151-@@ -87,7 +87,7 @@ struct var{
152- };
153- var *vlook(char*), *gvlook(char*), *newvar(char*, var*);
154- #define NVAR 521
155--var *gvar[NVAR]; /* hash for globals */
156-+extern var *gvar[NVAR]; /* hash for globals */
157- #define new(type) ((type *)emalloc(sizeof(type)))
158- void *emalloc(long);
159- void *Malloc(ulong);
160-@@ -98,7 +98,7 @@ struct here{
161- char *name;
162- struct here *next;
163- };
164--int mypid;
165-+extern int mypid;
166- /*
167- * Glob character escape in strings:
168- * In a string, GLOB must be followed by *?[ or GLOB.
169-@@ -117,10 +117,10 @@ int mypid;
170- #define threebyte(c) ((c&0xf0)==0xe0)
171- #define fourbyte(c) ((c&0xf8)==0xf0)
172-
173--char **argp;
174--char **args;
175--int nerror; /* number of errors encountered during compilation */
176--int doprompt; /* is it time for a prompt? */
177-+extern char **argp;
178-+extern char **args;
179-+extern int nerror; /* number of errors encountered during compilation */
180-+extern int doprompt; /* is it time for a prompt? */
181- /*
182- * Which fds are the reading/writing end of a pipe?
183- * Unfortunately, this can vary from system to system.
184-@@ -129,14 +129,14 @@ int doprompt; /* is it time for a prompt? */
185- */
186- #define PRD 0
187- #define PWR 1
188--char *Rcmain, *Fdprefix;
189-+extern char *Rcmain, *Fdprefix;
190- #define register
191- /*
192- * How many dot commands have we executed?
193- * Used to ensure that -v flag doesn't print rcmain.
194- */
195--int ndot;
196-+extern int ndot;
197- char *getstatus(void);
198--int lastc;
199--int lastword;
200--int kidpid;
201-+extern int lastc;
202-+extern int lastword;
203-+extern int kidpid;
204-diff --git a/simple.c b/simple.c
205-index d587227..7f1ee12 100644
206---- a/simple.c
207-+++ b/simple.c
208-@@ -6,6 +6,8 @@
209- #include "exec.h"
210- #include "io.h"
211- #include "fns.h"
212-+int ndot;
213-+
214- /*
215- * Search through the following code to see if we're just going to exit.
216- */
217-diff --git a/subr.c b/subr.c
218-index a2d8a18..f031be5 100644
219---- a/subr.c
220-+++ b/subr.c
221-@@ -23,6 +23,7 @@ efree(void *p)
222- else pfmt(err, "free 0\n");
223- }
224- extern int lastword, lastdol;
225-+int nerror;
226-
227- void
228- yyerror(char *m)
229-diff --git a/var.c b/var.c
230-index 2564ba2..b4a3ef5 100644
231---- a/var.c
232-+++ b/var.c
233-@@ -1,6 +1,7 @@
234- #include "rc.h"
235- #include "exec.h"
236- #include "fns.h"
237-+var *gvar[NVAR];
238-
239- int
240- hash(char *s, int n)
241---
242-2.24.0
243-
R pkg/rc/patch/0002-Use-proc-self-fd-0-instead-of-dev-fd-0.patch =>
pkg/rc/patch/0001-Use-proc-self-fd-0-instead-of-dev-fd-0.patch
+5,
-5
1@@ -1,4 +1,4 @@
2-From 56359f53946306347ef9bb1f8f3c402adb8f8a5b Mon Sep 17 00:00:00 2001
3+From 40656566e36b0eb4b557a522c9c309bd5d845cec Mon Sep 17 00:00:00 2001
4 From: Michael Forney <mforney@mforney.org>
5 Date: Mon, 4 Nov 2019 20:59:30 -0800
6 Subject: [PATCH] Use /proc/self/fd/0 instead of /dev/fd/0
7@@ -8,11 +8,11 @@ Subject: [PATCH] Use /proc/self/fd/0 instead of /dev/fd/0
8 1 file changed, 2 insertions(+), 2 deletions(-)
9
10 diff --git a/rcmain.unix b/rcmain.unix
11-index 42b3be4..1b5d6d2 100644
12+index 7ccbe1b..2aa9ddb 100644
13 --- a/rcmain.unix
14 +++ b/rcmain.unix
15-@@ -25,9 +25,9 @@ if not if(flag i){
16- if(flag l && test -r $profile) . $profile
17+@@ -29,9 +29,9 @@ if not if(flag i){
18+ }
19 status=''
20 if(! ~ $#* 0) . $*
21 - . -i /dev/fd/0
22@@ -24,5 +24,5 @@ index 42b3be4..1b5d6d2 100644
23 status=''
24 . $*
25 --
26-2.24.0
27+2.45.2
28
1@@ -0,0 +1,25 @@
2+From 64d1d3403037d9ec1895555b8015825c75815f85 Mon Sep 17 00:00:00 2001
3+From: hovercats <hovercatswithlasereyes@protonmail.com>
4+Date: Wed, 12 Mar 2025 03:36:44 +0100
5+Subject: [PATCH] fix return type for main
6+
7+---
8+ exec.c | 2 +-
9+ 1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+diff --git a/exec.c b/exec.c
12+index 32e7644..e3d12e5 100644
13+--- a/exec.c
14++++ b/exec.c
15+@@ -221,7 +221,7 @@ shuffleredir(void)
16+ * fabricate bootstrap code and start it (*=(argv);. -bq /usr/lib/rcmain $*)
17+ * start interpreting code
18+ */
19+-void
20++int
21+ main(int argc, char *argv[])
22+ {
23+ code bootstrap[20];
24+--
25+2.45.2
26+
1@@ -1,34 +0,0 @@
2-From 39da3936cd5cf89e97de197181a05bb405e114b9 Mon Sep 17 00:00:00 2001
3-From: Michael Forney <mforney@mforney.org>
4-Date: Tue, 29 Apr 2025 00:48:53 -0700
5-Subject: [PATCH] Use complete function prototype to fix build with C23
6-
7----
8- unix.c | 4 ++--
9- 1 file changed, 2 insertions(+), 2 deletions(-)
10-
11-diff --git a/unix.c b/unix.c
12-index 3f7bf9d..7052075 100644
13---- a/unix.c
14-+++ b/unix.c
15-@@ -402,7 +402,7 @@ gettrap(int sig)
16- ntrap++;
17- if(ntrap>=NSIG){
18- pfmt(err, "rc: Too many traps (trap %d), dumping core\n", sig);
19-- signal(SIGABRT, (void (*)())0);
20-+ signal(SIGABRT, (void (*)(int))0);
21- kill(getpid(), SIGABRT);
22- }
23- }
24-@@ -411,7 +411,7 @@ void
25- Trapinit(void)
26- {
27- int i;
28-- void (*sig)();
29-+ void (*sig)(int);
30-
31- if(1 || flag['d']){ /* wrong!!! */
32- sig = signal(SIGINT, gettrap);
33---
34-2.49.0
35-
+1,
-1
1@@ -1 +1 @@
2-Subproject commit 50b729e65d6f250ab9ab72487bd3c3d7c674e1fc
3+Subproject commit 3e907e648d7263c159c604dc51aa8ca5d5fcd7f8
+1,
-1
1@@ -1 +1 @@
2-50b729e65d r1
3+7c49b6bc9d r0