zsh-workers
 help / color / mirror / code / Atom feed
From: ivan tkachenko <me@ratijas.tk>
To: zsh-workers@zsh.org
Subject: [PATCH] zstat: double metafy fix
Date: Wed, 14 Nov 2018 12:07:26 +0800	[thread overview]
Message-ID: <76470381542168446@iva5-750e13568e4d.qloud-c.yandex.net> (raw)

Hello, zsh team!

I've found and successfully fixed a bug of double escaping formatted time in
`zstat` builtin with the patch below. This bug only affects locales (or rather
languages) other than english and only in some corner cases when characters'
codepoints collide with zsh's "Meta" definition, however it was still pretty
annoying, for example, for russian locale (ru_RU.UTF-8).

Relevant issue in irrelevant repository on GitHub:
https://github.com/supercrabtree/k/pull/87

I would also like to add tests for '%b' time formatting, but not sure which way
to go, because such test requires some OS setup.

For dockerized Debian:jessie steps to reproduce are as follow:

1) Build image from the following Dockerfile

    % docker build -t zsh . -f- <<EOF

    FROM buildpack-deps:jessie

    RUN apt-get update && apt-get install -y --no-install-recommends \
            locales \
        && rm -rf /var/lib/apt/lists/*

    RUN echo "ru_RU.UTF-8 UTF-8" >> /etc/locale.gen \
        && locale-gen \
        && update-locale

    ENV LANG=ru_RU.UTF-8

    # zsh repository is assumed to be in the current directory
    ADD . /src
    WORKDIR /src

    RUN ./Util/preconfig
    # tons of options blindly copied from Arch Linux PKGBUILD for zsh
    # https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/zsh
    RUN ./configure --prefix=/usr \
        --docdir=/usr/share/doc/zsh \
        --htmldir=/usr/share/doc/zsh/html \
        --enable-etcdir=/etc/zsh \
        --enable-zshenv=/etc/zsh/zshenv \
        --enable-zlogin=/etc/zsh/zlogin \
        --enable-zlogout=/etc/zsh/zlogout \
        --enable-zprofile=/etc/zsh/zprofile \
        --enable-zshrc=/etc/zsh/zshrc \
        --enable-maildir-support \
        --with-term-lib='ncursesw' \
        --enable-multibyte \
        --enable-function-subdirs \
        --enable-fndir=/usr/share/zsh/functions \
        --enable-scriptdir=/usr/share/zsh/scripts \
        --with-tcsetpgrp \
        --enable-pcre \
        --enable-cap \
        --enable-zsh-secure-free
    RUN make && make install.bin install.modules

    CMD zsh

    EOF

2) Run inside the container the following command

    % zmodload zsh/stat && zstat -F '%b' .

3) See something like

    atime   ноу�
    mtime   сен


All the best!

diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c
index 50a6a9bb2..ed75ea691 100644
--- a/Src/Modules/stat.c
+++ b/Src/Modules/stat.c
@@ -200,8 +200,6 @@ stattimeprint(time_t tim, long nsecs, char *outbuf, int flags)
        /* Where the heck does "40" come from? */
        int len = ztrftime(oend, 40, timefmt, (flags & STF_GMT) ? gmtime(&tim) :
                           localtime(&tim), nsecs);
-       if (len > 0)
-           metafy(oend, len, META_NOALLOC);
        if (flags & STF_RAW)
            strcat(oend, ")");
     }

             reply	other threads:[~2018-11-14  4:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14  4:07 ivan tkachenko [this message]
2018-11-15  1:47 ` Jun T

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=76470381542168446@iva5-750e13568e4d.qloud-c.yandex.net \
    --to=me@ratijas.tk \
    --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).