shithub: patch

Download patch

ref: d26b21913c1d6ff92961286fe0159a79096b3613
parent: feed31bb02f51d7ca45dfc8423decdb5b3228783
author: qwx <qwx@sciops.net>
date: Fri Jul 30 06:02:21 EDT 2021

sam-sharedsnarf: updated shared snarf patch from kvik

--- a/sam-fullfrontalnudity
+++ /dev/null
@@ -1,97 +1,0 @@
-diff -Naur a/sys/src/cmd/sam/cmd.c b/sys/src/cmd/sam/cmd.c
---- a/sys/src/cmd/sam/cmd.c	Sun Mar 15 22:31:10 2020
-+++ b/sys/src/cmd/sam/cmd.c	Tue Feb  4 05:48:08 2020
-@@ -35,7 +35,7 @@
- 	'>',	0,	0,	0,	0,	aDot,	0,	linex,	plan9_cmd,
- 	'<',	0,	0,	0,	0,	aDot,	0,	linex,	plan9_cmd,
- 	'|',	0,	0,	0,	0,	aDot,	0,	linex,	plan9_cmd,
--	'^',	0,	0,	0,	0,	aNo,	0,	linex,	plan9_cmd,
-+	'^',	0,	0,	0,	0,	aDot,	0,	linex,	plan9_cmd,
- 	'_',	0,	0,	0,	0,	aDot,	0,	linex,	plan9_cmd,
- 	'=',	0,	0,	0,	0,	aDot,	0,	linex,	eq_cmd,
- 	'c'|0x100,0,	0,	0,	0,	aNo,	0,	wordx,	cd_cmd,
-diff -Naur a/sys/src/cmd/sam/mesg.c b/sys/src/cmd/sam/mesg.c
---- a/sys/src/cmd/sam/mesg.c	Mon Apr 30 05:09:33 2012
-+++ b/sys/src/cmd/sam/mesg.c	Tue Feb  4 05:48:08 2020
-@@ -349,6 +349,12 @@
- 		f = whichfile(inshort());
- 		p0 = inlong();
- 		journaln(0, p0);
-+		int fd = open("/dev/snarf", OREAD);
-+		if(fd < 0)
-+			panic("paste: open");
-+		bufreset(&snarfbuf);
-+		bufload(&snarfbuf, 0, fd, &i);
-+		close(fd);
- 		for(l=0; l<snarfbuf.nc; l+=m){
- 			m = snarfbuf.nc-l;
- 			if(m>BLOCKSIZE)
-@@ -576,7 +582,9 @@
- snarf(File *f, Posn p1, Posn p2, Buffer *buf, int emptyok)
- {
- 	Posn l;
--	int i;
-+	int i, fd, n;
-+	String *s;
-+	char *cs;
- 
- 	if(!emptyok && p1==p2)
- 		return;
-@@ -586,11 +594,23 @@
- 		fprint(2, "bad snarf addr p1=%ld p2=%ld f->nc=%d\n", p1, p2, f->nc); /*ZZZ should never happen, can remove */
- 		p2 = f->nc;
- 	}
-+	fd = open("/dev/snarf", OWRITE);
-+	if(fd < 0){
-+		fprint(2, "snarf: %r\n");
-+		return;
-+	}
- 	for(l=p1; l<p2; l+=i){
- 		i = p2-l>BLOCKSIZE? BLOCKSIZE : p2-l;
- 		bufread(f, l, genbuf, i);
--		bufinsert(buf, buf->nc, tmprstr(genbuf, i)->s, i);
-+		s = tmprstr(genbuf, i);
-+		cs = Strtoc(s);
-+		n = strlen(cs);
-+		if(write(fd, cs, n) != n)
-+			fprint(2, "snarf: %r\n");
-+		free(cs);
-+		bufinsert(buf, buf->nc, s->s, i);
- 	}
-+	close(fd);
- }
- 
- int
-diff -Naur a/sys/src/cmd/sam/shell.c b/sys/src/cmd/sam/shell.c
---- a/sys/src/cmd/sam/shell.c	Sun Mar 15 22:31:10 2020
-+++ b/sys/src/cmd/sam/shell.c	Tue Feb  4 05:48:08 2020
-@@ -13,8 +13,7 @@
- static void
- updateenv(File *f)
- {
--	static int fd = -1;
--	int n;
-+	int n, fd;
- 	char buf[64], *p, *e;
- 	
- 	if(f == nil){
-@@ -33,7 +32,6 @@
- 	p = seprint(p+1, e, "%lud", f->dot.r.p1);
- 	p = seprint(p+1, e, "%lud", f->dot.r.p2);
- 	n = p - buf;
--	if(fd == -1)
- 	if((fd = create("/env/%dot", OWRITE, 0666)) < 0)
- 		fprint(2, "updateenv create: %r\n");
- 	if(write(fd, buf, n) != n)
-diff -Naur a/sys/src/cmd/sam/xec.c b/sys/src/cmd/sam/xec.c
---- a/sys/src/cmd/sam/xec.c	Sun Mar 15 22:31:10 2020
-+++ b/sys/src/cmd/sam/xec.c	Tue Feb  4 05:48:08 2020
-@@ -26,7 +26,7 @@
- 	if(f && f->unread)
- 		load(f);
- 	if(f==0 && (cp->addr==0 || cp->addr->type!='"') &&
--	    !utfrune("bBnqUXY!^", cp->cmdc) &&
-+	    !utfrune("bBnqUXY!", cp->cmdc) &&
- 	    cp->cmdc!=('c'|0x100) && !(cp->cmdc=='D' && cp->ctext))
- 		error(Enofile);
- 	i = lookup(cp->cmdc);
--- /dev/null
+++ b/sam-sharedsnarf
@@ -1,0 +1,99 @@
+--- //.git/fs/object/84b77568cda98a21dd4f3403a94c56724fbd5b37/tree/sys/src/cmd/sam/mesg.c
++++ sys/src/cmd/sam/mesg.c
+@@ -350,6 +350,12 @@
+ 		f = whichfile(inshort());
+ 		p0 = inlong();
+ 		journaln(0, p0);
++		int fd = open("/dev/snarf", OREAD);
++		if(fd < 0)
++			panic("paste: open");
++		bufreset(&snarfbuf);
++		bufload(&snarfbuf, 0, fd, &i);
++		close(fd);
+ 		for(l=0; l<snarfbuf.nc; l+=m){
+ 			m = snarfbuf.nc-l;
+ 			if(m>BLOCKSIZE)
+@@ -578,7 +584,9 @@
+ snarf(File *f, Posn p1, Posn p2, Buffer *buf, int emptyok)
+ {
+ 	Posn l;
+-	int i;
++	int i, fd, n;
++	String *s;
++	char *cs;
+ 
+ 	if(!emptyok && p1==p2)
+ 		return;
+@@ -588,11 +596,23 @@
+ 		fprint(2, "bad snarf addr p1=%ld p2=%ld f->nc=%d\n", p1, p2, f->nc); /*ZZZ should never happen, can remove */
+ 		p2 = f->nc;
+ 	}
++	fd = open("/dev/snarf", OWRITE);
++	if(fd < 0){
++		fprint(2, "snarf: %r\n");
++		return;
++	}
+ 	for(l=p1; l<p2; l+=i){
+ 		i = p2-l>BLOCKSIZE? BLOCKSIZE : p2-l;
+ 		bufread(f, l, genbuf, i);
+-		bufinsert(buf, buf->nc, tmprstr(genbuf, i)->s, i);
++		s = tmprstr(genbuf, i);
++		cs = Strtoc(s);
++		n = strlen(cs);
++		if(write(fd, cs, n) != n)
++			fprint(2, "snarf: %r\n");
++		free(cs);
++		bufinsert(buf, buf->nc, s->s, i);
+ 	}
++	close(fd);
+ }
+ 
+ int
+--- //.git/fs/object/84b77568cda98a21dd4f3403a94c56724fbd5b37/tree/sys/src/cmd/samterm/main.c
++++ sys/src/cmd/samterm/main.c
+@@ -303,11 +303,9 @@
+ void
+ paste(Text *t, int w)
+ {
+-	if(snarflen){
+-		cut(t, w, 0, 0);
+-		t->lock++;
+-		outTsl(Tpaste, t->tag, t->l[w].p0);
+-	}
++	cut(t, w, 0, 0);
++	t->lock++;
++	outTsl(Tpaste, t->tag, t->l[w].p0);
+ }
+ 
+ void
+--- //.git/fs/object/84b77568cda98a21dd4f3403a94c56724fbd5b37/tree/sys/src/cmd/samterm/menu.c
++++ sys/src/cmd/samterm/menu.c
+@@ -27,7 +27,6 @@
+ 	Snarf,
+ 	Plumb,
+ 	Look,
+-	Exch,
+ 	Search,
+ 	NMENU2 = Search,
+ 	Send = Search,
+@@ -50,7 +49,6 @@
+ 	"snarf",
+ 	"plumb",
+ 	"look",
+-	"<rio>",
+ 	0,		/* storage for last pattern */
+ };
+ 
+@@ -95,12 +93,6 @@
+ 	case Plumb:
+ 		if(hversion > 0)
+ 			outTsll(Tplumb, t->tag, which->p0, which->p1);
+-		break;
+-
+-	case Exch:
+-		snarf(t, w);
+-		outT0(Tstartsnarf);
+-		setlock();
+ 		break;
+ 
+ 	case Look: