From: Bruno Haible Date: Mon, 6 May 2019 23:27:33 +0000 (+0200) Subject: libtextstyle: examples: Enable --color=html, for debuggability. X-Git-Tag: v0.20~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe18e92743b7226791a5f28d7c786941a1bf8cc9;p=thirdparty%2Fgettext.git 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. --- 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)