linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Pierre Carrier <pierre@spotify.com>
Cc: Joe Perches <joe@perches.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] lib/vsprintf.c: "%#o",0 becomes '0' instead of '00'
Date: Mon, 7 May 2012 13:55:23 +1000	[thread overview]
Message-ID: <20120507135523.59bcc702ac15348c237fc2fd@canb.auug.org.au> (raw)
In-Reply-To: <CAPXGRDkgEKFU7fVDqz33C9vqjdxmBYTbPEPbcfhpkg0NxOJz-g@mail.gmail.com>

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

Hi Pierre,

On Mon, 7 May 2012 04:20:18 +0200 Pierre Carrier <pierre@spotify.com> wrote:
>
> On Mon, May 7, 2012 at 3:59 AM, Joe Perches <joe@perches.com> wrote:
> > If you do this, why not change 0-7 instead of just 0?
> 
> Consistency with POSIX *printf.
> 
> "#: Specifies that the value is to be converted to an alternative
> form. For o conversion, it increases the precision (if necessary) to
> force the first digit of the result to be zero."
> -- http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html
> 
> % cat octal.c;gcc -o octal octal.c;./octal
> #include <stdio.h>
> void main() {
>         int i;
>         for (i=0;i<10;i++) printf("%#o ", i);
>         puts("");
> }
> 0 01 02 03 04 05 06 07 010 011

Yes, if we are going to follow anything, then it may as well be that.

However just to add more mess, the next part of that section of the standard says:

"For x or X conversion specifiers, a non-zero result shall have 0x (or
0X) prefixed to it."

so we should also do:

0 0x1 ...

However, I think we expect 0x0, so changing it is, I think, unnecessary.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2012-05-07  3:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-05 14:32 [PATCH 1/1] lib/vsprintf.c: "%#o",0 becomes '0' instead of '00' Pierre Carrier
2012-05-07  0:19 ` Stephen Rothwell
2012-05-07  1:20   ` Pierre Carrier
2012-05-07  1:59     ` Joe Perches
2012-05-07  2:20       ` Pierre Carrier
2012-05-07  3:55         ` Stephen Rothwell [this message]
2012-05-07  3:56     ` Stephen Rothwell

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=20120507135523.59bcc702ac15348c237fc2fd@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=akpm@linux-foundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre@spotify.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.
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).