From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: print -v with multibyte characters
Date: Wed, 5 Aug 2020 18:13:49 +0200 [thread overview]
Message-ID: <CAHYJk3QdBLs5_RvBXtzkhwaK3zPpgsLGgscM-DgpfHoizfPWWw@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3QLJ27VEJm7c-_JWW1ex8dXQwWOKswJFpp0rhB9VkV5jg@mail.gmail.com>
On 2/20/20, Mikael Magnusson <mikachu@gmail.com> wrote:
> On 2/20/20, zsugabubus <zsugabubus@national.shitposting.agency> wrote:
>> Hi,
>>
>> $ echo $ZSH_VERSION
>> 5.7.1
>> $ export {LC_ALL,LANG}=en_US.UTF-8
>> $ set -o multibyte && echo ok
>> ok
>>
>> Good:
>> $ print ÖÓŐöóő
>> ÖÓŐöóő
>> $ printf -v var ÖÓŐöóő; echo $var
>> ÖÓŐöóő
>>
>> Bad:
>> $ print -v var ÖÓŐ; echo $var
>> öó
>> $ print -v var öóő; echo $var
>> öóŃ
>
> This gets closer to correct, but seems to leave out the final byte or
> two, or change it somehow,
> diff --git i/Src/builtin.c w/Src/builtin.c
> index 168bf8863b..ed26717b5b 100644
> --- i/Src/builtin.c
> +++ w/Src/builtin.c
> @@ -4848,8 +4848,7 @@ bin_print(char *name, char **args, Options ops, int
> func)
> if (ret)
> free(buf);
> else
> - setsparam(OPT_ARG(ops, 'v'),
> - metafy(buf, rcount, META_REALLOC));
> + setsparam(OPT_ARG(ops, 'v'), buf);
> unqueue_signals();
> }
> return ret;
> @@ -4972,8 +4971,7 @@ bin_print(char *name, char **args, Options ops, int
> func)
> if (ret)
> free(buf);
> else
> - setsparam(OPT_ARG(ops, 'v'),
> - metafy(buf, rcount, META_REALLOC));
> + setsparam(OPT_ARG(ops, 'v'), buf);
> unqueue_signals();
> }
> return ret;
>
> Incidentally you can use print -v var -f %s ÖÓŐ; echo $var to work
> around the problem (the handling for -f uses different code which
> doesn't have the bug).
Just looking through some pending patches and saw this is unresolved.
Does anyone have any ideas on how this can be fixed?
--
Mikael Magnusson
next prev parent reply other threads:[~2020-08-05 16:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-20 19:03 zsugabubus
2020-02-20 22:58 ` Mikael Magnusson
2020-08-05 16:13 ` Mikael Magnusson [this message]
2020-08-06 6:51 ` Daniel Shahaf
2020-08-07 10:10 ` Jun T
2020-08-07 22:29 ` PATCH: Test for print -v fix Mikael Magnusson
2020-08-11 4:34 ` Jun T
2020-08-12 9:45 ` Mikael Magnusson
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=CAHYJk3QdBLs5_RvBXtzkhwaK3zPpgsLGgscM-DgpfHoizfPWWw@mail.gmail.com \
--to=mikachu@gmail.com \
--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).