Looks perfect. Thanks for doing this Marek. Jose
On Thu, 2011-01-27 at 11:32 -0800, Marek Olšák wrote: > Module: Mesa > Branch: master > Commit: 387fe8dd475d70f098eabc48a8a3696cf0b72275 > URL: > http://cgit.freedesktop.org/mesa/mesa/commit/?id=387fe8dd475d70f098eabc48a8a3696cf0b72275 > > Author: Marek Olšák <mar...@gmail.com> > Date: Wed Jan 26 11:46:39 2011 +0100 > > util: fix parsing debug options > > So that 'foo' can be found in: OPTION=prefixfoosuffix,foo > > Also allow that debug options can be separated by a non-alphanumeric > characters > instead of just commas. > > --- > > src/gallium/auxiliary/util/u_debug.c | 44 +++++++++++++++++++-------------- > 1 files changed, 25 insertions(+), 19 deletions(-) > > diff --git a/src/gallium/auxiliary/util/u_debug.c > b/src/gallium/auxiliary/util/u_debug.c > index 8cf7660..36ce4b5 100644 > --- a/src/gallium/auxiliary/util/u_debug.c > +++ b/src/gallium/auxiliary/util/u_debug.c > @@ -44,6 +44,7 @@ > #include "util/u_surface.h" > > #include <limits.h> /* CHAR_BIT */ > +#include <ctype.h> /* isalnum */ > > void _debug_vprintf(const char *format, va_list ap) > { > @@ -182,36 +183,41 @@ debug_get_num_option(const char *name, long dfault) > > static boolean str_has_option(const char *str, const char *name) > { > - const char *substr; > + /* Empty string. */ > + if (!*str) { > + return FALSE; > + } > > /* OPTION=all */ > if (!util_strcmp(str, "all")) { > return TRUE; > } > > - /* OPTION=name */ > - if (!util_strcmp(str, name)) { > - return TRUE; > - } > + /* Find 'name' in 'str' surrounded by non-alphanumeric characters. */ > + { > + const char *start = str; > + unsigned name_len = strlen(name); > > - substr = util_strstr(str, name); > + /* 'start' is the beginning of the currently-parsed word, > + * we increment 'str' each iteration. > + * if we find either the end of string or a non-alphanumeric character, > + * we compare 'start' up to 'str-1' with 'name'. */ > > - if (substr) { > - unsigned name_len = strlen(name); > + while (1) { > + if (!*str || !isalnum(*str)) { > + if (str-start == name_len && > + !memcmp(start, name, name_len)) { > + return TRUE; > + } > > - /* OPTION=name,... */ > - if (substr == str && substr[name_len] == ',') { > - return TRUE; > - } > + if (!*str) { > + return FALSE; > + } > > - /* OPTION=...,name */ > - if (substr+name_len == str+strlen(str) && substr[-1] == ',') { > - return TRUE; > - } > + start = str+1; > + } > > - /* OPTION=...,name,... */ > - if (substr[-1] == ',' && substr[name_len] == ',') { > - return TRUE; > + str++; > } > } > > > _______________________________________________ > mesa-commit mailing list > mesa-com...@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-commit _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev