From f41498e16ced1c2b8804dae033f2354dd688f0af Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 26 Aug 2012 14:16:14 +0200 Subject: [PATCH] Exact debug token check and verify tokens are listed --- midori/midori-app.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/midori/midori-app.c b/midori/midori-app.c index 1c87460d..f73fe8f9 100644 --- a/midori/midori-app.c +++ b/midori/midori-app.c @@ -1566,13 +1566,13 @@ gboolean midori_debug (const gchar* token) { static const gchar* debug_token = NULL; - g_return_val_if_fail (token != NULL, FALSE); + const gchar* debug = g_getenv ("MIDORI_DEBUG"); + const gchar* debug_tokens = "soup soup:1 soup:2 soup:3 cookies "; + const gchar* full_debug_tokens = "adblock:1 adblock:2 startup bookmarks "; if (debug_token == NULL) { - const gchar* debug = g_getenv ("MIDORI_DEBUG"); - const gchar* debug_tokens = "soup:1 soup:2 soup:3 cookies"; - const gchar* full_debug_tokens = "adblock:1 adblock:2 startup bookmarks"; - if (debug && strstr (full_debug_tokens, debug)) + gchar* found_token; + if (debug && (found_token = strstr (full_debug_tokens, debug)) && *found_token == ' ') { #ifdef G_ENABLE_DEBUG debug_token = g_intern_static_string (debug); @@ -1580,7 +1580,7 @@ midori_debug (const gchar* token) g_warning ("Value '%s' for MIDORI_DEBUG requires a full debugging build.", debug); #endif } - else if (debug && strstr (debug_tokens, debug)) + else if (debug && (found_token = strstr (debug_tokens, debug)) && *found_token == ' ') debug_token = g_intern_static_string (debug); else if (debug) g_warning ("Unrecognized value '%s' for MIDORI_DEBUG.", debug); @@ -1593,6 +1593,9 @@ midori_debug (const gchar* token) debug_tokens, full_debug_tokens); } } + if (debug_token != g_intern_static_string ("NONE") + && !strstr (debug_tokens, token) && !strstr (full_debug_tokens, token)) + g_warning ("Token '%s' passed to midori_debug is not a known token.", token); return debug_token == g_intern_static_string (token); } -- 2.39.5