Alexandre Julliard : opengl32: Add a helper function to correctly compare extension strings.

Alexandre Julliard julliard at winehq.org
Tue Jun 26 13:34:14 CDT 2012


Module: wine
Branch: master
Commit: b349aa676facb465c127ad33623c06038b4f666b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b349aa676facb465c127ad33623c06038b4f666b

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jun 26 16:12:06 2012 +0200

opengl32: Add a helper function to correctly compare extension strings.

---

 dlls/opengl32/wgl.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index eca42e2..6d94716 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");




More information about the wine-cvs mailing list