mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Gabriel Ravier <gabravier@gmail.com>
Cc: "Jₑₙₛ Gustedt" <jens.gustedt@inria.fr>, musl@lists.openwall.com
Subject: Re: [musl] [PATCH v2 1/1] vfprintf: support C2x %b and %B conversion specifiers
Date: Sun, 16 Apr 2023 10:39:14 -0400	[thread overview]
Message-ID: <20230416143913.GN4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <30474c83-aa94-05d3-b7d6-aea3a0bd4e63@gmail.com>

On Sun, Apr 16, 2023 at 03:20:59PM +0200, Gabriel Ravier wrote:
> On 4/16/23 08:51, Jₑₙₛ Gustedt wrote:
> >Gabriel,
> >it also seems to me that ...
> >
> >on Sat, 15 Apr 2023 14:28:28 +0200 you (Gabriel Ravier
> ><gabravier@gmail.com>) wrote:
> >
> >>+	/* This buffer is used for integer conversions. As such, it needs
> >>+	 * to be able to contain the full representation of a number in base 2,
> >>+	 * 8, 10 or 16, with base 2 having the largest possible requirement of
> >>+	 * as many characters as the amount of bits in the largest
> >>possible
> >>+	 * integer type */
> >>+	char buf[sizeof(uintmax_t)*CHAR_BIT];
> >... here a `+3` seems to be in order to take care of the `0[bx]`
> >prefix and a terminating null byte.
> 
> This buffer is only used specifically for storing converted digits,
> and is never used to store the alternative form, and never contains
> a null terminator either as the code knows the used length and never
> passes the buffer to a function that doesn't do so, so from what I
> can see these objections are wrong (in fact it wouldn't make much
> sense to store the prefix in that buffer given that the code also
> has to handle the possibility of extremely large 0-padding that goes
> between the prefix and the converted digits).
> 
> Though perhaps the comment could be improved, I suppose it could be
> confusing...

Yes, without looking I'm pretty sure you're right about what the
buffer is and isn't used for. I think both the +3 and the
+LDBL_MANT_DIG/4 are artifacts of proto-musl code long ago where
things were done differently and floating point code was also in the
main printf_core function and did naive floating point math. Maybe
these should be fixed with a separate patch first (which I could make
and explain what I recall of the history) so this unrelated change
isn't a distraction from the %b patches.

Rich

      reply	other threads:[~2023-04-16 14:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 16:36 [musl] [PATCH] " Gabriel Ravier
2022-09-12 13:59 ` Rich Felker
2022-09-12 14:42   ` Jₑₙₛ Gustedt
2022-09-19 15:09     ` Rich Felker
2022-09-19 17:59       ` Szabolcs Nagy
2022-09-19 18:10         ` Rich Felker
2022-09-20  9:19           ` Jₑₙₛ Gustedt
2022-09-20 12:28             ` Rich Felker
2022-09-20 13:29               ` Jₑₙₛ Gustedt
2022-09-20 13:55                 ` Rich Felker
2022-09-20 14:08                   ` Jₑₙₛ Gustedt
2022-09-20 14:15                     ` Rich Felker
2022-09-20 14:22                       ` Jₑₙₛ Gustedt
2022-09-20 14:27                         ` Jₑₙₛ Gustedt
2022-09-20 14:46                           ` Rich Felker
2022-09-20 15:20                             ` Jₑₙₛ Gustedt
2023-04-15 12:28 ` [musl] [PATCH v2 0/1] " Gabriel Ravier
2023-04-15 12:28   ` [musl] [PATCH v2 1/1] " Gabriel Ravier
2023-04-15 12:52     ` Jₑₙₛ Gustedt
2023-04-15 13:15       ` Gabriel Ravier
2023-04-15 14:15         ` Jₑₙₛ Gustedt
2023-04-16  6:51     ` Jₑₙₛ Gustedt
2023-04-16 13:20       ` Gabriel Ravier
2023-04-16 14:39         ` Rich Felker [this message]

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=20230416143913.GN4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=gabravier@gmail.com \
    --cc=jens.gustedt@inria.fr \
    --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).