mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Andrew Snyder <arsnyder16@gmail.com>
To: musl@lists.openwall.com
Subject: [musl] print does not support variable width plus padding
Date: Tue, 14 Dec 2021 10:22:42 -0500	[thread overview]
Message-ID: <CAOJ3pK50TXL_p=JiK0G73PRZTy8ouoxPSO_Lb=xvrPNVfXEkvQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 918 bytes --]

I would like to be cc'd on the replies

Looks like a bug in the musl printf functionality

When using variable width format string and specifying a padding musl fails
to format properly.

I am using musl indirectly through an emscripten compile of a native
library.

Consider the following repro steps using alpine docker image. Correct
results exist when using ubuntu image

# Correct expected  ' 1'
docker run -it --rm alpine printf %2i 1
# Correct expected  ' 1'
docker run -it --rm alpine printf %*i 2 1
# Correct expected  '01'
docker run -it --rm alpine printf %02i 1
# errors, Expected '01'
docker run -it --rm alpine printf %0*i 2 1

# Correct expected  ' 1'
docker run -it --rm ubuntu printf %2i 1
# Correct expected  ' 1'
docker run -it --rm ubuntu printf %*i 2 1
# Correct expected  '01'
docker run -it --rm ubuntu printf %02i 1
# Correct expected  '01'
docker run -it --rm ubuntu printf %0*i 2 1

--Andrew

[-- Attachment #2: Type: text/html, Size: 1262 bytes --]

             reply	other threads:[~2021-12-14 15:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 15:22 Andrew Snyder [this message]
2021-12-14 16:03 ` Szabolcs Nagy
2021-12-14 16:09   ` Andrew Snyder
2021-12-14 16:10     ` Andrew Snyder
2021-12-14 16:50       ` Rich Felker
2021-12-14 17:05         ` Andrew Snyder
2021-12-15 18:09       ` Quentin Rameau
2021-12-15 18:37         ` Andrew Snyder
2021-12-15 21:21           ` Rich Felker
2021-12-15 21:40             ` enh
2021-12-15 21:51               ` Andrew Snyder
2021-12-16 11:22             ` Ron Yorston

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='CAOJ3pK50TXL_p=JiK0G73PRZTy8ouoxPSO_Lb=xvrPNVfXEkvQ@mail.gmail.com' \
    --to=arsnyder16@gmail.com \
    --cc=musl@lists.openwall.com \
    /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/musl/

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).