Blame SOURCES/0128-Make-it-possible-to-subtract-conditions-from-debug.patch

5593c8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5593c8
From: Peter Jones <pjones@redhat.com>
5593c8
Date: Thu, 17 Jan 2019 13:10:39 -0500
5593c8
Subject: [PATCH] Make it possible to subtract conditions from debug=
5593c8
5593c8
This makes it so you can do set debug to "all,-scripting,-lexer" and get the
5593c8
obvious outcome.  Any negation present will take preference over that
5593c8
conditional, so "all,-scripting,scripting" is the same thing as
5593c8
"all,-scripting".
5593c8
5593c8
Signed-off-by: Peter Jones <pjones@redhat.com>
5593c8
---
5593c8
 grub-core/kern/misc.c | 14 +++++++++++++-
5593c8
 1 file changed, 13 insertions(+), 1 deletion(-)
5593c8
5593c8
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
1c6ba0
index 9a2fae6398..578bf51a5f 100644
5593c8
--- a/grub-core/kern/misc.c
5593c8
+++ b/grub-core/kern/misc.c
5593c8
@@ -164,12 +164,24 @@ int
5593c8
 grub_debug_enabled (const char * condition)
5593c8
 {
5593c8
   const char *debug;
5593c8
+  char *negcond;
5593c8
+  int negated = 0;
5593c8
 
5593c8
   debug = grub_env_get ("debug");
5593c8
   if (!debug)
5593c8
     return 0;
5593c8
 
5593c8
-  if (grub_strword (debug, "all") || grub_strword (debug, condition))
5593c8
+  negcond = grub_zalloc (grub_strlen (condition) + 2);
5593c8
+  if (negcond)
5593c8
+    {
5593c8
+      grub_strcpy (negcond, "-");
5593c8
+      grub_strcpy (negcond+1, condition);
5593c8
+      negated = grub_strword (debug, negcond);
5593c8
+      grub_free (negcond);
5593c8
+    }
5593c8
+
5593c8
+  if (!negated &&
5593c8
+      (grub_strword (debug, "all") || grub_strword (debug, condition)))
5593c8
     return 1;
5593c8
 
5593c8
   return 0;