summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-05-07 08:41:29 +0200
committerAkim Demaille <akim.demaille@gmail.com>2019-05-08 13:36:47 +0200
commit23e536af498ac6ecb42cb00a0bd09bf34835126f (patch)
tree79acd81ce580fbea63989d00d139ba31f9fe8afc /src
parentcd569290979820edc65066d576b851d095bad6de (diff)
downloadbison-23e536af498ac6ecb42cb00a0bd09bf34835126f.tar.gz
diagnostics: support --color=html
Based on a message from Bruno Haible. https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=fe18e92743b7226791a5f28d7c786941a1bf8cc9 This does not generate proper HTML: special characters are not escaped for instance. This is a hidden feature meant for Bison developers, not end users. * src/complain.c (complain_init_color): Support --color=html.
Diffstat (limited to 'src')
-rw-r--r--src/complain.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/complain.c b/src/complain.c
index 8a6d8c57..b6412441 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -252,6 +252,7 @@ complain_init_color (void)
{
#if HAVE_LIBTEXTSTYLE
if (color_mode == color_yes
+ || color_mode == color_html
|| (color_mode == color_tty && isatty (STDERR_FILENO)))
{
style_file_prepare ("BISON_DIAGNOSTICS_STYLE", NULL,
@@ -268,9 +269,25 @@ complain_init_color (void)
style_file_name = NULL;
#endif
+ /* Workaround clang's warning (starting at Clang 3.5) about the stub
+ code of html_styled_ostream_create:
+
+ | src/complain.c:274:7: error: code will never be executed [-Werror,-Wunreachable-code]
+ | ? html_styled_ostream_create (file_ostream_create (stderr),
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ */
+#if defined __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wunreachable-code"
+#endif
errstream =
- styled_ostream_create (STDERR_FILENO, "(stderr)", TTYCTL_AUTO,
- style_file_name);
+ color_mode == color_html
+ ? html_styled_ostream_create (file_ostream_create (stderr),
+ style_file_name)
+ : styled_ostream_create (STDERR_FILENO, "(stderr)", TTYCTL_AUTO,
+ style_file_name);
+#if defined __clang__
+# pragma clang diagnostic pop
+#endif
}
void