Re: [PATCH v3 2/5] strbuf: refactor strbuf_trim_trailing_ch()
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Jan 27, 2025, 15:07 UTC
- Message-ID
- <CAP8UFD1fD4Rxz1=73kNxSWF+mwmUa4qF0cYUfD+PmMeNwA-cwA@mail.gmail.com>
- In-Reply-To
- <xmqqzfl8t2yl.fsf@gitster.g>
On Sat, Dec 7, 2024 at 7:35 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 18 quoted lines
> > Christian Couder <christian.couder@gmail.com> writes: > > > We often have to split strings at some specified terminator character. > > The strbuf_split*() functions, that we can use for this purpose, > > return substrings that include the terminator character, so we often > > need to remove that character. > > > > When it is a whitespace, newline or directory separator, the > > terminator character can easily be removed using an existing triming > > function like strbuf_rtrim(), strbuf_trim_trailing_newline() or > > strbuf_trim_trailing_dir_sep(). There is no function to remove that > > character when it's not one of those characters though. > > Heh, totally uninteresting (alternative being open coding this one). > If we pass, instead of a single character 'c', an array of characters > to be stripped from the right (like strspn() allows you to skip from > the left), I may have been a bit more receptive, though ;-)
Yeah, I realized strbuf_strip_suffix() can do the job in the following patches, so I dropped this patch and used strbuf_strip_suffix() in the version 4 of this series.