From: Christian Couder Date: Fri, 13 Mar 2009 04:48:30 GMT Subject: Re: [PATCH 1/7] strbuf: add "include_delim" parameter to "strbuf_split" Message-ID: <200903130548.30370.chriscool@tuxfamily.org> In-Reply-To: <20090312190846.6117@nanako3.lavabit.com> Le jeudi 12 mars 2009, Nanako Shiraishi a écrit : > Quoting Christian Couder : > > 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.