From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoffer Dall Subject: Re: [PATCH 1/3] printf: support field padding Date: Thu, 2 Jan 2014 09:25:56 -0800 Message-ID: <20140102172556.GF27806@cbox> References: <1386932286-10723-1-git-send-email-drjones@redhat.com> <1386932286-10723-2-git-send-email-drjones@redhat.com> <20131229063144.GI13601@cbox> <20140102170948.GH9725@hawk.usersys.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org To: Andrew Jones Return-path: Received: from mail-pb0-f47.google.com ([209.85.160.47]:34339 "EHLO mail-pb0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751606AbaABRZm (ORCPT ); Thu, 2 Jan 2014 12:25:42 -0500 Received: by mail-pb0-f47.google.com with SMTP id um1so14544766pbc.6 for ; Thu, 02 Jan 2014 09:25:38 -0800 (PST) Content-Disposition: inline In-Reply-To: <20140102170948.GH9725@hawk.usersys.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Jan 02, 2014 at 06:09:48PM +0100, Andrew Jones wrote: > On Sat, Dec 28, 2013 at 10:31:44PM -0800, Christoffer Dall wrote: > > > + > > > + if (npad < 0) { > > > + char pad = props.pad; > > > + if (pad == '0') /* ignore '0' flag with '-' flag */ > > > + pad = ' '; > > > > there are only the two options, so you can drop the check if > > you like. > > true. removed. > > > > +static int fmtnum(const char **fmt) > > > +{ > > > + const char *f = *fmt; > > > + int len = 0, num; > > > + > > > + if (*f == '-') > > > + ++f, ++len; > > > > oh wow, this deserves a small comment saying that negative values are > > used to add trailing padding instead of leading. > > You mean something beyond "man 3 printf; /flag"? :-) > yes, that's a functional description, not helping the reader of the implememtation. But ok, once this works, it's not likely to pass many eyes again. > > > > > + > > > + while (*f >= '0' && *f <= '9') > > > + ++f, ++len; > > > + > > > + num = atol(*fmt); > > > + *fmt += len; > > > + return num; > > > } > > > > some funny indentation is back here... Better check your entire patch > > for that. > > The whole file has the funny indentation, I just followed suit. The > alternative is to add a patch that "fixes" all the pre-existing lib/* > files first, but for this patch I didn't think it was worth it. > fair enough, but it really hurts when reading patches so we should fix this some time... -Christoffer