summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b6c315d)
raw | patch | inline | side by side (parent: b6c315d)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 13 Dec 2009 20:11:17 +0000 (15:11 -0500) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 13 Dec 2009 20:11:17 +0000 (15:11 -0500) |
tig.c | patch | blob | history |
index 4282b9df15aed8d40729f7a515495c19d67ffa6b..3f4a6f6d57f9467f01dbe4d371c009545f6dd871 100644 (file)
--- a/tig.c
+++ b/tig.c
return 0;
}
+#define enum_equals(entry, str, len) \
+ ((entry).namelen == (len) && string_enum_compare((entry).name, str, len))
+
struct enum_map {
const char *name;
int namelen;
int i;
for (i = 0; i < map_size; i++)
- if (namelen == map[i].namelen &&
- !string_enum_compare(name, map[i].name, namelen)) {
+ if (enum_equals(map[i], name, namelen)) {
*value = map[i].value;
return TRUE;
}
int i;
for (i = 0; i < ARRAY_SIZE(req_info); i++)
- if (req_info[i].namelen == namelen &&
- !string_enum_compare(req_info[i].name, name, namelen))
+ if (enum_equals(req_info[i], name, namelen))
return req_info[i].request;
return REQ_NONE;
enum line_type type;
for (type = 0; type < ARRAY_SIZE(line_info); type++)
- if (namelen == line_info[type].namelen &&
- !string_enum_compare(line_info[type].name, name, namelen))
+ if (enum_equals(line_info[type], name, namelen))
return &line_info[type];
return NULL;