Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: print -v with multibyte characters



On 2/20/20, Mikael Magnusson <mikachu@xxxxxxxxx> 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




Messages sorted by: Reverse Date, Date, Thread, Author