Change strcmp_underscore() to streq_underscore().
authorChristoph Mallon <christoph.mallon@gmx.de>
Wed, 14 Sep 2011 08:41:31 +0000 (10:41 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Wed, 14 Sep 2011 08:41:31 +0000 (10:41 +0200)
adt/strutil.c
adt/strutil.h
attribute.c
parser.c

index 7dd219a..fc494fe 100644 (file)
@@ -1,15 +1,15 @@
 #include "strutil.h"
 
 
-int strcmp_underscore(const char *const s1, const char *const s2)
+bool streq_underscore(const char *const s1, const char *const s2)
 {
        if (s2[0] == '_' && s2[1] == '_') {
                size_t len2 = strlen(s2);
                size_t len1 = strlen(s1);
                if (len1 == len2 - 4 && s2[len2 - 2] == '_' && s2[len2 - 1] == '_') {
-                       return strncmp(s1, s2 + 2, len2 - 4);
+                       return strncmp(s1, s2 + 2, len2 - 4) == 0;
                }
        }
 
-       return strcmp(s1, s2);
+       return streq(s1, s2);
 }
index ca0ec45..041e016 100644 (file)
@@ -19,8 +19,8 @@ static inline char const* strstart(char const* str, char const* start)
 }
 
 /**
- * compare two strings, ignoring double underscores on the second.
+ * Test two strings for equality, ignoring double underscores on the second.
  */
-int strcmp_underscore(const char *s1, const char *s2);
+bool streq_underscore(const char *s1, const char *s2);
 
 #endif
index a7deee5..8f9b2e0 100644 (file)
@@ -139,16 +139,16 @@ type_t *handle_attribute_mode(const attribute_t *attribute, type_t *orig_type)
        const char         *symbol_str = arg->v.symbol->string;
        bool                sign       = is_type_signed(type);
        atomic_type_kind_t  akind;
-       if (strcmp_underscore("QI",   symbol_str) == 0 ||
-           strcmp_underscore("byte", symbol_str) == 0) {
+       if (streq_underscore("QI",   symbol_str) ||
+           streq_underscore("byte", symbol_str)) {
                akind = sign ? ATOMIC_TYPE_CHAR : ATOMIC_TYPE_UCHAR;
-       } else if (strcmp_underscore("HI", symbol_str) == 0) {
+       } else if (streq_underscore("HI", symbol_str)) {
                akind = sign ? ATOMIC_TYPE_SHORT : ATOMIC_TYPE_USHORT;
-       } else if (strcmp_underscore("SI",      symbol_str) == 0
-               || strcmp_underscore("word",    symbol_str) == 0
-               || strcmp_underscore("pointer", symbol_str) == 0) {
+       } else if (streq_underscore("SI",      symbol_str)
+               || streq_underscore("word",    symbol_str)
+               || streq_underscore("pointer", symbol_str)) {
                akind = sign ? ATOMIC_TYPE_INT : ATOMIC_TYPE_UINT;
-       } else if (strcmp_underscore("DI", symbol_str) == 0) {
+       } else if (streq_underscore("DI", symbol_str)) {
                akind = sign ? ATOMIC_TYPE_LONGLONG : ATOMIC_TYPE_ULONGLONG;
        } else {
                source_position_t const *const pos = &attribute->source_position;
index 65aa04e..6d1a959 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1216,8 +1216,7 @@ static attribute_t *parse_attribute_gnu_single(void)
                }
 
                const char *attribute_name = get_attribute_name(kind);
-               if (attribute_name != NULL
-                               && strcmp_underscore(attribute_name, name) == 0)
+               if (attribute_name != NULL && streq_underscore(attribute_name, name))
                        break;
        }