diff options
author | wm4 <wm4@nowhere> | 2017-10-02 17:30:27 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-10-02 17:30:27 +0200 |
commit | 0c04ce5f0d9c4fb7311edf0ae7bdf1eef0f61235 (patch) | |
tree | 8c205467cd0020a512f128e570f2da29d0f8d0f6 /video/out/opengl/utils.c | |
parent | 51985e3dd630a5fc212f643781b4a0ca7f590782 (diff) | |
download | mpv-0c04ce5f0d9c4fb7311edf0ae7bdf1eef0f61235.tar.bz2 mpv-0c04ce5f0d9c4fb7311edf0ae7bdf1eef0f61235.tar.xz |
vo_gpu: gl: implement proper extension string search
The existing code in check_ext() avoided false positive due to
sub-strings, but allowed false negatives. Fix this with slightly better
search code, and make it available as function to other source files.
(There are some cases of strstr() still around.)
Diffstat (limited to 'video/out/opengl/utils.c')
-rw-r--r-- | video/out/opengl/utils.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index 3b296d52de..38982e501e 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -267,3 +267,21 @@ void gl_set_debug_logger(GL *gl, struct mp_log *log) if (gl->DebugMessageCallback) gl->DebugMessageCallback(log ? gl_debug_cb : NULL, log); } + +// Given a GL combined extension string in extensions, find out whether ext +// is included in it. Basically, a word search. +bool gl_check_extension(const char *extensions, const char *ext) +{ + int len = strlen(ext); + const char *cur = extensions; + while (cur) { + cur = strstr(cur, ext); + if (!cur) + break; + if ((cur == extensions || cur[-1] == ' ') && + (cur[len] == '\0' || cur[len] == ' ')) + return true; + cur += len; + } + return false; +} |