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

Re: [PATCH 1/3] add strnncmp() function

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 16, 2014, 20:16 UTC
Message-ID
<20140616201644.GN8557@google.com>
In-Reply-To
<58e0ac866bdeb8cc6e06cf553a459af351ccfd1b.1402945507.git.jmmahler@gmail.com>
Jeremiah Mahler wrote:
> Add a strnncmp() function which behaves like strncmp() except it uses
> the length of both strings instead of just one.
The above description isn't very clear to me.  Problems:
 - strncmp compares prefixes of \0-terminated strings.  This function
   compares two binary buffers which can contain \0
 - strncmp is a comparison function and can even be used with functions
   like qsort (for operations like "sort on the first two characters").
   This function returns 0 or nonzero.
Would something like
  /* true if buffers have the same length and are byte-for-byte identical */
  int bufeq(const char *, int, const char *, int);
(or buf_equal, array_equal etc) make sense?
Previous: Jeremiah MahlerNext: Jeremiah Mahler
Message 3 of 8 in “add strnncmp() function”
  1. 0/3 add strnncmp() functionJeremiah Mahler, Jun 16, 2014
  2. 1/3 add strnncmp() functionJeremiah Mahler, Jun 16, 2014
  3. Jonathan NiederJun 16, 2014
  4. 2/3 tree-walk: simplify via strnncmp()Jeremiah Mahler, Jun 16, 2014
  5. Jonathan NiederJun 16, 2014
  6. Jeremiah MahlerJun 17, 2014
  7. 3/3 unpack-trees: simplify via strnncmp()Jeremiah Mahler, Jun 16, 2014
  8. Jonathan NiederJun 16, 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.