From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: [BUG] E02 test failure / ztst *> issue
Date: Thu, 12 Mar 2020 11:37:33 +0900 [thread overview]
Message-ID: <E8D3FB22-7499-4710-905D-48A18FEC5D2E@kba.biglobe.ne.jp> (raw)
In-Reply-To: <EE2A90A2-9105-4E92-A3B0-DFFCF5A18085@dana.is>
> 2020/03/12 6:15, dana <dana@dana.is> wrote:
>
> When i run E02 on master, on macOS, i get an failure for the new 'preserves
> tracing' test (see output below). On my machine, `which` outputs the name of
> the ヌ function without quoting.
I noticed this on macOS few days ago or so, and was testing on other BSDs,
and yes, the test fails (at least) on Free/Net/Open BSDs. It turned out
that the problem is in zsh itself; a patch is at the end of this post.
The test is run under C-locale, but on BSDs "which" outputs the function
name ヌ (utdf-8: e3 83 8c) as raw bytes instead of escaping by \M and \C.
On Linux the test succeeds.
The function name is printed by quotedzputs(), which calls
is_mb_niceformat(), and mbrtowc() (line 5422, utils.c). Under C locale,
mbrtowc() behaves differently on Linux and BSDs.
On Linux, mbrtowc(&c, 0xe3;0x83;0x8c, ..) returns MB_INVALID if called
under C locale. So the 1st byte 0xe3 is an invalid byte.
On BSDs it returns 1, indicating that 0xe3 is a valid single byte
character (but not printable because isprint(0xe3) is 0).
But this should not make any difference, because zsh is *expected* to
print either invalid or unprintable byte by escaping with \M- and \C-
(by using one of nicechar-family functions).
The real problem is in is_wcs_nicechar() that is called from
is_mb_niceformat() (line 5452, utils.c); is_mb_niceformat(0xe3)
should return 1 but actually returns 0. The 2nd hunk in the path below
fixes this. But only with this hunk, the function name is output as
$'\M-c\M-^C\M-^L'
i.e., ^X instead of \C-X. The first hunk in the patch fixes this.
diff --git a/Src/utils.c b/Src/utils.c
index f9c2d4a2b..5ffc459f2 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -711,7 +711,7 @@ wcs_nicechar_sel(wchar_t c, size_t *widthp, char **swidep, int quotable)
if (widthp)
*widthp = 6;
} else {
- strcpy(buf, nicechar((int)c));
+ strcpy(buf, nicechar_sel((int)c, quotable));
/*
* There may be metafied characters from nicechar(),
* so compute width and end position independently.
@@ -771,7 +771,7 @@ mod_export int is_wcs_nicechar(wchar_t c)
if (c == 0x7f || c == L'\n' || c == L'\t' || c < 0x20)
return 1;
if (c >= 0x80) {
- return (c >= 0x100);
+ return (c >= 0x100 || is_nicechar(c));
}
}
return 0;
next prev parent reply other threads:[~2020-03-12 2:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 21:15 dana
2020-03-12 2:37 ` Jun T [this message]
2020-03-12 17:31 ` dana
2020-03-12 17:36 ` Peter Stephenson
2020-03-13 10:08 ` Jun T
2020-03-13 13:52 ` dana
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=E8D3FB22-7499-4710-905D-48A18FEC5D2E@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).