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

Re: [PATCH] wildmatch: correct isprint and isspace

From
JSJan H. Schönherr <schnhrr@cs.tu-berlin.de>
Date
Nov 15, 2012, 17:13 UTC
Message-ID
<50A522B5.7080206@cs.tu-berlin.de>
In-Reply-To
<1352981983-22005-1-git-send-email-pclouds@gmail.com>
Am 15.11.2012 13:19, schrieb Nguyễn Thái Ngọc Duy:
Show 12 quoted lines
>  On Thu, Nov 15, 2012 at 2:30 AM, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
>  > Nevertheless, it's unfortunate that we have an isspace() that *almost* does
>  > what the widely known thing of the same name does.  I'd shy away from
>  > changing git's version directly, because it's used more than a hundred times
>  > in the code, and estimating the impact of adding \v and \f to it.
>  > Perhaps renaming it to isgitspace() is a good first step, followed by
>  > adding a "standard" version of isspace() for wildmatch?
> 
>  There are just too many call sites of isspace() and there is a risk
>  of new call sites coming in independently. So I think keeping isspace()
>  as-is and using a different name for the standard version is probably
>  a better choice.

After having a closer look, where wildmatch is actually used -- matching filenames -- and I've not yet seen \v or \f in a filename, it's possibly unnecessary to do anything about isspace() right now.

(It's probably more an issue that filenames can be localized, and we only support unlocalized character classes.)

Show 14 quoted lines
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 02f48f6..d4c3fda 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -486,6 +486,7 @@ extern const unsigned char sane_ctype[256];
>  #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
>  #define isascii(x) (((x) & ~0x7f) == 0)
>  #define isspace(x) sane_istest(x,GIT_SPACE)
> +#define isspace_posix(x) (((x) >= 9 && (x) <= 13) || (x) == 32)
>  #define isdigit(x) sane_istest(x,GIT_DIGIT)
>  #define isalpha(x) sane_istest(x,GIT_ALPHA)
>  #define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
> @@ -499,7 +500,8 @@ extern const unsigned char sane_ctype[256];
>  #define isxdigit(x) (hexval_table[x] != -1)
This was from a previous patch, but maybe: "hexval_table[(unsigned char)x]"
Show 5 quoted lines
>  #define isprint(x) (sane_istest(x, GIT_ALPHA | GIT_DIGIT | GIT_SPACE | \
>  		GIT_PUNCT | GIT_REGEX_SPECIAL | GIT_GLOB_SPECIAL | \
> -		GIT_PATHSPEC_MAGIC))
> +		GIT_PATHSPEC_MAGIC) && \
> +		(x) >= 32)
May I suggest the current is_print() implementation in master:
#define isprint(x) ((x) >= 0x20 && (x) <= 0x7e)
To summarize my opinion:

I no longer see a reason to correct isspace() (unless somebody with an actual use case complains), and a more POSIXly isprint() is already in master.

=> Nothing to do. :)

Regards Jan

Previous: Nguyễn Thái Ngọc DuyNext: Nguyen Thai Ngoc Duy
Message 21 of 37 in “nd/wildmatch”
  1. 00/12 nd/wildmatchNguyễn Thái Ngọc Duy, Oct 14, 2012
  2. 01/12 ctype: make sane_ctype[] const arrayNguyễn Thái Ngọc Duy, Oct 14, 2012
  3. 02/12 ctype: support iscntrl, ispunct, isxdigit and isprintNguyễn Thái Ngọc Duy, Oct 14, 2012
  4. Junio C HamanoOct 14, 2012
  5. Nguyen Thai Ngoc DuyOct 14, 2012
  6. René ScharfeOct 14, 2012
  7. Nguyen Thai Ngoc DuyOct 14, 2012
  8. René ScharfeOct 14, 2012
  9. Nguyen Thai Ngoc DuyOct 14, 2012
  10. Jan H. SchönherrOct 17, 2012
  11. Nguyen Thai Ngoc DuyOct 17, 2012
  12. Correct Git's version of isprint and isspaceNguyễn Thái Ngọc Duy, Nov 13, 2012
  13. Jan H. SchönherrNov 13, 2012
  14. René ScharfeNov 13, 2012
  15. René ScharfeNov 13, 2012
  16. Linus TorvaldsNov 13, 2012
  17. Linus TorvaldsNov 13, 2012
  18. René ScharfeNov 14, 2012
  19. Johannes SixtNov 13, 2012
  20. wildmatch: correct isprint and isspaceNguyễn Thái Ngọc Duy, Nov 15, 2012
  21. Jan H. SchönherrNov 15, 2012
  22. Nguyen Thai Ngoc DuyNov 16, 2012
  23. 03/12 Import wildmatch from rsyncNguyễn Thái Ngọc Duy, Oct 14, 2012
  24. 04/12 wildmatch: remove unnecessary functionsNguyễn Thái Ngọc Duy, Oct 14, 2012
  25. Junio C HamanoOct 14, 2012
  26. Nguyen Thai Ngoc DuyOct 14, 2012
  27. 05/12 Integrate wildmatch to gitNguyễn Thái Ngọc Duy, Oct 14, 2012
  28. Junio C HamanoOct 14, 2012
  29. Torsten BögershausenOct 14, 2012
  30. 06/12 t3070: disable unreliable fnmatch testsNguyễn Thái Ngọc Duy, Oct 14, 2012
  31. 07/12 wildmatch: make wildmatch's return value compatible with fnmatchNguyễn Thái Ngọc Duy, Oct 14, 2012
  32. Junio C HamanoOct 14, 2012
  33. 08/12 wildmatch: remove static variable force_lower_caseNguyễn Thái Ngọc Duy, Oct 14, 2012
  34. 09/12 wildmatch: fix case-insensitive matchingNguyễn Thái Ngọc Duy, Oct 14, 2012
  35. 10/12 wildmatch: adjust "**" behaviorNguyễn Thái Ngọc Duy, Oct 14, 2012
  36. 11/12 wildmatch: make /**/ match zero or more directoriesNguyễn Thái Ngọc Duy, Oct 14, 2012
  37. 12/12 Support "**" wildcard in .gitignore and .gitattributesNguyễn Thái Ngọc Duy, Oct 14, 2012

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.