diff options
author | Bruno Haible <bruno@clisp.org> | 2019-04-02 17:52:29 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2019-04-02 17:52:29 +0200 |
commit | 7200ac4191bd1fed0e5b9230d354fb17716b5559 (patch) | |
tree | ec26ee2e00e3d1df32fba6c665e89da3a410ef6c /gnulib-local | |
parent | 283418cdf9425f5abc13e9097f1507e26f81d54e (diff) | |
download | gettext-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.
Diffstat (limited to 'gnulib-local')
-rw-r--r-- | gnulib-local/Makefile.am | 6 | ||||
-rw-r--r-- | gnulib-local/lib/fd-styled-ostream.oo.c | 89 | ||||
-rw-r--r-- | gnulib-local/lib/noop-styled-ostream.oo.c | 91 | ||||
-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-ostream | 49 | ||||
-rw-r--r-- | gnulib-local/modules/noop-styled-ostream | 49 |
6 files changed, 157 insertions, 151 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 + |