From: Jeff King Date: Tue, 29 Jan 2013 11:10:29 GMT Subject: Re: [PATCH 2/6] strbuf: add string-chomping functions Message-ID: <20130129111028.GA11055@sigill.intra.peff.net> In-Reply-To: <5107A146.4000309@alum.mit.edu> On Tue, Jan 29, 2013 at 11:15:34AM +0100, Michael Haggerty wrote: > > +void strbuf_chompmem(struct strbuf *sb, const void *data, size_t len) > > +{ > > + if (sb->len >= len && !memcmp(data, sb->buf + sb->len - len, len)) > > + strbuf_setlen(sb, sb->len - len); > > +} > > + > > +void strbuf_chompstr(struct strbuf *sb, const char *str) > > +{ > > + strbuf_chompmem(sb, str, strlen(str)); > > +} > > + > It might be handy to have these functions return true/false based on > whether the suffix was actually found. Yeah, that sounds reasonable. > Please document the new functions in > Documentation/technical/api-strbuf.txt. Personally I would also > advocate a "docstring" in the header file, but obviously that preference > is the exception rather than the rule in the git project :-( Will do. I need to document the metapack functions, too, so I was thinking about experimenting with some inline documentation systems. -Peff