From: Bruno Haible Date: Fri, 15 Feb 2019 20:39:56 +0000 (+0100) Subject: libtextstyle: Document when and how to turn off styling. X-Git-Tag: v0.20~157 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e27a0af01437573284c1000d76449a5d6c778373;p=thirdparty%2Fgettext.git libtextstyle: Document when and how to turn off styling. * libtextstyle/doc/libtextstyle.texi (Basic use): Document when and how to turn off styling. * gnulib-local/lib/term-styled-ostream.oo.c (term_styled_ostream_create): Handle a NULL css_filename explicitly. --- diff --git a/gnulib-local/lib/term-styled-ostream.oo.c b/gnulib-local/lib/term-styled-ostream.oo.c index c0e7003ac..69ca68452 100644 --- a/gnulib-local/lib/term-styled-ostream.oo.c +++ b/gnulib-local/lib/term-styled-ostream.oo.c @@ -601,10 +601,17 @@ term_styled_ostream_t term_styled_ostream_create (int fd, const char *filename, ttyctl_t tty_control, const char *css_filename) { - term_styled_ostream_t stream = - XMALLOC (struct term_styled_ostream_representation); + term_styled_ostream_t stream; CRStyleSheet *css_file_contents; + /* If css_filename is NULL, no styling is desired. The code below would end + up returning NULL anyway. But it's better to not rely on such details of + libcroco behaviour. */ + if (css_filename == NULL) + return NULL; + + stream = XMALLOC (struct term_styled_ostream_representation); + stream->base.base.vtable = &term_styled_ostream_vtable; stream->destination = term_ostream_create (fd, filename, tty_control); diff --git a/libtextstyle/doc/libtextstyle.texi b/libtextstyle/doc/libtextstyle.texi index 209fef9c5..f7cb5df54 100644 --- a/libtextstyle/doc/libtextstyle.texi +++ b/libtextstyle/doc/libtextstyle.texi @@ -507,7 +507,10 @@ Basic use of GNU libtextstyle consists of statements like these: @end smallexample Before this snippet, your code needs to determine the name of the style -file to use (@code{style_file_name}). +file to use (@code{style_file_name}). If no styling is desired -- the +precise condition depends on the value of @code{color_mode} but also on +your application logic --, you should set @code{style_file_name} to +@code{NULL}. An object of type @code{styled_ostream_t} is allocated. The function @code{styled_ostream_create} allocates it; the function