On 09/01/2012 10:15 AM, Jordan Justen wrote: > This better matches the interface of glGetStringi, which should be used > for GL >= 3.0. > > Signed-off-by: Jordan Justen <jordan.l.jus...@intel.com> > --- > tests/util/piglit-util-gl-common.c | 55 > ++++++++++++++++++++++++++++++++---- > tests/util/piglit-util.c | 15 ++++++++++ > tests/util/piglit-util.h | 12 ++++++++ > 3 files changed, 77 insertions(+), 5 deletions(-)
> -bool piglit_is_extension_supported(const char *name) > +static const char** split_string(const char *string) > { > - if (gl_extensions == NULL) { > - gl_extensions = (const char *) glGetString(GL_EXTENSIONS); > + char *split; > + char **strings; > + int offset, length, words, max_words; > + bool was_in_word, in_word; > + > + length = strlen(string); > + max_words = length / 2; > + strings = malloc ((sizeof(char*) * (max_words + 1)) + > + (sizeof(char) * (length + 1))); > + split = (char*) &strings[max_words + 1]; > + assert (strings != NULL); > + > + for (words = 0, was_in_word = false, offset = 0; > + offset < length; > + offset++) { > + char c = string[offset]; > + in_word = (c != 0) && !isspace(c); > + if (!in_word) { > + split[offset] = 0; > + } else { > + split[offset] = c; > + if (!was_in_word) { > + strings[words] = &split[offset]; > + words++; > + } > + } > + was_in_word = in_word; > } > > - return piglit_is_extension_in_string(gl_extensions, name); > + strings[words] = NULL; > + > + return (const char**) strings; > +} The loop can be more concisely written with strtok: split = strdup(string); strings = strtok(split, " "); for (i = 0; strings[i] != NULL; ++i) strings[i + 1] = strtok(NULL, " "); return strings; _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit