forked from enlightenment/efl
gl_common: Make extension string checks more robust
strstr() can give false positives if the extension name is a subset of a string in the extension list, for example EGL_EXT_image_dma_buf_import would match EGL_EXT_image_dma_buf_import_modifiers. I've opted for a mildly badgered copy of epoxy's test, which should be robust in the face of subsets.
This commit is contained in:
parent
464d0ca9bb
commit
05d7c1c9a2
|
@ -84,11 +84,35 @@ sym_missing(void)
|
|||
ERR("GL symbols missing!");
|
||||
}
|
||||
|
||||
/* This check is based heavily on the check from libepoxy.
|
||||
* Previously we used strstr(), however there are some extensions
|
||||
* whose names are subsets of others.
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
evas_gl_extension_string_check(const char *exts, const char *ext)
|
||||
{
|
||||
const char *ptr;
|
||||
int len;
|
||||
|
||||
if (!exts || !ext) return EINA_FALSE;
|
||||
return strstr(exts, ext) != NULL;
|
||||
ptr = exts;
|
||||
|
||||
if (*ptr == '\0')
|
||||
return EINA_FALSE;
|
||||
|
||||
len = strlen(ext);
|
||||
|
||||
while (1)
|
||||
{
|
||||
ptr = strstr(ptr, ext);
|
||||
if (!ptr)
|
||||
return EINA_FALSE;
|
||||
|
||||
if (ptr[len] == ' ' || ptr[len] == '\0')
|
||||
return EINA_TRUE;
|
||||
|
||||
ptr += len;
|
||||
}
|
||||
}
|
||||
|
||||
/* Totally gross, but I didn't want to reindent all the
|
||||
|
|
Loading…
Reference in New Issue