[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAZOWc+OfJhfj2yPwsvqG3=oDy4n1Tr0BYkmZnyEtAfjWMqp3g@mail.gmail.com>
Date: Fri, 30 Jan 2026 17:52:44 +0800
From: Cheng Li <im.lechain@...il.com>
To: David Laight <david.laight.linux@...il.com>
Cc: Willy Tarreau <w@....eu>, Thomas Weißschuh <linux@...ssschuh.net>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] tools/nolibc: support left alignment (-) and zero
padding (0) in printf
David Laight <david.laight.linux@...il.com> 于2026年1月30日周五 16:01写道:
>
> On Fri, 30 Jan 2026 09:05:39 +0800
> Cheng Li <im.lechain@...il.com> wrote:
>
> > David Laight <david.laight.linux@...il.com> 于2026年1月29日周四 18:30写道:
> ...
> > These are great suggestions for a larger refactoring of printf to
> > improve performance and standard compliance.
> > However, to keep this current change minimal and safe, I prefer to
> > focus on fixing the alignment feature first.
> >
> > @Willy, I will send a v3 that removes the '0' flag handling logic to
> > avoid the bug pointed out above.
> >
> > I will rethink how to implement leading zero pad support.
>
> You made me look at the code.
> A simple refactor saved 98 bytes (about 10%).
>
> I will look at adding support for field precision - which is what
> is needed for leading zeros.
> Will use up some of the saved space, but probably not all of it.
>
> I'll base any patch on top of your change.
Hi David,
Just a heads-up: I actually sent out a patch set implementing zero
padding (with explicit sign handling) right before reading your
message about adding precision support.
However, I agree that implementing full field precision is the cleaner
and more standard way to handle leading zeros. My patch handles it by
parsing the output buffer, which is less elegant.
Also, looking at my just-sent zero-padding patch again, I suspect I
might have missed adjusting the remaining length 'w' after skipping
the sign, which would be a bug.
So, let's stick to the plan:
I will discard my zero-padding attempt and focus on sending a **v4 of
the Left Alignment patch**. I will implement your suggested
optimization (swapping the logic to share the padding loop) to make it
a solid base for your future precision work.
Thanks,
Cheng
> David
Powered by blists - more mailing lists