Thread (1 message) 1 message, 1 author, 2016-06-15

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

From: Christian Couder <hidden>
Date: 2016-06-15 22:46:23

Le jeudi 12 mars 2009, Nanako Shiraishi a écrit :
Quoting Christian Couder [off-list ref]:
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help