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

Re: [PATCH 3/3] implement pattern matching in ce_path_match

From
Samuel Tardieu <sam@rfc1149.net>
Date
Jan 14, 2009, 16:18 UTC
Message-ID
<2009-01-14-17-18-40+trackit+sam@rfc1149.net>
In-Reply-To
<alpine.DEB.1.00.0901141641500.3586@pacific.mpi-cbg.de>
>>>>> "Johannes" == Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Dscho> I would prefer something like this:
My taste would favor:
  static int has_special(const char *p)
  {
    for (; *p; p++)
      if (isspecial(*p))
        return 1;
    return 0;
  }

as it underlines the intent (loop over "p" characters and stop no later than the end of the string) while avoiding using side effects in the body to increment the pointer. This habit comes from Ada, where loop indices are considered read-only in the loop body.

It also eases further extensions such as
  static int has_special(const char *p)
  {
    for (; *p; p++)
      if (isspecial(*p) || isveryspecial(*p))
        return 1;
    return 0;
  }
without having to move the "++" somewhere else.
Dscho> but that is probably a matter of taste.
Agreed.
  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/
Previous: Sverre RabbelierNext: Jeff King
Message 8 of 16 in “fix "git add" pattern matching”
  1. 0/3 fix "git add" pattern matchingClemens Buchacher, Jan 14, 2009
  2. 1/3 clean up pathspec matchingClemens Buchacher, Jan 14, 2009
  3. 2/3 remove pathspec_match, use match_pathspec insteadClemens Buchacher, Jan 14, 2009
  4. 3/3 implement pattern matching in ce_path_matchClemens Buchacher, Jan 14, 2009
  5. Clemens BuchacherJan 14, 2009
  6. Johannes SchindelinJan 14, 2009
  7. Sverre RabbelierJan 14, 2009
  8. Samuel TardieuJan 14, 2009
  9. Jeff KingJan 14, 2009
  10. Junio C HamanoJan 14, 2009
  11. Clemens BuchacherJan 14, 2009
  12. Junio C HamanoJan 14, 2009
  13. Clemens BuchacherJan 15, 2009
  14. Junio C HamanoJan 16, 2009
  15. Johannes SchindelinJan 14, 2009
  16. Clemens BuchacherJan 14, 2009

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.