[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
diagnostics: support --color=html
From: |
Akim Demaille |
Subject: |
diagnostics: support --color=html |
Date: |
Wed, 8 May 2019 14:33:37 +0200 |
commit 23e536af498ac6ecb42cb00a0bd09bf34835126f
Author: Akim Demaille <address@hidden>
Date: Tue May 7 08:41:29 2019 +0200
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.
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- diagnostics: support --color=html,
Akim Demaille <=