public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <colomar.6.4.3@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: libc-alpha@sourceware.org
Subject: Re: printf %b
Date: Sun, 26 Apr 2020 04:29:39 +0200	[thread overview]
Message-ID: <6e163d3e-fc4f-7a87-6168-890c21a00dde@gmail.com> (raw)
In-Reply-To: <20200426005407.GE877@gmail.com>



On 4/26/20 2:54 AM, Jonathan Nieder wrote:
> 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. :)

Yup, I forgot the main point :)

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

Hmmm.  Good point.  Maybe, given that binary doesn't have letters such 
as hex does, we don't need both ``%b`` and ``%B``.  We could have just 
``%B`` (if it isn't already taken by some other thing) and use it for 
binary.

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

I can try.  I do agree that it is messy; maybe too much for me to 
understand it.

> 
> Thanks and hope that helps,
> Jonathan


Thank you very much.

		Alex.

  reply	other threads:[~2020-04-26  2:29 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
2020-04-26  2:29   ` Alejandro Colomar [this message]
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=6e163d3e-fc4f-7a87-6168-890c21a00dde@gmail.com \
    --to=colomar.6.4.3@gmail.com \
    --cc=jrnieder@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).