X-Git-Url: http://git.refcnt.org/?a=blobdiff_plain;f=colorize.c;h=213b8c602eda31b0b072f5bbc9618508301e3f92;hb=refs%2Ftags%2Fv0.64;hp=2f164fa2ba64d6c73a06b115eaff4f9976e8c65f;hpb=fcf4408d02a843b008c262c808cabbc7bf36ed0a;p=colorize.git diff --git a/colorize.c b/colorize.c index 2f164fa..213b8c6 100644 --- a/colorize.c +++ b/colorize.c @@ -2,7 +2,7 @@ * colorize - Read text from standard input stream or file and print * it colorized through use of ANSI escape sequences * - * Copyright (c) 2011-2017 Steven Schubiger + * Copyright (c) 2011-2018 Steven Schubiger * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -124,7 +124,7 @@ #define PROGRAM_NAME "colorize" -#define VERSION "0.63" +#define VERSION "0.64" typedef enum { false, true } bool; @@ -339,8 +339,8 @@ main (int argc, char **argv) vfprintf_fail (formats[FMT_GENERIC], "--clean and --clean-all switch are mutually exclusive"); if (arg_cnt > 1) { - const char *format = "%s %s"; - const char *message = "switch cannot be used with more than one file"; + const char *const format = "%s %s"; + const char *const message = "switch cannot be used with more than one file"; if (clean) vfprintf_fail (format, "--clean", message); else if (clean_all) @@ -576,7 +576,7 @@ print_version (void) #ifdef HAVE_VERSION # include "version.h" #else - const char *version = NULL; + const char *const version = NULL; #endif const char *version_prefix, *version_string; const char *c_flags, *ld_flags, *cpp_flags; @@ -661,7 +661,11 @@ process_args (unsigned int arg_cnt, char **arg_strings, char *attr, const struct int ret; char *p; struct stat sb; - struct color_name *color_names[3] = { NULL, NULL, NULL }; + struct color_name *color_names[3] = { + NULL, /* foreground */ + NULL, /* background */ + NULL, /* sentinel value */ + }; const char *color_string = arg_cnt >= 1 ? arg_strings[0] : NULL; const char *file_string = arg_cnt == 2 ? arg_strings[1] : NULL; @@ -905,7 +909,7 @@ read_print_stream (const char *attr, const struct color **colors, const char *fi } else if (*eol == '\n') flags |= LF; - else + else /* never reached */ vfprintf_fail (formats[FMT_FILE], file, "unrecognized line ending"); p = eol + SKIP_LINE_ENDINGS (flags); *eol = '\0';