git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Jeff KingNext: Kyle J. McKay
Message 4 of 5 in “tolower cleanups”
  1. 0/2 tolower cleanupsJeff King, May 22, 2014
  2. 1/2 daemon/config: factor out duplicate xstrdup_tolowerJeff King, May 22, 2014
  3. 2/2 strbuf: add strbuf_tolower functionJeff King, May 22, 2014
  4. Jeff KingMay 22, 2014
  5. Kyle J. McKayMay 22, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.