X-Git-Url: http://git.refcnt.org/?a=blobdiff_plain;f=colorize.c;h=7faeb8008392459b9d32381445212854d2b2a2fa;hb=f340b5874461fd2405ad4def6a365c89b45efbae;hp=a891135fdd4772710481ff8607f9d7782cee7ff6;hpb=afbfe4ff6003d2e148130d570fd46bf5dd3103bd;p=colorize.git diff --git a/colorize.c b/colorize.c index a891135..7faeb80 100644 --- a/colorize.c +++ b/colorize.c @@ -339,10 +339,13 @@ main (int argc, char **argv) exit (EXIT_SUCCESS); } -#define SET_OPT_TYPE(type) \ - opt_type = type; \ - opt = 0; \ - goto PARSE_OPT; \ +#define PRINT_HELP_EXIT() \ + print_help (); \ + exit (EXIT_SUCCESS); \ + +#define PRINT_VERSION_EXIT() \ + print_version (); \ + exit (EXIT_SUCCESS); \ extern char *optarg; @@ -352,7 +355,6 @@ process_opts (int argc, char **argv) int opt; while ((opt = getopt_long (argc, argv, "hV", long_opts, NULL)) != -1) { - PARSE_OPT: switch (opt) { case 0: /* long opts */ @@ -383,19 +385,17 @@ process_opts (int argc, char **argv) break; } case OPT_HELP: - print_help (); - exit (EXIT_SUCCESS); + PRINT_HELP_EXIT (); case OPT_VERSION: - print_version (); - exit (EXIT_SUCCESS); + PRINT_VERSION_EXIT (); default: /* never reached */ ABORT_TRACE (); } break; case 'h': - SET_OPT_TYPE (OPT_HELP); + PRINT_HELP_EXIT (); case 'V': - SET_OPT_TYPE (OPT_VERSION); + PRINT_VERSION_EXIT (); case '?': print_hint (); exit (EXIT_FAILURE); @@ -473,7 +473,7 @@ print_version (void) const char *version = NULL; #endif const char *version_prefix, *version_string; - const char *c_flags; + const char *c_flags, *ld_flags, *cpp_flags; struct bytes_size bytes_size; bool debug; #ifdef CFLAGS @@ -481,6 +481,16 @@ print_version (void) #else c_flags = "unknown"; #endif +#ifdef LDFLAGS + ld_flags = to_str (LDFLAGS); +#else + ld_flags = "unknown"; +#endif +#ifdef CPPFLAGS + cpp_flags = to_str (CPPFLAGS); +#else + cpp_flags = "unknown"; +#endif #if DEBUG debug = true; #else @@ -491,6 +501,8 @@ print_version (void) printf ("colorize %s%s (compiled at %s, %s)\n", version_prefix, version_string, __DATE__, __TIME__); printf ("Compiler flags: %s\n", c_flags); + printf ("Linker flags: %s\n", ld_flags); + printf ("Preprocessor flags: %s\n", cpp_flags); if (get_bytes_size (BUF_SIZE, &bytes_size)) { if (BUF_SIZE % 1024 == 0) @@ -554,7 +566,7 @@ process_args (unsigned int arg_cnt, char **arg_strings, bool *bold, const struct if (file_string) vfprintf_fail (formats[FMT_GENERIC], "hyphen cannot be used as color string"); else - vfprintf_fail (formats[FMT_GENERIC], "hyphen must be preceeded by color string"); + vfprintf_fail (formats[FMT_GENERIC], "hyphen must be preceded by color string"); } ret = lstat (color_string, &sb); @@ -684,7 +696,7 @@ skip_path_colors (const char *color_string, const char *file_string, const struc else { if (VALID_FILE_TYPE (mode)) - vfprintf_fail (formats[FMT_QUOTE], get_file_type (mode), file_exists, "must be preceeded by color string"); + vfprintf_fail (formats[FMT_QUOTE], get_file_type (mode), file_exists, "must be preceded by color string"); else vfprintf_fail (formats[FMT_QUOTE], get_file_type (mode), file_exists, "is not a valid file type"); }