From 4055babc7557f788e6c8f3cbb2c62d6161cf6903 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Thu, 28 Apr 2016 16:43:10 -0500 Subject: [PATCH] tgsi/text: add str_match_name_from_array Reviewed-by: Ilia Mirkin Reviewed-by: Dave Airlie --- src/gallium/auxiliary/tgsi/tgsi_text.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 26e7c8f3165..c7f1664f917 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -119,6 +119,24 @@ static boolean str_match_nocase_whole( const char **pcur, const char *str ) return FALSE; } +/* Return the array index that matches starting at *pcur, where the string at + * *pcur is terminated by a non-digit non-letter non-underscore. + * Returns -1 if no match is found. + * + * On success, the pointer to the first string is moved to the end of the read + * word. + */ +static int str_match_name_from_array(const char **pcur, + const char * const *array, + unsigned array_size) +{ + for (unsigned j = 0; j < array_size; ++j) { + if (str_match_nocase_whole(pcur, array[j])) + return j; + } + return -1; +} + /* Return the format corresponding to the name at *pcur. * Returns -1 if there is no format name. * -- 2.30.2