chiark / gitweb /
Bring bootchart code in line with CODING_STYLE
[elogind.git] / src / delta / delta.c
index 49c2fc323ada673b89e14236fbafb087f0551018..0785e7b5e7ca466b516feea2019db260a561ee04 100644 (file)
@@ -66,7 +66,8 @@ static int notify_override_masked(const char *top, const char *bottom) {
         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;
 }
 
@@ -74,7 +75,8 @@ static int notify_override_equivalent(const char *top, const char *bottom) {
         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;
 }
 
@@ -82,7 +84,8 @@ static int notify_override_redirected(const char *top, const char *bottom) {
         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;
 }
 
@@ -90,7 +93,8 @@ static int notify_override_overridden(const char *top, const char *bottom) {
         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;
 }
 
@@ -98,7 +102,8 @@ static int notify_override_extended(const char *top, const char *bottom) {
         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;
 }
 
@@ -246,7 +251,7 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const
                 if (!p)
                         return -ENOMEM;
 
-                k = hashmap_put(h, path_get_file_name(p), p);
+                k = hashmap_put(h, basename(p), p);
                 if (k < 0) {
                         free(p);
                         if (k != -EEXIST)
@@ -298,7 +303,7 @@ static int enumerate_dir(Hashmap *top, Hashmap *bottom, Hashmap *drops, const ch
 
                 path_kill_slashes(p);
 
-                k = hashmap_put(top, path_get_file_name(p), p);
+                k = hashmap_put(top, basename(p), p);
                 if (k >= 0) {
                         p = strdup(p);
                         if (!p)
@@ -308,8 +313,8 @@ static int enumerate_dir(Hashmap *top, Hashmap *bottom, Hashmap *drops, const ch
                         return k;
                 }
 
-                free(hashmap_remove(bottom, path_get_file_name(p)));
-                k = hashmap_put(bottom, path_get_file_name(p), p);
+                free(hashmap_remove(bottom, basename(p)));
+                k = hashmap_put(bottom, basename(p), p);
                 if (k < 0) {
                         free(p);
                         return k;
@@ -426,7 +431,7 @@ static int process_suffix_chop(const char *prefixes, const char *suffix, const c
         return -EINVAL;
 }
 
-static void help(void) {
+static int help(void) {
 
         printf("%s [OPTIONS...] [SUFFIX...]\n\n"
                "Find overridden configuration files.\n\n"
@@ -436,6 +441,8 @@ static void help(void) {
                "     --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) {
@@ -477,7 +484,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "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;
@@ -502,9 +509,6 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_no_pager = true;
                         break;
 
-                case '?':
-                        return -EINVAL;
-
                 case 't': {
                         int f;
                         f = parse_flags(optarg, arg_flags);
@@ -533,9 +537,11 @@ static int parse_argv(int argc, char *argv[]) {
                         }
                         break;
 
-                default:
-                        log_error("Unknown option code %c", c);
+                case '?':
                         return -EINVAL;
+
+                default:
+                        assert_not_reached("Unhandled option");
                 }
         }