mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 04:15:49 +01:00
When matching debug flag keys, ignore case and accept any of comma, colon,
2006-07-06 Behdad Esfahbod <behdad@gnome.org> * glib/gutils.c (g_parse_debug_string): When matching debug flag keys, ignore case and accept any of comma, colon, semicolon, space, and tab as separators. Also, match dash with underscore.
This commit is contained in:
parent
6d9d3a111e
commit
4e866367a7
@ -1,3 +1,9 @@
|
|||||||
|
2006-07-06 Behdad Esfahbod <behdad@gnome.org>
|
||||||
|
|
||||||
|
* glib/gutils.c (g_parse_debug_string): When matching debug flag keys,
|
||||||
|
ignore case and accept any of comma, colon, semicolon, space, and tab
|
||||||
|
as separators. Also, match dash with underscore.
|
||||||
|
|
||||||
2006-07-05 Matthias Clasen <mclasen@redhat.com>
|
2006-07-05 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gbase64.c: Fix typos in the docs. (#346660, Mark
|
* glib/gbase64.c: Fix typos in the docs. (#346660, Mark
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2006-07-06 Behdad Esfahbod <behdad@gnome.org>
|
||||||
|
|
||||||
|
* glib/gutils.c (g_parse_debug_string): When matching debug flag keys,
|
||||||
|
ignore case and accept any of comma, colon, semicolon, space, and tab
|
||||||
|
as separators. Also, match dash with underscore.
|
||||||
|
|
||||||
2006-07-05 Matthias Clasen <mclasen@redhat.com>
|
2006-07-05 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gbase64.c: Fix typos in the docs. (#346660, Mark
|
* glib/gbase64.c: Fix typos in the docs. (#346660, Mark
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h> /* For tolower() */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef HAVE_PWD_H
|
#ifdef HAVE_PWD_H
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@ -552,16 +553,33 @@ g_find_program_in_path (const gchar *program)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
debug_key_matches (const gchar *key,
|
||||||
|
const gchar *token,
|
||||||
|
guint length)
|
||||||
|
{
|
||||||
|
for (; length; length--, key++, token++)
|
||||||
|
{
|
||||||
|
char k = (*key == '_') ? '-' : tolower (*key );
|
||||||
|
char t = (*token == '_') ? '-' : tolower (*token);
|
||||||
|
|
||||||
|
if (k != t)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *key == '\0';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_parse_debug_string:
|
* g_parse_debug_string:
|
||||||
* @string: a list of debug options separated by ':' or "all"
|
* @string: a list of debug options separated by colons, spaces, or
|
||||||
* to set all flags.
|
* commas; or the string "all" to set all flags.
|
||||||
* @keys: pointer to an array of #GDebugKey which associate
|
* @keys: pointer to an array of #GDebugKey which associate
|
||||||
* strings with bit flags.
|
* strings with bit flags.
|
||||||
* @nkeys: the number of #GDebugKey<!-- -->s in the array.
|
* @nkeys: the number of #GDebugKey<!-- -->s in the array.
|
||||||
*
|
*
|
||||||
* Parses a string containing debugging options separated
|
* Parses a string containing debugging options
|
||||||
* by ':' into a %guint containing bit flags. This is used
|
* into a %guint containing bit flags. This is used
|
||||||
* within GDK and GTK+ to parse the debug options passed on the
|
* within GDK and GTK+ to parse the debug options passed on the
|
||||||
* command line or through environment variables.
|
* command line or through environment variables.
|
||||||
*
|
*
|
||||||
@ -594,17 +612,16 @@ g_parse_debug_string (const gchar *string,
|
|||||||
|
|
||||||
while (*p)
|
while (*p)
|
||||||
{
|
{
|
||||||
q = strchr (p, ':');
|
q = strpbrk (p, ":;, \t");
|
||||||
if (!q)
|
if (!q)
|
||||||
q = p + strlen(p);
|
q = p + strlen(p);
|
||||||
|
|
||||||
for (i = 0; i < nkeys; i++)
|
for (i = 0; i < nkeys; i++)
|
||||||
if (g_ascii_strncasecmp (keys[i].key, p, q - p) == 0 &&
|
if (debug_key_matches (keys[i].key, p, q - p))
|
||||||
keys[i].key[q - p] == '\0')
|
|
||||||
result |= keys[i].value;
|
result |= keys[i].value;
|
||||||
|
|
||||||
p = q;
|
p = q;
|
||||||
if (*p == ':')
|
if (*p)
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user