Re: [PATCH 2/2] strbuf: add strbuf_tolower function
- From
Jeff King <peff@peff.net>
- Date
- May 22, 2014, 13:42 UTC
- Message-ID
- <20140522134253.GA16408@sigill.intra.peff.net>
- In-Reply-To
- <CAP8UFD0PkA_VokFpRkdaKE2UW1AtL6mCY2bOSxOCqX_C9wB=OQ@mail.gmail.com>
[re-adding list cc]
On Thu, May 22, 2014 at 03:16:45PM +0200, Christian Couder wrote:
Show 12 quoted lines
> > +void strbuf_tolower(struct strbuf *sb)
> > +{
> > + char *p;
> > + for (p = sb->buf; *p; p++)
> > + *p = tolower(*p);
> > +}
>
> Last time I tried a change like the above, I was told that strbufs are
> buffers that can contain NUL bytes. So maybe it should be:
>
> for (p = sb->buf; p < sb->buf + sb->len; p++)
> *p = tolower(*p);Hah. I wrote it like that originally, and in review was asked to switch it. I agree that it might be worth keeping strbuf functions 8bit-clean. The original intent of the strbuf code was to make C strings easier to use, but I think we sometimes use them as general buffers, too.
-Peff