Re: [PATCH v2] remote: align --verbose output with spaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Wang Bing-hua" <louiswpf@xxxxxxxxx> writes:

>> Wouldn't it work to just do (totally untested code snippet below;
>> may have off-by-one around maxwidth)
>> 
>> 				printf("%.*s%s", maxwidth, item->string,
>> 					item->util ? "" : item->util);
>> 
>> without using any strbuf operation?
>
> I did try to use printf at first.
>
> 				printf("%-*s %s\n", maxwidth, item->string,
> 				       item->util ? (const char *)item->util :
> 						    "");
>
> But it broke when there are non-ASCII characters. For example:

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.

> Thank you for reviewing. I'm also debating. It's great to align
> "remote -v" and make it behave similarly to "branch -v". But it might
> not be worth it to complicate the code and break machine readers.
> Do we continue working on this?

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.

THanks.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux