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

Re: [PATCH 2/2] grep: mark "haystack" buffers as const

From
Jeff King <peff@peff.net>
Date
Sep 21, 2021, 02:05 UTC
Message-ID
<YUk9+p1j3GNwZ1DL@coredump.intra.peff.net>
In-Reply-To
<YUk4vnMQHApY99Lb@coredump.intra.peff.net>
On Mon, Sep 20, 2021 at 09:43:26PM -0400, Jeff King wrote:
> When we're grepping in a buffer, we don't need to modify it. So we can
> take "const char *" buffers, rather than "char *". This can avoid some
> awkward casts in our callers.

Sorry, this patch should have touched strip_timestamp(), too. I had originally done it in the earlier patch, but because we pass a pointer-to-pointer, the compiler got mad about the mis-matched type from the caller. So I reverted it there, but forgot to add it back in here.

At any rate, these are mostly for illustration. They'd need a little rebasing if not put on top of your patches anyway.

-Peff
Previous: Jeff KingNext: Hamza Mahfooz
Message 7 of 10 in “grep: refactor next_match() and match_one_pattern() for external use”
  1. 1/2 grep: refactor next_match() and match_one_pattern() for external useHamza Mahfooz, Sep 21, 2021
  2. 2/2 pretty: colorize pattern matches in commit messagesHamza Mahfooz, Sep 21, 2021
  3. Jeff KingSep 21, 2021
  4. Jeff KingSep 21, 2021
  5. 1/2 grep: stop modifying buffer in strip_timestampJeff King, Sep 21, 2021
  6. 2/2 grep: mark "haystack" buffers as constJeff King, Sep 21, 2021
  7. Jeff KingSep 21, 2021
  8. Hamza MahfoozSep 21, 2021
  9. Jeff KingSep 21, 2021
  10. Jeff KingSep 21, 2021

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.