#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);
}
}
/**
- * 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
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;
}
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;
}