Mesa (master): tgsi/text: add str_match_name_from_array

Nicolai Hähnle nh at kemper.freedesktop.org
Fri Apr 29 16:41:39 UTC 2016


Module: Mesa
Branch: master
Commit: 4055babc7557f788e6c8f3cbb2c62d6161cf6903
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4055babc7557f788e6c8f3cbb2c62d6161cf6903

Author: Nicolai Hähnle <nicolai.haehnle at amd.com>
Date:   Thu Apr 28 16:43:10 2016 -0500

tgsi/text: add str_match_name_from_array

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
Reviewed-by: Dave Airlie <airlied at redhat.com>

---

 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 26e7c8f..c7f1664 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.
  *




More information about the mesa-commit mailing list