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