From 7927fb737a325836e29ea13c4d412f5b28333968 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Mon, 13 Mar 2006 19:06:02 +0100 Subject: [PATCH] 1. If neither CONFIG_88_COLORS nor CONFIG_256_COLORS is defined, then dump_to_file_256 is defined in dump.c but not used. If configure --enable-debug was used, then gcc warns about the unused function, and the warning stops the build. 2. The description of document.dump.color_mode ends with a newline, provoking a runtime warning from check_description in src/config/options.c. 3. options.inc has preprocessor directives inside macro arguments. That is not portable C. xgettext (GNU gettext-tools) 0.14.3 is not smart enough to figure out the possible combinations, and copies an incorrect string to elinks.pot. --- src/config/options.inc | 48 +++++++++++++++++++++++++++--------------- src/viewer/dump/dump.c | 8 +++++++ 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/config/options.inc b/src/config/options.inc index 2e79f8fa3..97b1c9b66 100644 --- a/src/config/options.inc +++ b/src/config/options.inc @@ -632,29 +632,43 @@ static struct option_info config_options_info[] = { N_("Codepage used in dump output. 'System' stands for\n" "a codepage determined by a selected locale.")), - INIT_OPT_INT("document.dump", N_("Color mode"), - "color_mode", 0, -1, + /* The #if directives cannot be inside the argument list of + * the INIT_OPT_INT macro; that wouldn't be standard C. + * And they especially cannot be inside the argument list of N_; + * xgettext (GNU gettext-tools) 0.14.3 wouldn't support that. */ #if defined(CONFIG_88_COLORS) && defined(CONFIG_256_COLORS) -3, -#elif defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS) -2, -#else -1, -#endif --1, + INIT_OPT_INT("document.dump", N_("Color mode"), + "color_mode", 0, -1, 3, -1, N_("Color mode for dumps:\n" "-1 is standard dump mode\n" "0 is mono mode\n" "1 is 16 color mode\n" -#if defined(CONFIG_88_COLORS) && defined(CONFIG_256_COLORS) "2 is 88 color mode\n" - "3 is 256 color mode\n" -#elif defined(CONFIG_88_COLORS) - "2 is 88 color mode\n" -#elif defined(CONFIG_256_COLORS) - "2 is 256 color mode\n" -#endif - )), + "3 is 256 color mode")), +#elif defined(CONFIG_88_COLORS) /* && !defined(CONFIG_256_COLORS) */ + INIT_OPT_INT("document.dump", N_("Color mode"), + "color_mode", 0, -1, 2, -1, + N_("Color mode for dumps:\n" + "-1 is standard dump mode\n" + "0 is mono mode\n" + "1 is 16 color mode\n" + "2 is 88 color mode")), +#elif defined(CONFIG_256_COLORS) /* && !defined(CONFIG_88_COLORS) */ + INIT_OPT_INT("document.dump", N_("Color mode"), + "color_mode", 0, -1, 2, -1, + N_("Color mode for dumps:\n" + "-1 is standard dump mode\n" + "0 is mono mode\n" + "1 is 16 color mode\n" + "2 is 256 color mode")), +#else /* !defined(CONFIG_88_COLORS) && !defined(CONFIG_256_COLORS) */ + INIT_OPT_INT("document.dump", N_("Color mode"), + "color_mode", 0, -1, 1, -1, + N_("Color mode for dumps:\n" + "-1 is standard dump mode\n" + "0 is mono mode\n" + "1 is 16 color mode")), +#endif /* !defined(CONFIG_88_COLORS) && !defined(CONFIG_256_COLORS) */ INIT_OPT_STRING("document.dump", N_("Footer"), "footer", 0, "", diff --git a/src/viewer/dump/dump.c b/src/viewer/dump/dump.c index 6179f6f68..6b2a5e05a 100644 --- a/src/viewer/dump/dump.c +++ b/src/viewer/dump/dump.c @@ -51,7 +51,9 @@ static struct download dump_download; static int dump_redir_count = 0; static int dump_to_file_16(struct document *document, int fd); +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS) static int dump_to_file_256(struct document *document, int fd); +#endif /* This dumps the given @cached's source onto @fd nothing more. It returns 0 if it * all went fine and 1 if something isn't quite right and we should terminate @@ -521,6 +523,11 @@ fail: return 0; } +/* configure --enable-debug uses gcc -Wall -Werror, and -Wall includes + * -Wunused-function, so declaring or defining any unused function + * would break the build. */ +#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS) + static int write_color_256(unsigned char *str, unsigned char color, int fd, unsigned char *buf, int *bptr) { @@ -648,6 +655,7 @@ fail: return 0; } +#endif /* defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS) */ int dump_to_file(struct document *document, int fd)