if (!(arg_flags & SHOW_MASKED))
return 0;
- printf(ANSI_HIGHLIGHT_RED_ON "[MASKED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom);
+ printf("%s%s%s %s → %s\n",
+ ansi_highlight_red(), "[MASKED]", ansi_highlight_off(), top, bottom);
return 1;
}
if (!(arg_flags & SHOW_EQUIVALENT))
return 0;
- printf(ANSI_HIGHLIGHT_GREEN_ON "[EQUIVALENT]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom);
+ printf("%s%s%s %s → %s\n",
+ ansi_highlight_green(), "[EQUIVALENT]", ansi_highlight(), top, bottom);
return 1;
}
if (!(arg_flags & SHOW_REDIRECTED))
return 0;
- printf(ANSI_HIGHLIGHT_ON "[REDIRECTED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom);
+ printf("%s%s%s %s → %s\n",
+ ansi_highlight(), "[REDIRECTED]", ansi_highlight_off(), top, bottom);
return 1;
}
if (!(arg_flags & SHOW_OVERRIDDEN))
return 0;
- printf(ANSI_HIGHLIGHT_ON "[OVERRIDDEN]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom);
+ printf("%s%s%s %s → %s\n",
+ ansi_highlight(), "[OVERRIDDEN]", ansi_highlight_off(), top, bottom);
return 1;
}
if (!(arg_flags & SHOW_EXTENDED))
return 0;
- printf(ANSI_HIGHLIGHT_ON "[EXTENDED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom);
+ printf("%s%s%s %s → %s\n",
+ ansi_highlight(), "[EXTENDED]", ansi_highlight_off(), top, bottom);
return 1;
}
assert(top);
assert(bottom);
- if (null_or_empty_path(top) > 0) {
- notify_override_masked(top, bottom);
- return 0;
- }
+ if (null_or_empty_path(top) > 0)
+ return notify_override_masked(top, bottom);
k = readlink_malloc(top, &dest);
if (k >= 0) {
if (equivalent(dest, bottom) > 0)
- notify_override_equivalent(top, bottom);
+ return notify_override_equivalent(top, bottom);
else
- notify_override_redirected(top, bottom);
-
- return 0;
+ return notify_override_redirected(top, bottom);
}
- notify_override_overridden(top, bottom);
+ k = notify_override_overridden(top, bottom);
if (!arg_diff)
- return 0;
+ return k;
putchar('\n');
putchar('\n');
- return 0;
+ return k;
}
static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const char *toppath, const char *drop) {
k = found_override(f, o);
if (k < 0)
r = k;
- n_found++;
+ else
+ n_found += k;
}
h = hashmap_get(drops, key);
if (h)
- HASHMAP_FOREACH(o, h, j) {
- notify_override_extended(f, o);
- n_found++;
- }
+ HASHMAP_FOREACH(o, h, j)
+ n_found += notify_override_extended(f, o);
}
finish:
return -EINVAL;
}
-static void help(void) {
+static int help(void) {
printf("%s [OPTIONS...] [SUFFIX...]\n\n"
"Find overridden configuration files.\n\n"
" --diff[=1|0] Show a diff when overridden files differ\n"
" -t --type=LIST... Only display a selected set of override types\n",
program_invocation_short_name);
+
+ return 0;
}
static int parse_flags(const char *flag_str, int flags) {
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
{ "diff", optional_argument, NULL, ARG_DIFF },
{ "type", required_argument, NULL, 't' },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
arg_no_pager = true;
break;
- case '?':
- return -EINVAL;
-
case 't': {
int f;
f = parse_flags(optarg, arg_flags);
}
break;
- default:
- log_error("Unknown option code %c", c);
+ case '?':
return -EINVAL;
+
+ default:
+ assert_not_reached("Unhandled option");
}
}
}
if (r >= 0)
- printf("\n%i overridden configuration files found.\n", n_found);
+ printf("%s%i overridden configuration files found.\n",
+ n_found ? "\n" : "", n_found);
finish:
pager_close();