From: ori@eigenstate.org
To: 9front@9front.org
Subject: Re: [9front] sam input line length limits
Date: Fri, 12 Feb 2021 19:43:34 -0800 [thread overview]
Message-ID: <10CE4A9EC513CE5FC11B0B0D5006E7C8@eigenstate.org> (raw)
In-Reply-To: <32B4F44886A8F86854EDDC8FF1699640@5ess.inri.net>
Quoth sl@stanleylieber.com:
> sam.h says:
>
> /*
> * BLOCKSIZE is relatively small to keep memory consumption down.
> */
>
> and:
>
> #define BLOCKSIZE 2048
>
> and:
>
> #define STRSIZE (2*BLOCKSIZE)
>
> is there a compelling reason to keep STRSIZE so small, in this day and
> age?
>
> problem case:
>
> users trying to paste in long articles from websites.
>
> sl
>
I'd be in favor of bumping STRSIZE up a lot.
It only seems to be used as a "sane upper
bound" on string length, so changing the one
place that uses it as a stack buffer and over
to malloc should be safe.
Here's an untested diff that bumps it to 512
megabytes.
diff -r ce98610ce572 sys/src/cmd/sam/address.c
--- a/sys/src/cmd/sam/address.c Wed Feb 10 15:42:18 2021 -0800
+++ b/sys/src/cmd/sam/address.c Fri Feb 12 19:41:41 2021 -0800
@@ -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);
}
diff -r ce98610ce572 sys/src/cmd/sam/sam.h
--- a/sys/src/cmd/sam/sam.h Wed Feb 10 15:42:18 2021 -0800
+++ b/sys/src/cmd/sam/sam.h Fri Feb 12 19:41:41 2021 -0800
@@ -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 */
next prev parent reply other threads:[~2021-02-13 5:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-13 0:45 sl
2021-02-13 2:47 ` Nick Owens
2021-02-13 3:43 ` ori [this message]
2021-02-13 3:55 ` sl
2021-02-13 16:25 ` Steve Simon
2021-02-13 20:06 ` ori
2021-02-13 20:21 ` Stanley Lieber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10CE4A9EC513CE5FC11B0B0D5006E7C8@eigenstate.org \
--to=ori@eigenstate.org \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).