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

Re: [PATCH 1/3] wildmatch: make dowild() take arbitrary flags

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 19, 2012, 16:32 UTC
Message-ID
<7v4njiatp3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1355922488-20976-2-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 15 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  wildmatch.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/wildmatch.c b/wildmatch.c
> index 3972e26..9586ed9 100644
> --- a/wildmatch.c
> +++ b/wildmatch.c
> @@ -55,7 +55,7 @@ typedef unsigned char uchar;
>  #define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
>  
>  /* Match pattern "p" against "text" */
> -static int dowild(const uchar *p, const uchar *text, int force_lower_case)
> +static int dowild(const uchar *p, const uchar *text, int flags)
It may be better to declare a bitset like this unsigned.
Show 9 quoted lines
>  {
>  	uchar p_ch;
>  
> @@ -64,9 +64,9 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
>  		uchar t_ch, prev_ch;
>  		if ((t_ch = *text) == '\0' && p_ch != '*')
>  			return ABORT_ALL;
> -		if (force_lower_case && ISUPPER(t_ch))
> +		if (flags & FNM_CASEFOLD && ISUPPER(t_ch))

Please add parentheses around bitwise-AND that is used as a boolean, i.e.

	if ((flags & FNM_CASEFOLD) && ISUPPER(t_ch))
Less chance of confusion.
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 3 of 11 in “Bye bye fnmatch()”
  1. 0/3 Bye bye fnmatch()Nguyễn Thái Ngọc Duy, Dec 19, 2012
  2. 1/3 wildmatch: make dowild() take arbitrary flagsNguyễn Thái Ngọc Duy, Dec 19, 2012
  3. Junio C HamanoDec 19, 2012
  4. 2/3 wildmatch: support "no FNM_PATHNAME" modeNguyễn Thái Ngọc Duy, Dec 19, 2012
  5. Junio C HamanoDec 19, 2012
  6. Nguyen Thai Ngoc DuyDec 20, 2012
  7. Nguyen Thai Ngoc DuyDec 20, 2012
  8. 3/3 Convert all fnmatch() calls to wildmatch()Nguyễn Thái Ngọc Duy, Dec 19, 2012
  9. Junio C HamanoDec 19, 2012
  10. Nguyen Thai Ngoc DuyDec 20, 2012
  11. Nguyen Thai Ngoc DuyDec 19, 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.