summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2019-04-02 17:52:29 +0200
committerBruno Haible <bruno@clisp.org>2019-04-02 17:52:29 +0200
commit7200ac4191bd1fed0e5b9230d354fb17716b5559 (patch)
treeec26ee2e00e3d1df32fba6c665e89da3a410ef6c
parent283418cdf9425f5abc13e9097f1507e26f81d54e (diff)
downloadgettext-7200ac4191bd1fed0e5b9230d354fb17716b5559.tar.gz
libtextstyle: Generalize fd-styled-ostream to noop-styled-ostream.
* gnulib-local/lib/noop-styled-ostream.oo.h: New file, based on gnulib-local/lib/fd-styled-ostream.oo.h. * gnulib-local/lib/noop-styled-ostream.oo.c: New file, based on gnulib-local/lib/fd-styled-ostream.oo.c. * gnulib-local/modules/noop-styled-ostream: New file, based on gnulib-local/modules/fd-styled-ostream. * gnulib-local/Makefile.am (EXTRA_DIST): Remove lib/fd-styled-ostream.oo.[hc] and modules/fd-styled-ostream. Add lib/noop-styled-ostream.oo.[hc] and modules/noop-styled-ostream. * libtextstyle/woe32dll/c++noop-styled-ostream.cc: New file, based on libtextstyle/woe32dll/c++fd-styled-ostream.cc. * libtextstyle/gnulib-local/modules/noop-styled-ostream.diff: New file, based on libtextstyle/gnulib-local/modules/fd-styled-ostream.diff. * gnulib-local/lib/fd-styled-ostream.oo.h: Remove file. * gnulib-local/lib/fd-styled-ostream.oo.c: Remove file. * gnulib-local/modules/fd-styled-ostream: Remove file. * libtextstyle/woe32dll/c++fd-styled-ostream.cc: Remove file. * libtextstyle/gnulib-local/modules/fd-styled-ostream.diff: Remove file. * libtextstyle/autogen.sh (GNULIB_MODULES): Add noop-styled-ostream. Remove fd-styled-ostream. * libtextstyle/lib/misc.c: Include noop-styled-ostream.h, fd-ostream.h. (styled_ostream_create): Call fd_ostream_create and noop_styled_ostream_create instead of fd_styled_ostream_create. * libtextstyle/lib/textstyle.h (noop_styled_ostream_t): New type. (noop_styled_ostream_*): New declarations. * libtextstyle/doc/libtextstyle.texi (The noop_styled_ostream class): New subsection.
-rw-r--r--gnulib-local/Makefile.am6
-rw-r--r--gnulib-local/lib/fd-styled-ostream.oo.c89
-rw-r--r--gnulib-local/lib/noop-styled-ostream.oo.c91
-rw-r--r--gnulib-local/lib/noop-styled-ostream.oo.h (renamed from gnulib-local/lib/fd-styled-ostream.oo.h)24
-rw-r--r--gnulib-local/modules/fd-styled-ostream49
-rw-r--r--gnulib-local/modules/noop-styled-ostream49
-rw-r--r--libtextstyle/.gitignore12
-rwxr-xr-xlibtextstyle/autogen.sh2
-rw-r--r--libtextstyle/doc/libtextstyle.texi22
-rw-r--r--libtextstyle/gnulib-local/modules/fd-styled-ostream.diff23
-rw-r--r--libtextstyle/gnulib-local/modules/noop-styled-ostream.diff23
-rw-r--r--libtextstyle/lib/misc.c6
-rw-r--r--libtextstyle/lib/textstyle.h38
-rw-r--r--libtextstyle/woe32dll/c++fd-styled-ostream.cc1
-rw-r--r--libtextstyle/woe32dll/c++noop-styled-ostream.cc1
15 files changed, 252 insertions, 184 deletions
diff --git a/gnulib-local/Makefile.am b/gnulib-local/Makefile.am
index ddab7032b..2d110d8f9 100644
--- a/gnulib-local/Makefile.am
+++ b/gnulib-local/Makefile.am
@@ -37,8 +37,6 @@ lib/error-progname.h \
lib/exitfail.h.diff \
lib/fd-ostream.oo.c \
lib/fd-ostream.oo.h \
-lib/fd-styled-ostream.oo.c \
-lib/fd-styled-ostream.oo.h \
lib/file-ostream.oo.c \
lib/file-ostream.oo.h \
lib/fnmatch.c.diff \
@@ -230,6 +228,8 @@ lib/markup.h \
lib/memory-ostream.oo.c \
lib/memory-ostream.oo.h \
lib/moo.h \
+lib/noop-styled-ostream.oo.c \
+lib/noop-styled-ostream.oo.h \
lib/obstack.h.diff \
lib/ostream.oo.c \
lib/ostream.oo.h \
@@ -270,7 +270,6 @@ modules/basename \
modules/closeout \
modules/error-progname \
modules/fd-ostream \
-modules/fd-styled-ostream \
modules/file-ostream \
modules/fnmatch.diff \
modules/gettext-runtime-misc \
@@ -287,6 +286,7 @@ modules/markup \
modules/memory-ostream \
modules/moo \
modules/moo-tests \
+modules/noop-styled-ostream \
modules/ostream \
modules/styled-ostream \
modules/termcap \
diff --git a/gnulib-local/lib/fd-styled-ostream.oo.c b/gnulib-local/lib/fd-styled-ostream.oo.c
deleted file mode 100644
index 8cf64621a..000000000
--- a/gnulib-local/lib/fd-styled-ostream.oo.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Output stream with no-op styling, referring to a file descriptor.
- Copyright (C) 2006, 2019 Free Software Foundation, Inc.
- Written by Bruno Haible <bruno@clisp.org>, 2019.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include "fd-styled-ostream.h"
-
-#include "fd-ostream.h"
-
-#include "xalloc.h"
-
-
-struct fd_styled_ostream : struct styled_ostream
-{
-fields:
- /* The destination stream. */
- fd_ostream_t destination;
-};
-
-/* Implementation of ostream_t methods. */
-
-static void
-fd_styled_ostream::write_mem (fd_styled_ostream_t stream,
- const void *data, size_t len)
-{
- fd_ostream_write_mem (stream->destination, data, len);
-}
-
-static void
-fd_styled_ostream::flush (fd_styled_ostream_t stream, ostream_flush_scope_t scope)
-{
- fd_ostream_flush (stream->destination, scope);
-}
-
-static void
-fd_styled_ostream::free (fd_styled_ostream_t stream)
-{
- fd_ostream_free (stream->destination);
- free (stream);
-}
-
-/* Implementation of styled_ostream_t methods. */
-
-static void
-fd_styled_ostream::begin_use_class (fd_styled_ostream_t stream,
- const char *classname)
-{
-}
-
-static void
-fd_styled_ostream::end_use_class (fd_styled_ostream_t stream,
- const char *classname)
-{
-}
-
-static void
-fd_styled_ostream::flush_to_current_style (fd_styled_ostream_t stream)
-{
- fd_ostream_flush (stream->destination, FLUSH_THIS_STREAM);
-}
-
-/* Constructor. */
-
-fd_styled_ostream_t
-fd_styled_ostream_create (int fd, const char *filename)
-{
- fd_styled_ostream_t stream =
- XMALLOC (struct fd_styled_ostream_representation);
-
- stream->base.base.vtable = &fd_styled_ostream_vtable;
- stream->destination = fd_ostream_create (fd, filename, true);
-
- return stream;
-}
diff --git a/gnulib-local/lib/noop-styled-ostream.oo.c b/gnulib-local/lib/noop-styled-ostream.oo.c
new file mode 100644
index 000000000..f24cffbe9
--- /dev/null
+++ b/gnulib-local/lib/noop-styled-ostream.oo.c
@@ -0,0 +1,91 @@
+/* Output stream with no-op styling.
+ Copyright (C) 2006, 2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2019.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "noop-styled-ostream.h"
+
+#include "xalloc.h"
+
+
+struct noop_styled_ostream : struct styled_ostream
+{
+fields:
+ /* The destination stream. */
+ ostream_t destination;
+ bool own_destination;
+};
+
+/* Implementation of ostream_t methods. */
+
+static void
+noop_styled_ostream::write_mem (noop_styled_ostream_t stream,
+ const void *data, size_t len)
+{
+ ostream_write_mem (stream->destination, data, len);
+}
+
+static void
+noop_styled_ostream::flush (noop_styled_ostream_t stream,
+ ostream_flush_scope_t scope)
+{
+ ostream_flush (stream->destination, scope);
+}
+
+static void
+noop_styled_ostream::free (noop_styled_ostream_t stream)
+{
+ if (stream->own_destination)
+ ostream_free (stream->destination);
+ free (stream);
+}
+
+/* Implementation of styled_ostream_t methods. */
+
+static void
+noop_styled_ostream::begin_use_class (noop_styled_ostream_t stream,
+ const char *classname)
+{
+}
+
+static void
+noop_styled_ostream::end_use_class (noop_styled_ostream_t stream,
+ const char *classname)
+{
+}
+
+static void
+noop_styled_ostream::flush_to_current_style (noop_styled_ostream_t stream)
+{
+ ostream_flush (stream->destination, FLUSH_THIS_STREAM);
+}
+
+/* Constructor. */
+
+noop_styled_ostream_t
+noop_styled_ostream_create (ostream_t destination, bool pass_ownership)
+{
+ noop_styled_ostream_t stream =
+ XMALLOC (struct noop_styled_ostream_representation);
+
+ stream->base.base.vtable = &noop_styled_ostream_vtable;
+ stream->destination = destination;
+ stream->own_destination = pass_ownership;
+
+ return stream;
+}
diff --git a/gnulib-local/lib/fd-styled-ostream.oo.h b/gnulib-local/lib/noop-styled-ostream.oo.h
index 04eaaff5d..fa64e1c87 100644
--- a/gnulib-local/lib/fd-styled-ostream.oo.h
+++ b/gnulib-local/lib/noop-styled-ostream.oo.h
@@ -1,4 +1,4 @@
-/* Output stream with no-op styling, referring to a file descriptor.
+/* Output stream with no-op styling.
Copyright (C) 2006, 2019 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2019.
@@ -15,13 +15,15 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
-#ifndef _FD_STYLED_OSTREAM_H
-#define _FD_STYLED_OSTREAM_H
+#ifndef _NOOP_STYLED_OSTREAM_H
+#define _NOOP_STYLED_OSTREAM_H
+
+#include <stdbool.h>
#include "styled-ostream.h"
-struct fd_styled_ostream : struct styled_ostream
+struct noop_styled_ostream : struct styled_ostream
{
methods:
};
@@ -32,16 +34,18 @@ extern "C" {
#endif
-/* Create an output stream referring to the file descriptor FD, that supports
+/* Create an output stream that delegates to DESTINATION and that supports
the styling operations as no-ops.
- FILENAME is used only for error messages.
- Note that the resulting stream must be closed before FD can be closed. */
-extern fd_styled_ostream_t
- fd_styled_ostream_create (int fd, const char *filename);
+ If PASS_OWNERSHIP is true, closing the resulting stream will automatically
+ close the DESTINATION.
+ Note that if PASS_OWNERSHIP is false, the resulting stream must be closed
+ before DESTINATION can be closed. */
+extern noop_styled_ostream_t
+ noop_styled_ostream_create (ostream_t destination, bool pass_ownership);
#ifdef __cplusplus
}
#endif
-#endif /* _FD_STYLED_OSTREAM_H */
+#endif /* _NOOP_STYLED_OSTREAM_H */
diff --git a/gnulib-local/modules/fd-styled-ostream b/gnulib-local/modules/fd-styled-ostream
deleted file mode 100644
index 1b8582aff..000000000
--- a/gnulib-local/modules/fd-styled-ostream
+++ /dev/null
@@ -1,49 +0,0 @@
-Description:
-Output stream with no-op styling, referring to a file descriptor.
-
-Files:
-lib/fd-styled-ostream.oo.h
-lib/fd-styled-ostream.oo.c
-
-Depends-on:
-styled-ostream
-fd-ostream
-xalloc
-
-configure.ac:
-
-Makefile.am:
-if !WOE32DLL
-lib_SOURCES += fd-styled-ostream.c
-else
-lib_SOURCES += ../woe32dll/c++fd-styled-ostream.cc
-endif
-# This is a Makefile rule that generates multiple files at once; see the
-# automake documentation, node "Multiple Outputs", for details.
-$(srcdir)/fd-styled-ostream.h : $(top_srcdir)/build-aux/moopp fd-styled-ostream.oo.h fd-styled-ostream.oo.c styled-ostream.oo.h ostream.oo.h
- $(top_srcdir)/build-aux/moopp $(MOOPPFLAGS) $(srcdir)/fd-styled-ostream.oo.c $(srcdir)/fd-styled-ostream.oo.h $(srcdir)/styled-ostream.oo.h $(srcdir)/ostream.oo.h
-$(srcdir)/fd-styled-ostream.c $(srcdir)/fd_styled_ostream.priv.h $(srcdir)/fd_styled_ostream.vt.h : fd-styled-ostream.h
- @test -f $@ || { \
- trap 'rm -rf fd-styled-ostream.lock' 1 2 13 15; \
- if mkdir fd-styled-ostream.lock 2>/dev/null; then \
- echo "$(top_srcdir)/build-aux/moopp $(MOOPPFLAGS) $(srcdir)/fd-styled-ostream.oo.c $(srcdir)/fd-styled-ostream.oo.h $(srcdir)/styled-ostream.oo.h $(srcdir)/ostream.oo.h"; \
- $(top_srcdir)/build-aux/moopp $(MOOPPFLAGS) $(srcdir)/fd-styled-ostream.oo.c $(srcdir)/fd-styled-ostream.oo.h $(srcdir)/styled-ostream.oo.h $(srcdir)/ostream.oo.h; \
- result=$$?; rm -rf fd-styled-ostream.lock; exit $$result; \
- else \
- while test -d fd-styled-ostream.lock; do sleep 1; done; \
- test -f $(srcdir)/fd-styled-ostream.h; \
- fi; \
- }
-BUILT_SOURCES += fd-styled-ostream.h fd-styled-ostream.c fd_styled_ostream.priv.h fd_styled_ostream.vt.h
-MAINTAINERCLEANFILES += fd-styled-ostream.h fd-styled-ostream.c fd_styled_ostream.priv.h fd_styled_ostream.vt.h
-EXTRA_DIST += fd-styled-ostream.h fd-styled-ostream.c fd_styled_ostream.priv.h fd_styled_ostream.vt.h
-
-Include:
-"fd-styled-ostream.h"
-
-License:
-GPL
-
-Maintainer:
-Bruno Haible
-
diff --git a/gnulib-local/modules/noop-styled-ostream b/gnulib-local/modules/noop-styled-ostream
new file mode 100644
index 000000000..9fcd12ccb
--- /dev/null
+++ b/gnulib-local/modules/noop-styled-ostream
@@ -0,0 +1,49 @@
+Description:
+Output stream with no-op styling.
+
+Files:
+lib/noop-styled-ostream.oo.h
+lib/noop-styled-ostream.oo.c
+
+Depends-on:
+styled-ostream
+stdbool
+xalloc
+
+configure.ac:
+
+Makefile.am:
+if !WOE32DLL
+lib_SOURCES += noop-styled-ostream.c
+else
+lib_SOURCES += ../woe32dll/c++noop-styled-ostream.cc
+endif
+# This is a Makefile rule that generates multiple files at once; see the
+# automake documentation, node "Multiple Outputs", for details.
+$(srcdir)/noop-styled-ostream.h : $(top_srcdir)/build-aux/moopp noop-styled-ostream.oo.h noop-styled-ostream.oo.c styled-ostream.oo.h ostream.oo.h
+ $(top_srcdir)/build-aux/moopp $(MOOPPFLAGS) $(srcdir)/noop-styled-ostream.oo.c $(srcdir)/noop-styled-ostream.oo.h $(srcdir)/styled-ostream.oo.h $(srcdir)/ostream.oo.h
+$(srcdir)/noop-styled-ostream.c $(srcdir)/noop_styled_ostream.priv.h $(srcdir)/noop_styled_ostream.vt.h : noop-styled-ostream.h
+ @test -f $@ || { \
+ trap 'rm -rf noop-styled-ostream.lock' 1 2 13 15; \
+ if mkdir noop-styled-ostream.lock 2>/dev/null; then \
+ echo "$(top_srcdir)/build-aux/moopp $(MOOPPFLAGS) $(srcdir)/noop-styled-ostream.oo.c $(srcdir)/noop-styled-ostream.oo.h $(srcdir)/styled-ostream.oo.h $(srcdir)/ostream.oo.h"; \
+ $(top_srcdir)/build-aux/moopp $(MOOPPFLAGS) $(srcdir)/noop-styled-ostream.oo.c $(srcdir)/noop-styled-ostream.oo.h $(srcdir)/styled-ostream.oo.h $(srcdir)/ostream.oo.h; \
+ result=$$?; rm -rf noop-styled-ostream.lock; exit $$result; \
+ else \
+ while test -d noop-styled-ostream.lock; do sleep 1; done; \
+ test -f $(srcdir)/noop-styled-ostream.h; \
+ fi; \
+ }
+BUILT_SOURCES += noop-styled-ostream.h noop-styled-ostream.c noop_styled_ostream.priv.h noop_styled_ostream.vt.h
+MAINTAINERCLEANFILES += noop-styled-ostream.h noop-styled-ostream.c noop_styled_ostream.priv.h noop_styled_ostream.vt.h
+EXTRA_DIST += noop-styled-ostream.h noop-styled-ostream.c noop_styled_ostream.priv.h noop_styled_ostream.vt.h
+
+Include:
+"noop-styled-ostream.h"
+
+License:
+GPL
+
+Maintainer:
+Bruno Haible
+
diff --git a/libtextstyle/.gitignore b/libtextstyle/.gitignore
index 12e4908be..5dab4fbe7 100644
--- a/libtextstyle/.gitignore
+++ b/libtextstyle/.gitignore
@@ -49,8 +49,6 @@
/lib/fd-hook.h
/lib/fd-ostream.oo.c
/lib/fd-ostream.oo.h
-/lib/fd-styled-ostream.oo.c
-/lib/fd-styled-ostream.oo.h
/lib/file-ostream.oo.c
/lib/file-ostream.oo.h
/lib/filename.h
@@ -108,6 +106,8 @@
/lib/msvc-inval.h
/lib/msvc-nothrow.c
/lib/msvc-nothrow.h
+/lib/noop-styled-ostream.oo.c
+/lib/noop-styled-ostream.oo.h
/lib/obstack.c
/lib/obstack.h
/lib/ostream.oo.c
@@ -233,12 +233,8 @@
/lib/libtextstyle.sym.in
/lib/fd-ostream.c
/lib/fd-ostream.h
-/lib/fd-styled-ostream.c
-/lib/fd-styled-ostream.h
/lib/fd_ostream.priv.h
/lib/fd_ostream.vt.h
-/lib/fd_styled_ostream.priv.h
-/lib/fd_styled_ostream.vt.h
/lib/file-ostream.c
/lib/file-ostream.h
/lib/file_ostream.priv.h
@@ -259,6 +255,10 @@
/lib/memory-ostream.h
/lib/memory_ostream.priv.h
/lib/memory_ostream.vt.h
+/lib/noop-styled-ostream.c
+/lib/noop-styled-ostream.h
+/lib/noop_styled_ostream.priv.h
+/lib/noop_styled_ostream.vt.h
/lib/ostream.c
/lib/ostream.h
/lib/ostream.priv.h
diff --git a/libtextstyle/autogen.sh b/libtextstyle/autogen.sh
index d1980dfc4..dd7765672 100755
--- a/libtextstyle/autogen.sh
+++ b/libtextstyle/autogen.sh
@@ -80,8 +80,8 @@ if test $skip_gnulib = false; then
memory-ostream
term-ostream
styled-ostream
- fd-styled-ostream
html-styled-ostream
+ noop-styled-ostream
term-styled-ostream
filename
isatty
diff --git a/libtextstyle/doc/libtextstyle.texi b/libtextstyle/doc/libtextstyle.texi
index 174487c6f..a9ca095c7 100644
--- a/libtextstyle/doc/libtextstyle.texi
+++ b/libtextstyle/doc/libtextstyle.texi
@@ -990,6 +990,7 @@ can be closed.
@menu
* The term_styled_ostream class:: Styled output to a terminal.
* The html_styled_ostream class:: Styled output to an HTML file.
+* The noop_styled_ostream class:: No-op styling.
@end menu
@node The term_styled_ostream class
@@ -1052,6 +1053,27 @@ Note: The resulting stream must be closed before @code{@var{destination}}
can be closed.
@end deftypefn
+@node The noop_styled_ostream class
+@subsubsection The @code{noop_styled_ostream} class
+
+The @code{noop_styled_ostream} class supports the styled output operations
+to any destination. The text is output to the given destination; the
+styling operations, however, do nothing. Its type is
+@samp{noop_styled_ostream_t}. It is a subclass of @samp{styled_ostream_t}.
+
+It can be instantiated through this function:
+
+@deftypefn Function noop_styled_ostream_t noop_styled_ostream_create (ostream_t@tie{}@var{destination}, bool@tie{}@var{pass_ownership})
+Creates an output stream that delegates to @code{@var{destination}} and
+that supports the styling operations as no-ops.
+
+If @code{@var{pass_ownership}} is @code{true}, closing the resulting
+stream will automatically close the @code{@var{destination}}.
+
+Note: If @code{@var{pass_ownership}} is @code{false}, the resulting stream
+must be closed before @code{@var{destination}} can be closed.
+@end deftypefn
+
@node What to document
@section Documenting the text styling support
diff --git a/libtextstyle/gnulib-local/modules/fd-styled-ostream.diff b/libtextstyle/gnulib-local/modules/fd-styled-ostream.diff
deleted file mode 100644
index cb6d94831..000000000
--- a/libtextstyle/gnulib-local/modules/fd-styled-ostream.diff
+++ /dev/null
@@ -1,23 +0,0 @@
-*** fd-styled-ostream.orig
---- fd-styled-ostream
-***************
-*** 13,23 ****
- configure.ac:
-
- Makefile.am:
-- if !WOE32DLL
- lib_SOURCES += fd-styled-ostream.c
-- else
-- lib_SOURCES += ../woe32dll/c++fd-styled-ostream.cc
-- endif
- # This is a Makefile rule that generates multiple files at once; see the
- # automake documentation, node "Multiple Outputs", for details.
- $(srcdir)/fd-styled-ostream.h : $(top_srcdir)/build-aux/moopp fd-styled-ostream.oo.h fd-styled-ostream.oo.c styled-ostream.oo.h ostream.oo.h
---- 13,19 ----
- configure.ac:
-
- Makefile.am:
- lib_SOURCES += fd-styled-ostream.c
- # This is a Makefile rule that generates multiple files at once; see the
- # automake documentation, node "Multiple Outputs", for details.
- $(srcdir)/fd-styled-ostream.h : $(top_srcdir)/build-aux/moopp fd-styled-ostream.oo.h fd-styled-ostream.oo.c styled-ostream.oo.h ostream.oo.h
diff --git a/libtextstyle/gnulib-local/modules/noop-styled-ostream.diff b/libtextstyle/gnulib-local/modules/noop-styled-ostream.diff
new file mode 100644
index 000000000..cef0a0677
--- /dev/null
+++ b/libtextstyle/gnulib-local/modules/noop-styled-ostream.diff
@@ -0,0 +1,23 @@
+*** noop-styled-ostream.orig
+--- noop-styled-ostream
+***************
+*** 13,23 ****
+ configure.ac:
+
+ Makefile.am:
+- if !WOE32DLL
+ lib_SOURCES += noop-styled-ostream.c
+- else
+- lib_SOURCES += ../woe32dll/c++noop-styled-ostream.cc
+- endif
+ # This is a Makefile rule that generates multiple files at once; see the
+ # automake documentation, node "Multiple Outputs", for details.
+ $(srcdir)/noop-styled-ostream.h : $(top_srcdir)/build-aux/moopp noop-styled-ostream.oo.h noop-styled-ostream.oo.c styled-ostream.oo.h ostream.oo.h
+--- 13,19 ----
+ configure.ac:
+
+ Makefile.am:
+ lib_SOURCES += noop-styled-ostream.c
+ # This is a Makefile rule that generates multiple files at once; see the
+ # automake documentation, node "Multiple Outputs", for details.
+ $(srcdir)/noop-styled-ostream.h : $(top_srcdir)/build-aux/moopp noop-styled-ostream.oo.h noop-styled-ostream.oo.c styled-ostream.oo.h ostream.oo.h
diff --git a/libtextstyle/lib/misc.c b/libtextstyle/lib/misc.c
index aed4001c6..866fd212f 100644
--- a/libtextstyle/lib/misc.c
+++ b/libtextstyle/lib/misc.c
@@ -21,7 +21,8 @@
#include "misc.h"
#include "term-styled-ostream.h"
-#include "fd-styled-ostream.h"
+#include "noop-styled-ostream.h"
+#include "fd-ostream.h"
#include "exitfail.h"
extern int xmalloc_exit_failure;
@@ -35,7 +36,8 @@ styled_ostream_create (int fd, const char *filename, ttyctl_t tty_control,
stream = term_styled_ostream_create (fd, filename, tty_control, css_filename);
if (stream == NULL)
- stream = fd_styled_ostream_create (fd, filename);
+ stream =
+ noop_styled_ostream_create (fd_ostream_create (fd, filename, true), true);
return stream;
}
diff --git a/libtextstyle/lib/textstyle.h b/libtextstyle/lib/textstyle.h
index 4b79e52f6..0a76beba2 100644
--- a/libtextstyle/lib/textstyle.h
+++ b/libtextstyle/lib/textstyle.h
@@ -462,6 +462,44 @@ extern html_styled_ostream_t
}
#endif
+/* ----------------------- From noop-styled-ostream.h ----------------------- */
+
+/* noop_styled_ostream_t is a subtype of styled_ostream_t. */
+typedef styled_ostream_t noop_styled_ostream_t;
+
+/* Functions that invoke the methods. */
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void noop_styled_ostream_write_mem (noop_styled_ostream_t first_arg, const void *data, size_t len);
+extern void noop_styled_ostream_flush (noop_styled_ostream_t first_arg, ostream_flush_scope_t scope);
+extern void noop_styled_ostream_free (noop_styled_ostream_t first_arg);
+extern void noop_styled_ostream_begin_use_class (noop_styled_ostream_t first_arg, const char *classname);
+extern void noop_styled_ostream_end_use_class (noop_styled_ostream_t first_arg, const char *classname);
+extern void noop_styled_ostream_flush_to_current_style (noop_styled_ostream_t first_arg);
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Create an output stream that delegates to DESTINATION and that supports
+ the styling operations as no-ops.
+ If PASS_OWNERSHIP is true, closing the resulting stream will automatically
+ close the DESTINATION.
+ Note that if PASS_OWNERSHIP is false, the resulting stream must be closed
+ before DESTINATION can be closed. */
+extern noop_styled_ostream_t
+ noop_styled_ostream_create (ostream_t destination, bool pass_ownership);
+
+
+#ifdef __cplusplus
+}
+#endif
+
/* ------------------------------ From color.h ------------------------------ */
#ifdef __cplusplus
diff --git a/libtextstyle/woe32dll/c++fd-styled-ostream.cc b/libtextstyle/woe32dll/c++fd-styled-ostream.cc
deleted file mode 100644
index bbe4b2a1a..000000000
--- a/libtextstyle/woe32dll/c++fd-styled-ostream.cc
+++ /dev/null
@@ -1 +0,0 @@
-#include "../lib/fd-styled-ostream.c"
diff --git a/libtextstyle/woe32dll/c++noop-styled-ostream.cc b/libtextstyle/woe32dll/c++noop-styled-ostream.cc
new file mode 100644
index 000000000..e74fab162
--- /dev/null
+++ b/libtextstyle/woe32dll/c++noop-styled-ostream.cc
@@ -0,0 +1 @@
+#include "../lib/noop-styled-ostream.c"