From fe18e92743b7226791a5f28d7c786941a1bf8cc9 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 7 May 2019 01:27:33 +0200 Subject: [PATCH] libtextstyle: examples: Enable --color=html, for debuggability. Reported by Akim Demaille. * libtextstyle/examples/color-hello/hello.c (main): Handle color_html case. * libtextstyle/examples/color-filter/filter.c (main): Likewise. --- libtextstyle/examples/color-filter/filter.c | 10 +++++++--- libtextstyle/examples/color-hello/hello.c | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/libtextstyle/examples/color-filter/filter.c b/libtextstyle/examples/color-filter/filter.c index c2e88c40d..e97e2f96b 100644 --- a/libtextstyle/examples/color-filter/filter.c +++ b/libtextstyle/examples/color-filter/filter.c @@ -88,7 +88,8 @@ main (int argc, char *argv[]) } if (color_mode == color_yes - || (color_mode == color_tty && isatty (STDOUT_FILENO))) + || (color_mode == color_tty && isatty (STDOUT_FILENO)) + || color_mode == color_html) { /* Find the style file. */ style_file_prepare ("FILTER_STYLE", "FILTER_STYLESDIR", STYLESDIR, @@ -107,8 +108,11 @@ main (int argc, char *argv[]) /* Create a terminal output stream that uses this style file. */ styled_ostream_t stream = - styled_ostream_create (STDOUT_FILENO, "(stdout)", TTYCTL_AUTO, - style_file_name); + (color_mode == color_html + ? html_styled_ostream_create (file_ostream_create (stdout), + style_file_name) + : styled_ostream_create (STDOUT_FILENO, "(stdout)", TTYCTL_AUTO, + style_file_name)); /* Allocate initial storage for the loop. */ size_t buflen = 10; diff --git a/libtextstyle/examples/color-hello/hello.c b/libtextstyle/examples/color-hello/hello.c index fdb800862..87e091f12 100644 --- a/libtextstyle/examples/color-hello/hello.c +++ b/libtextstyle/examples/color-hello/hello.c @@ -140,7 +140,8 @@ main (int argc, char *argv[]) } if (color_mode == color_yes - || (color_mode == color_tty && isatty (STDOUT_FILENO))) + || (color_mode == color_tty && isatty (STDOUT_FILENO)) + || color_mode == color_html) { /* Find the style file. */ style_file_prepare ("HELLO_STYLE", "HELLO_STYLESDIR", STYLESDIR, @@ -159,8 +160,11 @@ main (int argc, char *argv[]) /* Create a terminal output stream that uses this style file. */ styled_ostream_t stream = - styled_ostream_create (STDOUT_FILENO, "(stdout)", TTYCTL_AUTO, - style_file_name); + (color_mode == color_html + ? html_styled_ostream_create (file_ostream_create (stdout), + style_file_name) + : styled_ostream_create (STDOUT_FILENO, "(stdout)", TTYCTL_AUTO, + style_file_name)); /* Determine the full name of the user. */ if (fullname == NULL) -- 2.47.2