diff options
author | Nicolai Hähnle <[email protected]> | 2016-04-28 16:43:10 -0500 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2016-04-29 11:39:53 -0500 |
commit | 4055babc7557f788e6c8f3cbb2c62d6161cf6903 (patch) | |
tree | 3bc9d491f4ad4c9a1ec6b529db1f950a7dca2737 | |
parent | a56edbdd8ff2619d54787b6d0705ab33dbe7d189 (diff) |
tgsi/text: add str_match_name_from_array
Reviewed-by: Ilia Mirkin <[email protected]>
Reviewed-by: Dave Airlie <[email protected]>
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_text.c | 18 |
1 files changed, 18 insertions, 0 deletions
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. * |