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