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

Re: [PATCH 4/7] ident_split: store begin/end pairs on their own struct

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jun 23, 2014, 01:28 UTC
Message-ID
<CAPig+cSZfm4fL0xBUCMKU5h8gWeSb736T8Rv62QhREg1F=xzqA@mail.gmail.com>
In-Reply-To
<20140618203133.GD23896@sigill.intra.peff.net>
On Wednesday, June 18, 2014, Jeff King <peff@peff.net> wrote:
> Subject: ident_split: store begin/end pairs on their own struct
s/on/in/
Show 20 quoted lines
> When we parse an ident line, we end up with several fields,
> each with a begin/end pointer into the buffer, like:
>
>   const char *name_begin;
>   const char *name_end;
>
> There is nothing except the field names to indicate that
> they are paired. This makes it annoying to write helper
> functions for dealing with the sub-fields, as you have to
> pass both sides. Instead, let's move them into a single
> struct "name", with fields "begin" and "end". This will be
> stored identically, but can be passed as a unit.
>
> We have to do a mechanical update of "s/_/./" at each point
> of use, but other than that, the fields should behave
> identically.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> Suggestions welcome on the name "pointer_pair".
str_segment  ;-)
Show 9 quoted lines
> While writing this series, I also noticed that it would be more
> convenient to have a pointer/len combination rather than two pointers.
> You can convert between them, of course, but I found I was always
> converting the other way.
>
> I left it this way because it makes the mass-update mechanical (and
> because now that I can pass the pair as a unit, I don't have to write
> the same "ident->name_begin, ident->name_end - ident->name_begin" pair
> over and over).
Previous: Jeff KingNext: Jeff King
Message 8 of 16 in “cleaning up determine_author_info”
  1. 0/7 cleaning up determine_author_infoJeff King, Jun 18, 2014
  2. 1/7 commit: provide a function to find a header in a bufferJeff King, Jun 18, 2014
  3. Eric SunshineJun 23, 2014
  4. Jeff KingJun 23, 2014
  5. 2/7 record_author_info: fix memory leak on malformed commitJeff King, Jun 18, 2014
  6. 3/7 record_author_info: use find_commit_headerJeff King, Jun 18, 2014
  7. 4/7 ident_split: store begin/end pairs on their own structJeff King, Jun 18, 2014
  8. Eric SunshineJun 23, 2014
  9. 5/7 use strbufs in date functionsJeff King, Jun 18, 2014
  10. 6/7 determine_author_info: reuse parsing functionsJeff King, Jun 18, 2014
  11. 7/7 determine_author_info: stop leaking name/emailJeff King, Jun 18, 2014
  12. Eric SunshineJun 23, 2014
  13. Erik Faye-LundJun 23, 2014
  14. Eric SunshineJun 23, 2014
  15. Jeff KingJun 23, 2014
  16. Jeff KingJun 23, 2014

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.