From a2e25226125ff12b5294055dd01e247197270265 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 14 Jan 2008 16:26:22 -0800 Subject: Let alIsExtensionPresent work with mixed-case extension names --- OpenAL32/alExtension.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'OpenAL32/alExtension.c') diff --git a/OpenAL32/alExtension.c b/OpenAL32/alExtension.c index 703bd140..dacb9218 100644 --- a/OpenAL32/alExtension.c +++ b/OpenAL32/alExtension.c @@ -303,7 +303,8 @@ ALAPI ALboolean ALAPIENTRY alIsExtensionPresent(const ALchar *extName) { ALboolean bIsSupported = AL_FALSE; ALCcontext *pContext; - char *ptr, *ext; + const char *ptr; + size_t len; if (!extName) { @@ -318,32 +319,28 @@ ALAPI ALboolean ALAPIENTRY alIsExtensionPresent(const ALchar *extName) return AL_FALSE; } - ext = strdup(extName); - ptr = ext; - do { - *ptr = (char)toupper(*ptr); - } while(*(ptr++)); - SuspendContext(pContext); + len = strlen(extName); ptr = pContext->ExtensionList; - while((ptr=strstr(ptr, ext)) != NULL) + while(ptr && *ptr) { - if(ptr == pContext->ExtensionList || ptr[-1] == ' ') + if(strncasecmp(ptr, extName, len) == 0 && + (ptr[len] == '\0' || isspace(ptr[len]))) + { + bIsSupported = AL_TRUE; + break; + } + if((ptr=strchr(ptr, ' ')) != NULL) { - char e = ptr[strlen(ext)]; - if(e == ' ' || e == 0) - { - bIsSupported = AL_TRUE; - break; - } + do { + ++ptr; + } while(isspace(*ptr)); } - ptr++; } ProcessContext(pContext); - free(ext); return bIsSupported; } -- cgit v1.2.3