shithub: riscv

Download patch

ref: 29e8ea26f2f9af2b9924e16dffd784bc5ae5685e
parent: bc1cc79225f0b006dd66d4fd81030d06f83bfca2
author: sl <[email protected]>
date: Fri Feb 19 16:15:15 EST 2021

sam/{address.c, sam.h}: bump STRSIZE to 512MB (thanks, Ori_B)

--- a/sys/src/cmd/sam/address.c
+++ b/sys/src/cmd/sam/address.c
@@ -143,14 +143,16 @@
 int
 filematch(File *f, String *r)
 {
-	char *c, buf[STRSIZE+100];
+	char *c, *s;
 	String *t;
 
 	c = Strtoc(&f->name);
-	sprint(buf, "%c%c%c %s\n", " '"[f->mod],
+	s = smprint("%c%c%c %s\n", " '"[f->mod],
 		"-+"[f->rasp!=0], " ."[f==curfile], c);
+	if(s == nil)
+		error(Etoolong);
 	free(c);
-	t = tmpcstr(buf);
+	t = tmpcstr(s);
 	Strduplstr(&genstr, t);
 	freetmpstr(t);
 	/* A little dirty... */
@@ -159,6 +161,7 @@
 	bufreset(menu);
 	bufinsert(menu, 0, genstr.s, genstr.n);
 	compile(r);
+	free(s);
 	return execute(menu, 0, menu->nc);
 }
 
--- a/sys/src/cmd/sam/sam.h
+++ b/sys/src/cmd/sam/sam.h
@@ -18,7 +18,7 @@
 
 #define	INFINITY	0x7FFFFFFFL
 #define	INCR		25
-#define	STRSIZE		(2*BLOCKSIZE)
+#define	STRSIZE		(512<<20)
 
 typedef long		Posn;		/* file position or address */
 typedef	ushort		Mod;		/* modification number */