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

Re: [PATCH v2] C: use skip-prefix to avoid hardcoded string length

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 31, 2020, 21:03 UTC
Message-ID
<xmqq36bv9w4f.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CACayv=hcH=dvfup2fzm5-OKYxEyC1m7YBTfpm=6z0BhO=hK-cQ@mail.gmail.com>
Andrei Rybak <rybak.a.v@gmail.com> writes:
Show 13 quoted lines
> On 1/30/20 8:35 PM, Junio C Hamano wrote:
>> We often skip an optional prefix in a string with a hardcoded
>> constant, e.g.
>>
>>       if (starts_with(string, "prefix"))
>>               string += 6;
>>
>> which is less error prone when written
>>
>>       skip_prefix(string, "prefix", &string);
>
> Should the subject line say "skip_prefix" with an underscore instead of
> "skip-prefix" with a dash?

Perhaps. Or "skip_prefix()" to clarify that we are talking about a function.

Previous: Andrei Rybak
Message 7 of 7 in “C: use skip-prefix to avoid hardcoded string length”
  1. C: use skip-prefix to avoid hardcoded string lengthJunio C Hamano, Jan 27, 2020
  2. Jeff KingJan 27, 2020
  3. Junio C HamanoJan 28, 2020
  4. C: use skip-prefix to avoid hardcoded string lengthJunio C Hamano, Jan 30, 2020
  5. Jeff KingJan 31, 2020
  6. Andrei RybakJan 31, 2020
  7. Junio C HamanoJan 31, 2020

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.