Mesa (master): tgsi/text: Don't use strncasecmp(), it breaks windows build.

Michał Król michal at kemper.freedesktop.org
Tue Dec 15 04:54:18 PST 2009


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

Author: Michal Krol <michal at vmware.com>
Date:   Tue Dec 15 13:54:05 2009 +0100

tgsi/text: Don't use strncasecmp(), it breaks windows build.

Also, break out of the for-loop when a matching property is found.

---

 src/gallium/auxiliary/tgsi/tgsi_text.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 5a17b9d..f000958 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -60,6 +60,21 @@ static boolean uprcase( char c )
    return c;
 }
 
+/*
+ * Ignore case of str1 and assume str2 is already uppercase.
+ * Return TRUE iff str1 and str2 are equal.
+ */
+static int
+streq_nocase_uprcase(const char *str1,
+                     const char *str2)
+{
+   while (*str1 && uprcase(*str1) == *str2) {
+      str1++;
+      str2++;
+   }
+   return *str1 == *str2;
+}
+
 static boolean str_match_no_case( const char **pcur, const char *str )
 {
    const char *cur = *pcur;
@@ -1012,8 +1027,7 @@ static boolean parse_property( struct translate_ctx *ctx )
    }
    for (property_name = 0; property_name < TGSI_PROPERTY_COUNT;
         ++property_name) {
-      if (strncasecmp(id, property_names[property_name],
-                      strlen(property_names[property_name]))) {
+      if (streq_nocase_uprcase(id, property_names[property_name])) {
          break;
       }
    }



More information about the mesa-commit mailing list