From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] fix printf regression with alt-form octal, default precision
Date: Thu, 15 Sep 2016 12:22:57 -0400 [thread overview]
Message-ID: <20160915162257.GI15995@brightrain.aerifal.cx> (raw)
In-Reply-To: <20160915160434.GB19101@altlinux.org>
On Thu, Sep 15, 2016 at 07:04:34PM +0300, Dmitry V. Levin wrote:
> Ping?
>
> On Thu, Aug 04, 2016 at 04:07:40AM +0300, Dmitry V. Levin wrote:
> > commit v1.1.5-10-gb91cdbe2bc8b626aa04dc6e3e84345accf34e4b1 that fixed
> > behavior of printf with alt-form octal, zero precision, zero value,
> > at the same time broke alt-form octal with default precision,
> > e. g. printf("%#09o", 1).
> > ---
> > src/stdio/vfprintf.c | 9 ++++++++-
> > 1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
> > index 2ecf769..ac2891c 100644
> > --- a/src/stdio/vfprintf.c
> > +++ b/src/stdio/vfprintf.c
> > @@ -570,7 +570,14 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
> > if (0) {
> > case 'o':
> > a = fmt_o(arg.i, z);
> > - if ((fl&ALT_FORM) && p<z-a+1) p=z-a+1;
> > + if (fl&ALT_FORM) {
> > + if (p >= 0 && p<z-a+1) {
> > + p=z-a+1;
> > + } else if (arg.i) {
> > + prefix+=5;
> > + pl=1;
> > + }
> > + }
This still does not fix all cases, e.g. printf("%#09.0o\n", 0);
I'm going to try to understand what's going on and make a complete
fix.
Rich
next prev parent reply other threads:[~2016-09-15 16:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-04 1:07 Dmitry V. Levin
2016-09-15 16:04 ` Dmitry V. Levin
2016-09-15 16:22 ` Rich Felker [this message]
2016-09-15 16:25 ` Rich Felker
2016-09-15 16:37 ` Rich Felker
2016-09-15 18:14 ` Dmitry V. Levin
2016-09-16 21:58 ` Rich Felker
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=20160915162257.GI15995@brightrain.aerifal.cx \
--to=dalias@libc.org \
--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).