From b349aa676facb465c127ad33623c06038b4f666b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 26 Jun 2012 16:12:06 +0200 Subject: [PATCH] opengl32: Add a helper function to correctly compare extension strings. --- dlls/opengl32/wgl.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index eca42e24c38..6d94716d75b 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -393,6 +393,20 @@ int WINAPI wglGetLayerPaletteEntries(HDC hdc, return 0; } +/* check if the extension is present in the list */ +static BOOL has_extension( const char *list, const char *ext ) +{ + size_t len = strlen( ext ); + + while (list) + { + while (*list == ' ') list++; + if (!strncmp( list, ext, len ) && (!list[len] || list[len] == ' ')) return TRUE; + list = strchr( list, ' ' ); + } + return FALSE; +} + static int compar(const void *elt_a, const void *elt_b) { return strcmp(((const OpenGL_extension *) elt_a)->name, ((const OpenGL_extension *) elt_b)->name); @@ -417,7 +431,7 @@ static BOOL is_extension_supported(const char* extension) * if the OpenGL extension required for the function we are looking up is supported. */ /* Check if the extension is part of the GL extension string to see if it is supported. */ - if(strstr(gl_ext_string, extension) != NULL) + if (has_extension(gl_ext_string, extension)) return TRUE; /* In general an OpenGL function starts as an ARB/EXT extension and at some stage @@ -1028,7 +1042,7 @@ const GLubyte * WINAPI wine_glGetString( GLenum name ) TRACE("- %s:", ThisExtn); /* test if supported API is disabled by config */ - if (!internal_gl_disabled_extensions || !strstr(internal_gl_disabled_extensions, ThisExtn)) { + if (!has_extension(internal_gl_disabled_extensions, ThisExtn)) { strcat(internal_gl_extensions, " "); strcat(internal_gl_extensions, ThisExtn); TRACE(" active\n");