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

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