On 03/26/2012 11:17 AM, Nikola Pajkovsky wrote:
-bool is_in_string_list(const char *name, char **v)
+bool is_in_string_list(const char *name, char **v, int flags)
{
+ bool ret = false;
while (*v)
{
if (strcmp(*v, name) == 0)
- return true;
+ {
+ ret = true;
+ break;
+ }
v++;
}
- return false;
+
+ if (flags& MAKEDESC_WHITELIST)
+ ret = !ret;
+
+ return ret;
}
As I see it, is_in_string_list() is a generic helper function:
"is this string in this NULL-terminated array of strings?"
If you need to ask "is this string NOT in array?",
just use !is_in_string_list(str, vector).
- if (names_to_skip&& is_in_string_list(key, names_to_skip))
+ if (names_to_skip
+&& is_in_string_list(key, names_to_skip, desc_flags))
continue;
struct problem_item *item = g_hash_table_lookup(problem_data, key);
@@ -87,7 +89,8 @@ char *make_description(problem_data_t *problem_data, char
**names_to_skip, unsig
l = l->next;
/* Skip items we are not interested in */
- if (names_to_skip&& is_in_string_list(key, names_to_skip))
+ if (names_to_skip
+ && is_in_string_list(key, names_to_skip, desc_flags))
continue;
Yes, I see that you want it simple, and adding (flags & MAKEDESC_WHITELIST)
check here would be butt-ugly. I propose we add a local helper function
just above make_description():
static bool rejected_name(const char *name, char **v, int flags)
{
bool r = is_in_string_list(name, v);
if (flags & MAKEDESC_WHITELIST)
r = !r;
return r;
}
and use it here.
--
vda