zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Jason C. Kwan" <jasonckwan@yahoo.com>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: bug report : printf %.1s outputting more than 1 character
Date: Tue, 14 Mar 2023 20:46:02 -0700	[thread overview]
Message-ID: <CAH+w=7bkqfUYbQ2DvZ7RPDZpSgZVxMZcT8orAiANZhWMY7fxHg@mail.gmail.com> (raw)
In-Reply-To: <1621619253.265114.1678847919086@mail.yahoo.com>

On Tue, Mar 14, 2023 at 7:40 PM Jason C. Kwan <jasonckwan@yahoo.com> wrote:
>
> I'm using the macOS 13.2.1 OS-provided zsh, version 5.8.1, which I understand isn't the latest and greatest of 5.9, so perhaps this bug has already been addressed.

A related case been addressed by declaring it an intentional
divergence from POSIX, see
https://www.zsh.org/mla/workers/2022/msg00240.html

However ...

> In the 4-byte sequence as seen below ( defined via explicit octal codes ), under no Unicode scenario should 4 bytes be printed out via a command of printf %.1s, by design.
>
>  - The first byte of \377 \xFF is explicitly invalid under UTF-8 (even allowing up to 7-byte in the oldest of definitions).

This triggers a branch of the printf code introduced by this comment:
    /*
     * Invalid/incomplete character at this
     * point.  Assume all the rest are a
     * single byte.  That's about the best we
     * can do.
     */

Thus, you've deliberately invoked a case where zsh's response to
invalid input is to punt.  This dates back to the original
implementation in workers/23098,
https://www.zsh.org/mla/workers/2007/msg00019.html, January 2007.


  reply	other threads:[~2023-03-15  3:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1621619253.265114.1678847919086.ref@mail.yahoo.com>
2023-03-15  2:38 ` Jason C. Kwan
2023-03-15  3:46   ` Bart Schaefer [this message]
2023-03-15  4:56     ` Jason C. Kwan
2023-03-15 15:31       ` Bart Schaefer
2023-03-15 15:50         ` Roman Perepelitsa
2023-03-18 16:56         ` Peter Stephenson

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='CAH+w=7bkqfUYbQ2DvZ7RPDZpSgZVxMZcT8orAiANZhWMY7fxHg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=jasonckwan@yahoo.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).