commit 4ff0243

hovercats  ·  2025-03-12 02:47:47 +0000 UTC
parent 78fca20
rc: switch to cinap_lenrek repo. this is just a port pulled from 9fronts sourcetree, and more or less follows 9fronts changes
9 files changed,  +108, -270
+1, -1
1@@ -87,7 +87,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
+12, -20
 1@@ -1,28 +1,20 @@
 2 cflags{
 3 	'-Wpedantic',
 4+	'-I $srcdir',
 5+	'-I $outdir',
 6 	([['-D PREFIX="%s"']]):format(config.prefix),
 7 }
 8 
 9-exe('rc', {
10-	'code.c',
11-	'exec.c',
12-	'getflags.c',
13-	'glob.c',
14-	'here.c',
15-	'io.c',
16-	'lex.c',
17-	'pcmd.c',
18-	'pfnc.c',
19-	'simple.c',
20-	'subr.c',
21-	'trap.c',
22-	'tree.c',
23-	'var.c',
24-	'y.tab.c',
25-	'unix.c',
26-	'havefork.c',
27-	'prompt-null.c',
28-})
29+yacc('y', 'syn.y')
30+
31+exe('rc', [[
32+	code.c exec.c getflags.c glob.c
33+	here.c io.c lex.c pcmd.c pfnc.c
34+	simple.c subr.c trap.c tree.c
35+	var.c unix.c havefork.c
36+
37+	$outdir/y.tab.c
38+]])
39 file('bin/rc', '755', '$outdir/rc')
40 man{'rc.1'}
41 
+0, -242
  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 
+38, -0
 1@@ -0,0 +1,38 @@
 2+From 0a6a205f8cd48665527fbe4534e32b04e03ca660 Mon Sep 17 00:00:00 2001
 3+From: kemal <kemalinanc8@gmail.com>
 4+Date: Sat, 23 Sep 2023 23:52:39 +0000
 5+Subject: [PATCH] rc: use IOUNIT for io NBUF
 6+
 7+---
 8+ io.c | 2 +-
 9+ rc.h | 1 +
10+ 2 files changed, 2 insertions(+), 1 deletion(-)
11+
12+diff --git a/io.c b/io.c
13+index 7c1a27e..be8f647 100644
14+--- a/io.c
15++++ b/io.c
16+@@ -4,7 +4,7 @@
17+ #include "fns.h"
18+ 
19+ enum {
20+-	NBUF = 8192,
21++	NBUF = IOUNIT,
22+ };
23+ 
24+ void
25+diff --git a/rc.h b/rc.h
26+index a688663..3663a1c 100644
27+--- a/rc.h
28++++ b/rc.h
29+@@ -19,6 +19,7 @@
30+ #ifndef NSIG
31+ #define NSIG 32
32+ #endif
33++#define IOUNIT	32768
34+ #endif
35+ 
36+ #define	YYMAXDEPTH	500
37+-- 
38+2.45.2
39+
+25, -0
 1@@ -0,0 +1,25 @@
 2+From 8cce15805da628c41a09c2fe3dbbf86c061a5ad1 Mon Sep 17 00:00:00 2001
 3+From: cinap_lenrek <cinap_lenrek@felloff.net>
 4+Date: Wed, 27 Dec 2023 23:07:06 +0000
 5+Subject: [PATCH] rc: handle Xeflag in exitnext()
 6+
 7+---
 8+ simple.c | 2 +-
 9+ 1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+diff --git a/simple.c b/simple.c
12+index 6f4d38b..5f325ba 100644
13+--- a/simple.c
14++++ b/simple.c
15+@@ -18,7 +18,7 @@ exitnext(void){
16+ loop:
17+ 	c=&p->code[p->pc];
18+ 	while(1){
19+-		if(c->f==Xpopredir || c->f==Xunlocal)
20++		if(c->f==Xpopredir || c->f==Xunlocal || c->f==Xeflag)
21+ 			c++;
22+ 		else if(c->f==Xsrcline)
23+ 			c += 2;
24+-- 
25+2.45.2
26+
+25, -0
 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] exec.c: 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
1@@ -1 +1 @@
2-Subproject commit 50b729e65d6f250ab9ab72487bd3c3d7c674e1fc
3+Subproject commit a827beee910cb143f916cf3657c45c29d904800c
+1, -1
1@@ -1 +1 @@
2-50b729e65d r0
3+a827bee r0