[client] egl: use new util_hasGLExt helper to check extensions

We previously used strstr, which can be prone to false positives when
the name of one extension is a substring of another extension.

This commit creates the helper function util_hasGLExt, which asserts
that the substring found in extension list is bounded by either spaces
or the beginning/end of the string.
This commit is contained in:
Quantum authored and Geoffrey McRae committed 2021-05-19 15:58:54 +10:00
1 parent edbd6f6ade
commit f9a9953071
8 files changed
+47 -7

No files matched your search

+24
View File
@@ -17,9 +17,13 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "common/stringutils.h"
int valloc_sprintf(char ** str, const char * format, va_list ap)
{
@@ -64,3 +68,23 @@ int alloc_sprintf(char ** str, const char * format, ...)
va_end(ap);
return ret;
}
bool str_containsValue(const char * list, char delimiter, const char * value)
{
size_t len = strlen(value);
const char span[] = {delimiter, '\0'};
while (*list)
{
if (*list == delimiter)
{
++list;
continue;
}
size_t n = strcspn(list, span);
if (n == len && strncmp(value, list, n) == 0)
return true;
list += n;
}
return false;
}