[Mesa-dev] Mesa (master): util: require debug options to be separated by commas
Marek Olšák
maraeo at gmail.com
Wed Jan 26 02:45:43 PST 2011
Hi Michal,
Is this what you have in mind?
diff --git a/src/gallium/auxiliary/util/u_debug.c
b/src/gallium/auxiliary/util/u_debug.c
index 8cf7660..cb4d60d 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -180,6 +180,13 @@ debug_get_num_option(const char *name, long dfault)
return result;
}
+static boolean is_alphanumeric(char c)
+{
+ return (c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9');
+}
+
static boolean str_has_option(const char *str, const char *name)
{
const char *substr;
@@ -200,17 +207,17 @@ static boolean str_has_option(const char *str, const
char *name)
unsigned name_len = strlen(name);
/* OPTION=name,... */
- if (substr == str && substr[name_len] == ',') {
+ if (substr == str && !is_alphanumeric(substr[name_len])) {
return TRUE;
}
/* OPTION=...,name */
- if (substr+name_len == str+strlen(str) && substr[-1] == ',') {
+ if (substr+name_len == str+strlen(str) &&
!is_alphanumeric(substr[-1])) {
return TRUE;
}
/* OPTION=...,name,... */
- if (substr[-1] == ',' && substr[name_len] == ',') {
+ if (!is_alphanumeric(substr[-1]) &&
!is_alphanumeric(substr[name_len])) {
return TRUE;
}
}
Marek
On Wed, Jan 26, 2011 at 10:59 AM, Michal Krol <michal at vmware.com> wrote:
> On 2011-01-26 09:48, Marek Olšák wrote:
>
>> Module: Mesa
>> Branch: master
>> Commit: c7c733545a19aab3e2b954153b9348ebe3147368
>> URL:
>> http://cgit.freedesktop.org/mesa/mesa/commit/?id=c7c733545a19aab3e2b954153b9348ebe3147368
>>
>> Author: Marek Olšák<maraeo at gmail.com>
>> Date: Mon Jan 24 23:41:51 2011 +0100
>>
>> util: require debug options to be separated by commas
>>
>> Let's assume there are two options with names such that one is a substring
>> of another. Previously, if we only specified the longer one as a debug
>> option,
>> the shorter one would be considered specified as well (because of strstr).
>> This commit fixes it by checking that each option is surrounded by commas.
>>
>>
> Marek,
>
> What about just checking whether the preceding and trailing character is
> not alphanumeric?
>
> It's nice to get it fixed, but changing the way config options are
> specified might break development setups on a few people's machines.
>
> Thanks.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110126/2af897bf/attachment.html>
More information about the mesa-dev
mailing list