Exact debug token check and verify tokens are listed

This commit is contained in:
Christian Dywan 2012-08-26 14:16:14 +02:00
parent b5ff08c4c0
commit f41498e16c
1 changed files with 9 additions and 6 deletions

View File

@ -1566,13 +1566,13 @@ gboolean
midori_debug (const gchar* token) midori_debug (const gchar* token)
{ {
static const gchar* debug_token = NULL; 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) if (debug_token == NULL)
{ {
const gchar* debug = g_getenv ("MIDORI_DEBUG"); gchar* found_token;
const gchar* debug_tokens = "soup:1 soup:2 soup:3 cookies"; if (debug && (found_token = strstr (full_debug_tokens, debug)) && *found_token == ' ')
const gchar* full_debug_tokens = "adblock:1 adblock:2 startup bookmarks";
if (debug && strstr (full_debug_tokens, debug))
{ {
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
debug_token = g_intern_static_string (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); g_warning ("Value '%s' for MIDORI_DEBUG requires a full debugging build.", debug);
#endif #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); debug_token = g_intern_static_string (debug);
else if (debug) else if (debug)
g_warning ("Unrecognized value '%s' for MIDORI_DEBUG.", debug); g_warning ("Unrecognized value '%s' for MIDORI_DEBUG.", debug);
@ -1593,6 +1593,9 @@ midori_debug (const gchar* token)
debug_tokens, full_debug_tokens); 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); return debug_token == g_intern_static_string (token);
} }