public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Alejandro Colomar <colomar.6.4.3@gmail.com>
Cc: libc-alpha@sourceware.org
Subject: Re: printf %b
Date: Sat, 25 Apr 2020 17:54:07 -0700	[thread overview]
Message-ID: <20200426005407.GE877@gmail.com> (raw)
In-Reply-To: <1137ece3-27fb-0ca8-22df-dcc69077f354@gmail.com>

Hi!

Alejandro Colomar wrote:

> In my personal library, about a year ago, I wrote a function to register the
> ``b`` and ``B`` conversion specifiers using ``register_printf_specifier()``.
>
> They work the closest possible to ``o``, ``u``, ``x`` & ``X``:

You left out the key detail up here, that it writes a number in
binary. :)

The printf command line utility uses %b for something else: it prints
its argument as an expanded string, with backslashes interpolated.
For example, "foo\\tbar" becomes "foo	bar".  I think this is enough
reason not to use %b for something else in libc out of the box.  Of
course, particular programs registering a printf specifier are a
separate story.

That said, I don't want to discourage a potential glibc contributor.
For what it's worth, glibc's printf code is pretty messy and I would
be very happy to review a proposal for cleaning it up.

Thanks and hope that helps,
Jonathan

  reply	other threads:[~2020-04-26  0:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-25 13:33 Alejandro Colomar
2020-04-26  0:54 ` Jonathan Nieder [this message]
2020-04-26  2:29   ` Alejandro Colomar
2020-04-26 19:18     ` Alejandro Colomar

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=20200426005407.GE877@gmail.com \
    --to=jrnieder@gmail.com \
    --cc=colomar.6.4.3@gmail.com \
    --cc=libc-alpha@sourceware.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).