git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] submodule--helper: do not call utf8_fprintf() unnecessarily

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 28, 2017, 20:58 UTC
Message-ID
<xmqqwp7vvngg.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAGZ79kbvncDoSuj8AF_rdDoEzavdzEaLxqr7NXi1_eCLNt01Kg@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 22 quoted lines
> On Wed, Jun 28, 2017 at 1:38 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> The helper function utf8_fprintf(fp, ...) has exactly the same
>> effect to the output stream fp as fprintf(fp, ...) does, and the
>> only difference is that its return value counts in display columns
>> consumed (assuming that the payload is encoded in UTF-8), as opposed
>> to number of bytes.
>>
>> There is no reason to call it unless the caller cares about its
>> return value.
>>
>> Signed-off-by: Junio C Hamano <gitster@pobox.com>
>> ---
>>
>>  * The helper was introduced at c0821965 ("Add utf8_fprintf helper
>>    that returns correct number of columns", 2013-02-09), which also
>>    taught the help text output from the parse_options API to use it
>>    to align columns.  These original callers naturally do use the
>>    returned value and left alone by this fix, which corrects all the
>>    later callers that misuses it.
>>
>
> The patch looks correct.

Thanks. I had a small voice back in my head telling me that I may have misread the code and this patch breaks things, which you cleared up for me ;-)

Previous: Stefan BellerNext: Stefan Beller
Message 3 of 4 in “submodule--helper: do not call utf8_fprintf() unnecessarily”
  1. submodule--helper: do not call utf8_fprintf() unnecessarilyJunio C Hamano, Jun 28, 2017
  2. Stefan BellerJun 28, 2017
  3. Junio C HamanoJun 28, 2017
  4. Stefan BellerJun 28, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.