From: "Jun. T" <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: [bug] busy loop and memory exhaustion on {x..$'\80'} with nomultibyte
Date: Sat, 24 Sep 2022 20:04:16 +0900 [thread overview]
Message-ID: <5DEC33AD-021F-42CD-A08E-F8BDEC23BD0A@kba.biglobe.ne.jp> (raw)
In-Reply-To: <20220923105414.mrvkpoxsejwtu7rz@chazelas.org>
> 2022/09/23 19:54, Stephane Chazelas <stephane@chazelas.org> wrote:
>
> $ (limit cputime 10; TIMEFMT='%MMiB %U user %S sys'; time zsh +o multibyte -c ": {z..$'\x80'}")
> 3980MiB 8.84s user 1.40s sys
>
> {$'\x80'..$'\xff} doesn't have the problem, but the expansion is:
(snip)
> With {$'\x80'..$'\xff'}, we get:
>
> $ zsh +o multibyte -c "printf %s {$'\x80'..$'\xff'}" | hd
> 00000000 7b 80 2e 2e ff 7d |{....}|
Does this solve the problem?
diff --git a/Src/utils.c b/Src/utils.c
index 62bd3e602..edf5d3df7 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5519,7 +5519,7 @@ mb_metacharlenconv(const char *s, wint_t *wcp)
if (!isset(MULTIBYTE) || STOUC(*s) <= 0x7f) {
/* treat as single byte, possibly metafied */
if (wcp)
- *wcp = (wint_t)(*s == Meta ? s[1] ^ 32 : *s);
+ *wcp = (wint_t)STOUC(*s == Meta ? s[1] ^ 32 : *s);
return 1 + (*s == Meta);
}
/*
next prev parent reply other threads:[~2022-09-24 11:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-23 10:54 Stephane Chazelas
2022-09-24 11:04 ` Jun. T [this message]
2022-09-25 10:34 ` Stephane Chazelas
2022-09-26 5:49 ` Jun T
2022-09-28 6:03 ` Stephane Chazelas
2022-09-28 7:53 ` Jun T
2022-09-28 9:52 ` Stephane Chazelas
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=5DEC33AD-021F-42CD-A08E-F8BDEC23BD0A@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@zsh.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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).