Thread (43 messages) 43 messages, 3 authors, 2021-01-24
STALE1996d
Revisions (2)
  1. v1 [diff vs current]
  2. v1 current

[PATCH v3 2/4] grep/pcre2: simplify boolean spaghetti

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-01-24 02:14:02
Subsystem: the rest · Maintainer: Linus Torvalds

Simplify an expression I added in 870eea8166 (grep: do not enter
PCRE2_UTF mode on fixed matching, 2019-07-26) by using a simple
application of De Morgan's laws[1]. I.e.:

    NOT(A && B) is Equivalent to (NOT(A) OR NOT(B))

1. https://en.wikipedia.org/wiki/De_Morgan%27s_laws

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 grep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grep.c b/grep.c
index efeb6dc58d..0bb772f727 100644
--- a/grep.c
+++ b/grep.c
@@ -491,7 +491,7 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
 		options |= PCRE2_CASELESS;
 	}
 	if (!opt->ignore_locale && is_utf8_locale() && has_non_ascii(p->pattern) &&
-	    !(!opt->ignore_case && (p->fixed || p->is_fixed)))
+	    (opt->ignore_case || !(p->fixed || p->is_fixed)))
 		options |= PCRE2_UTF;
 
 	p->pcre2_pattern = pcre2_compile((PCRE2_SPTR)p->pattern,
-- 
2.29.2.222.g5d2a92d10f8
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help