Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Aug 2020 16:44:55 +0200
From:      Stefan Esser <se@freebsd.org>
To:        rgrimes@freebsd.org
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org>, Ed Maste <emaste@freebsd.org>
Subject:   Re: svn commit: r364321 - head/sbin/ipfw
Message-ID:  <4e233a60-33cc-69db-3f2a-faf3b0c8d4f0@freebsd.org>
In-Reply-To: <202008311409.07VE9Ch9033206@gndrsh.dnsmgr.net>
References:  <202008311409.07VE9Ch9033206@gndrsh.dnsmgr.net>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--0gFKOi6mQqYhil7lFogP9OYGYXnfkj6Tl
Content-Type: multipart/mixed; boundary="7gs3ivT7ODwDWMxtCYESrYXquYtN34LIB";
 protected-headers="v1"
From: Stefan Esser <se@freebsd.org>
To: rgrimes@freebsd.org
Cc: src-committers <src-committers@freebsd.org>,
 svn-src-all <svn-src-all@freebsd.org>,
 svn-src-head <svn-src-head@freebsd.org>, Ed Maste <emaste@freebsd.org>
Message-ID: <4e233a60-33cc-69db-3f2a-faf3b0c8d4f0@freebsd.org>
Subject: Re: svn commit: r364321 - head/sbin/ipfw
References: <202008311409.07VE9Ch9033206@gndrsh.dnsmgr.net>
In-Reply-To: <202008311409.07VE9Ch9033206@gndrsh.dnsmgr.net>

--7gs3ivT7ODwDWMxtCYESrYXquYtN34LIB
Content-Type: multipart/mixed;
 boundary="------------99325335DA063CBDB4C12FA2"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------99325335DA063CBDB4C12FA2
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: quoted-printable

Am 31.08.20 um 16:09 schrieb Rodney W. Grimes:
>> Hrm, it seems this reply ended up in my spam folder; sorry for not
>> replying until now.
>=20
> lol Oh, bad filter :-)
>=20
>>>>                        *strchr(timestr, '\n') =3D '\0';
>>>>                        bprintf(bp, "%s ", timestr);
>>>                                         ^ Isnt this the +1 space?
>>>
>>>>                } else {
>>>> -                     bprintf(bp, "%*s", twidth, " ");
>>>> +                     bprintf(bp, "%*s", twidth + 1, " ");
>>>                                          ^missing from this string?
>>
>> Inserting an extra space in the format string would also work, sure. I=

>> considered doing it that way but in the end decided it's not
>> materially more clear one way or another, so used the patch as
>> submitted.
>=20
> For me the + 1 leads to a "why is this here", where as the space
> in the format string clearly matches the other condition of the else.

In this case it doesn't seem to make much of a difference, since
the string passed is just a blank character (and it does not make
any difference whether a blank is inserted before or behind it).

But in general, I'd rather see "%*s " as the format (which makes
it clear, that the blank is inserted behind the string argument
referenced by %s, not to the left of it - or " %*s" for the other
placement of the extra blank).

But in this particular case I'd use

	printf(bp, "%*s ", twidth, "");

since there is no need to pass a non-zero length argument for %s and
I'd think that the purpose of the format string is to make the columns
line up and then to provide one additional blank as a separator for
maximum length values.

Adding 1 to the width argument of "%*s" adds blanks to the left of
the string, which is obvious given the semantics of the format string,
but still takes some thinking compared to trivially seeing the place
where the extra blank is put in a format string ...

> Also + 1 causes a run time computation, the extra space does not.

Well, the parsing of the extra blank in the format string can be
assumed to cost more cycles than the increment of a variable plus
the extra loop iteration it causes for the alignment blanks that are
written. But the code length will be shorter with the blank in the
format string and the extra cycles will be irrelevant ...

Regards, STefan

--------------99325335DA063CBDB4C12FA2--

--7gs3ivT7ODwDWMxtCYESrYXquYtN34LIB--

--0gFKOi6mQqYhil7lFogP9OYGYXnfkj6Tl
Content-Type: application/pgp-signature; name="OpenPGP_signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="OpenPGP_signature"

-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFqEEo3HqZZwL7MgrcVMTR+u171r99UQFAl9NDOcFAwAAAAAACgkQR+u171r99UTX
Uwf/XuZej6pwHQTRPhhEmaI2kgkVK+2j1RXeZJX6fFqpCKM0f2aGMpQuVeNIeBXaZKoJQH2yPv0x
GowThwwF94r06wU/1LP8xtVSnwdFWUtXvUNLAneyTtGGUuP9T9/KXxarQO/QDWM7ajlvunXG1Bve
zFxUc/sWZVaTcSBfLsb9Y+KnnMGIJc8J9c+Wab6bWdkmBTosBv6oeodzlh3kBNja+I+TdlDhP02X
2/d6+qFzMbWRiXF+BtR2/uS9aHhEUq9fRfXlzbHteLSg2fnX2nPUAcCRH8VQ/glZARfdKJZNzdB6
ckZIOQVD1K5iNBBQkHkiA6W66tj8BxV/wfFWKvTgTg==
=ec9/
-----END PGP SIGNATURE-----

--0gFKOi6mQqYhil7lFogP9OYGYXnfkj6Tl--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4e233a60-33cc-69db-3f2a-faf3b0c8d4f0>