]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
libtextstyle: Document when and how to turn off styling.
authorBruno Haible <bruno@clisp.org>
Fri, 15 Feb 2019 20:39:56 +0000 (21:39 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 15 Feb 2019 20:44:08 +0000 (21:44 +0100)
* 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.

gnulib-local/lib/term-styled-ostream.oo.c
libtextstyle/doc/libtextstyle.texi

index c0e7003ac45c061db8e8bf9850698c9e35e2faa6..69ca68452f2cc0891f8d3a592f6f7627dc363788 100644 (file)
@@ -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);
 
index 209fef9c502a524073ff952613fe8ec9ba072cac..f7cb5df54735387a359b027ff846c2f705854f42 100644 (file)
@@ -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