From: Wang Bing-hua Date: Thu, 19 Dec 2024 02:14:30 GMT Subject: Re: [PATCH v2] remote: align --verbose output with spaces Message-ID: <1812724a6e98b9f0.772d5fa147f10a1c.6ab8f72f53fdfcab@host> In-Reply-To: On 18/12/2024 07:39, Junio C Hamano wrote: > Ah, of course, I should have double-checked, but it should be more > like > > printf("%.*s%s%s", > maxwidth + 1 - utf8_strwidth(item->string), "", > item->string, > item->util ? item->util : ""); > > meaning > > (1) the first output field must have maxwidth+1 - the display width > the second output field takes. The field's contents is empty, so > we get enough SP padded to make the total of this first field > and the second field to make maxwidth+1. > > (2) the second output field is item->string itself. > > (3) the third output field has item->util if exists. Understood. Thanks for the explanation. Here is a tested code snippet for the record: printf("%s%*s %s\n", item->string, maxwidth - utf8_strwidth(item->string), "", item->util ? (const char *)item->util : ""); > You already know from my initial reaction what my answer would be, > but I am inclined to hear from others before we make a decision. I see. Thanks.