git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git config: Don't rely on regexec() returning 1 on non-match
@ 2007-12-05 15:11 Björn Steinbrink
  2007-12-05 15:14 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Björn Steinbrink @ 2007-12-05 15:11 UTC (permalink / raw)
  To: gitster; +Cc: git, Björn Steinbrink, Johannes Schindelin

Some systems don't return 1 from regexec() when the pattern does not
match (notably HP-UX which returns 20). Fortunately, there's the
REG_NOMATCH constant, which we can use as the expected return value
and test for that instead of "1 XOR retval".

Bug identified by Dscho and H.Merijn Brand.

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Tested-by: H.Merijn Brand <h.m.brand@xs4all.nl>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 builtin-config.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin-config.c b/builtin-config.c
index 4c9ded3..9fda4e4 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -11,7 +11,7 @@ static regex_t *regexp;
 static int show_keys;
 static int use_key_regexp;
 static int do_all;
-static int do_not_match;
+static int expected_regexec_result;
 static int seen;
 static char delim = '=';
 static char key_delim = ' ';
@@ -38,7 +38,7 @@ static int show_config(const char* key_, const char* value_)
 	if (use_key_regexp && regexec(key_regexp, key_, 0, NULL, 0))
 		return 0;
 	if (regexp != NULL &&
-			 (do_not_match ^
+			 (expected_regexec_result !=
 			  regexec(regexp, (value_?value_:""), 0, NULL, 0)))
 		return 0;
 
@@ -101,7 +101,7 @@ static int get_value(const char* key_, const char* regex_)
 
 	if (regex_) {
 		if (regex_[0] == '!') {
-			do_not_match = 1;
+			expected_regexec_result = REG_NOMATCH;
 			regex_++;
 		}
 
-- 
1.5.3.GIT

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-12-05 19:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-05 15:11 [PATCH] git config: Don't rely on regexec() returning 1 on non-match Björn Steinbrink
2007-12-05 15:14 ` Johannes Schindelin
2007-12-05 19:34   ` Junio C Hamano

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 NNTP newsgroup(s).