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: Mon, 26 Sep 2022 14:49:08 +0900 [thread overview]
Message-ID: <26BCD53A-DBBC-4058-89E1-851705710541@kba.biglobe.ne.jp> (raw)
In-Reply-To: <9382d4c99158b30b26e6cdf9b64f225d@chazelas.org>
> 2022/09/25 19:34, Stephane Chazelas <stephane@chazelas.org> wrote:
>
> Thanks that's better, but now:
>
> $ echo $options[multibyte]
> off
> $ printf %s {$'\x80'..$'\xff'} | hexdump -C
> 00000000 5c 4d 2d 5e 40 5c 4d 2d 5e 41 5c 4d 2d 5e 42 5c |\M-^@\M-^A\M-^B\|
> 00000010 4d 2d 5e 43 5c 4d 2d 5e 44 5c 4d 2d 5e 45 5c 4d |M-^C\M-^D\M-^E\M|
(snip)
>
> That's bytes 0x80 to 0x9f with their \M-^X representation followed by UTF-8
> encoded (in my locale using UTF-8 as charmap) characters U+00A0 to U+00FF
> instead of bytes 0x80 to 0xff which I'd expect with nomultibyte.
Did you try 'LANG=C; setopt print_eight_bit' ?
Anyway, I will push the patch (included below again) with a test.
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);
}
/*
diff --git a/Test/D09brace.ztst b/Test/D09brace.ztst
index 580ed430f..c289be949 100644
--- a/Test/D09brace.ztst
+++ b/Test/D09brace.ztst
@@ -116,3 +116,10 @@
print -r {1..10}{..
0:Unmatched braces after matched braces are left alone.
>1{.. 2{.. 3{.. 4{.. 5{.. 6{.. 7{.. 8{.. 9{.. 10{..
+
+ () {
+ setopt localoptions no_multibyte
+ echo -E {$'\x80'..$'\x81'}
+ }
+0:range of 8bit chars, mulibyte option unset
+>\M-^@ \M-^A
next prev parent reply other threads:[~2022-09-26 5:54 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
2022-09-25 10:34 ` Stephane Chazelas
2022-09-26 5:49 ` Jun T [this message]
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=26BCD53A-DBBC-4058-89E1-851705710541@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).