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