git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Masahiro Yamada" <masahiroy@kernel.org>
Subject: [PATCH v2 3/5] wildmatch: remove NEGATE_CLASS(2) macros with trivial refactoring
Date: Sun, 26 Feb 2023 20:50:19 +0900	[thread overview]
Message-ID: <20230226115021.1681834-4-masahiroy@kernel.org> (raw)
In-Reply-To: <20230226115021.1681834-1-masahiroy@kernel.org>

The other glob patterns are hard-coded in dowild(). There is no need
to macrofy '!' or '^'. Remove the NEGATE_CLASS and REGATE_CLASS2
defines, then refactor the code.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

(no changes since v1)

 wildmatch.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/wildmatch.c b/wildmatch.c
index a510b3fd23..93800b8eac 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -14,10 +14,6 @@
 
 typedef unsigned char uchar;
 
-/* What character marks an inverted character class? */
-#define NEGATE_CLASS	'!'
-#define NEGATE_CLASS2	'^'
-
 #define CC_EQ(class, len, litmatch) ((len) == sizeof (litmatch)-1 \
 				    && *(class) == *(litmatch) \
 				    && strncmp((char*)class, litmatch, len) == 0)
@@ -137,12 +133,8 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
 			return WM_ABORT_ALL;
 		case '[':
 			p_ch = *++p;
-#ifdef NEGATE_CLASS2
-			if (p_ch == NEGATE_CLASS2)
-				p_ch = NEGATE_CLASS;
-#endif
 			/* Assign literal 1/0 because of "matched" comparison. */
-			negated = p_ch == NEGATE_CLASS ? 1 : 0;
+			negated = p_ch == '!' || p_ch == '^' ? 1 : 0;
 			if (negated) {
 				/* Inverted character class. */
 				p_ch = *++p;
-- 
2.34.1


  parent reply	other threads:[~2023-02-26 11:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-26 11:50 [PATCH v2 0/5] Clean up wildmatch.c Masahiro Yamada
2023-02-26 11:50 ` [PATCH v2 1/5] git-compat-util: add isblank() and isgraph() Masahiro Yamada
2023-02-26 18:45   ` René Scharfe
2023-02-27 19:39     ` Junio C Hamano
2023-02-26 11:50 ` [PATCH v2 2/5] wildmatch: remove IS*() macros Masahiro Yamada
2023-02-26 11:50 ` Masahiro Yamada [this message]
2023-02-26 11:50 ` [PATCH v2 4/5] wildmatch: use char instead of uchar Masahiro Yamada
2023-02-27 20:07   ` Junio C Hamano
2023-02-26 11:50 ` [PATCH v2 5/5] wildmatch: more cleanups after killing uchar Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230226115021.1681834-4-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).