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

Re: [PATCH 1/7] strbuf: add "include_delim" parameter to "strbuf_split"

From
Christian Couder <chriscool@tuxfamily.org>
Date
Mar 13, 2009, 04:48 UTC
Message-ID
<200903130548.30370.chriscool@tuxfamily.org>
In-Reply-To
<20090312190846.6117@nanako3.lavabit.com>
Le jeudi 12 mars 2009, Nanako Shiraishi a écrit :
Show 11 quoted lines
> Quoting Christian Couder <chriscool@tuxfamily.org>:
> > The "strbuf_split" function used to include the delimiter character
> > at the end of the splited strbufs it produced.
> >
> > This behavior is not wanted in many cases, so this patch adds a new
> > "include_delim" parameter to the function to let us switch it on or
> > off as we want.
>
> Sorry, but I don't understand the above claim. You say "not wanted in
> many cases" but your patch updates the existing callers, all of which do
> want to include the delimiter.

In many programming languages, like Perl and Python for example, there is a "split" function that splits strings, and by default the resulting strings don't include the delimiter.

In Git there are only 2 existing callers and I think this function could be used a lot more if there was a way not to include the delimiter.

In my patch series I add one caller that don't want the delimiter so after my patch series there are already half as many callers that don't want the delimiter.

And by the way, when I mentored the GSoC sequencer project I suggested to Stephan to use strbuf_split, but we also had the problem that the delimiter was included.

> The patch would easily justify itself if it made the callers pass 0 to
> the function to decline the delimiter, and as the result it made the
> codepaths that use the result simpler. But I don't think that is what
> your patch does.

Yes, my patch does not do that, because I think including the delimiter is a special case of the more general and useful behavior of not including it.

Best regards, Christian.

Previous: Christian CouderNext: Junio C Hamano
Message 2 of 9 in “strbuf: add "include_delim" parameter to "strbuf_split"”
  1. 1/7 strbuf: add "include_delim" parameter to "strbuf_split"Christian Couder, Mar 12, 2009
  2. Christian CouderMar 13, 2009
  3. Junio C HamanoMar 13, 2009
  4. Christian CouderMar 13, 2009
  5. Junio C HamanoMar 13, 2009
  6. Migrate bisect to C (was: [PATCH 1/7] strbuf: add "include_delim" parameter to "strbuf_split")Christian Couder, Mar 14, 2009
  7. Junio C HamanoMar 14, 2009
  8. fetch--tool, was Re: Migrate bisect to CJohannes Schindelin, Mar 14, 2009
  9. Junio C HamanoMar 13, 2009

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.