> If you make your patch work with --without-included-boost, then I can > handle the rest of making --with-included-boost work.
Attached patch works on my system, with --with-included-boost, subject to renaming libboostxxx-gcc.so to libboostxxx.so. (autoconf needed) I tried to follow the original logic, the only problem I have now is that name = filename; lineno = 0; - return gz_.is_open() && is.good(); + return /* gz_.component(1).is_open() && */ is.good(); gz_.components(int) is supposed to work (I am trying to get hold of file_sink() to test is_open() ) according to http://www.boost.org/libs/iostreams/doc/faq.html#component_access and http://www.boost.org/libs/iostreams/doc/classes/filtering_streambuf.html . I am not sure what goes wrong. The error message is: lyxlex_pimpl.C: In member function `bool LyXLex::Pimpl::setFile(const std::string&)': lyxlex_pimpl.C:155: error: no matching function for call to `boost::iostreams::filtering_streambuf<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char>, boost::iostreams::public_>::component(int)' make[3]: *** [lyxlex_pimpl.o] Error 1 Bo
Index: src/lyxlex_pimpl.C =================================================================== --- src/lyxlex_pimpl.C (revision 13701) +++ src/lyxlex_pimpl.C (working copy) @@ -144,14 +144,15 @@ // The check only outputs a debug message, because it triggers // a bug in compaq cxx 6.2, where is_open() returns 'true' for // a fresh new filebuf. (JMarc) - if (gz_.is_open() || istream::off_type(is.tellg()) > -1) + if (!gz_.empty() || istream::off_type(is.tellg()) > -1) lyxerr[Debug::LYXLEX] << "Error in LyXLex::setFile: " "file or stream already set." << endl; - gz_.open(filename.c_str(), ios::in); + gz_.push(io::gzip_decompressor()); + gz_.push(io::file_source(filename)); is.rdbuf(&gz_); name = filename; lineno = 0; - return gz_.is_open() && is.good(); + return /* gz_.component(1).is_open() && */ is.good(); #else return false; #endif Index: src/buffer.C =================================================================== --- src/buffer.C (revision 13701) +++ src/buffer.C (working copy) @@ -69,7 +69,10 @@ #include "support/filetools.h" #include "support/fs_extras.h" #ifdef USE_COMPRESSION -# include "support/gzstream.h" +# include <boost/iostreams/filtering_stream.hpp> +# include <boost/iostreams/filter/gzip.hpp> +# include <boost/iostreams/device/file.hpp> +namespace io = boost::iostreams; #endif #include "support/lyxlib.h" #include "support/os.h" @@ -735,7 +738,7 @@ if (params().compressed) { #ifdef USE_COMPRESSION - gz::ogzstream ofs(fname.c_str(), ios::out|ios::trunc); + io::filtering_ostream ofs(io::gzip_compressor() | io::file_sink(fname)); if (!ofs) return false; Index: src/lyxlex_pimpl.h =================================================================== --- src/lyxlex_pimpl.h (revision 13701) +++ src/lyxlex_pimpl.h (working copy) @@ -15,7 +15,10 @@ #include "lyxlex.h" #ifdef USE_COMPRESSION -# include "support/gzstream.h" +# include <boost/iostreams/filtering_streambuf.hpp> +# include <boost/iostreams/filter/gzip.hpp> +# include <boost/iostreams/device/file.hpp> +namespace io = boost::iostreams; #endif #include <boost/utility.hpp> @@ -63,7 +66,7 @@ #ifdef USE_COMPRESSION /// gz_ is only used to open files, the stream is accessed through is. - gz::gzstreambuf gz_; + io::filtering_istreambuf gz_; #endif /// the stream that we use. Index: src/Makefile.am =================================================================== --- src/Makefile.am (revision 13701) +++ src/Makefile.am (working copy) @@ -25,7 +25,7 @@ graphics/libgraphics.la \ support/libsupport.la -BOOST_LIBS = $(BOOST_REGEX) $(BOOST_SIGNALS) $(BOOST_FILESYSTEM) +BOOST_LIBS = $(BOOST_REGEX) $(BOOST_SIGNALS) $(BOOST_FILESYSTEM) $(BOOST_IOSTREAMS) OTHERLIBS = $(BOOST_LIBS) $(INTLLIBS) $(AIKSAURUS_LIBS) @LIBS@ $(SOCKET_LIBS) Index: src/support/gzstream.h =================================================================== --- src/support/gzstream.h (revision 13701) +++ src/support/gzstream.h (working copy) @@ -1,125 +0,0 @@ -// ============================================================================ -// gzstream, C++ iostream classes wrapping the zlib compression library. -// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library 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 -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// ============================================================================ -// -// File : gzstream.h -// Revision : $Revision: 1.2 $ -// Revision_date : $Date: 2005/04/26 10:30:24 $ -// Author(s) : Deepak Bandyopadhyay, Lutz Kettner -// -// Standard streambuf implementation following Nicolai Josuttis, "The -// Standard C++ Library". -// ============================================================================ - -#ifndef GZSTREAM_H -#define GZSTREAM_H 1 - -// standard C++ with new header file names and std:: namespace -#include <iostream> -#include <fstream> -#ifdef HAVE_ZLIB_H -# include <zlib.h> -#endif - -// For LyX -#define GZSTREAM_NAMESPACE gz - -#ifdef GZSTREAM_NAMESPACE -namespace GZSTREAM_NAMESPACE { -#endif - -// ---------------------------------------------------------------------------- -// Internal classes to implement gzstream. See below for user classes. -// ---------------------------------------------------------------------------- - -class gzstreambuf : public std::streambuf { -private: - static const int bufferSize = 47+256; // size of data buff - // totals 512 bytes under g++ for igzstream at the end. - - gzFile file; // file handle for compressed file - char buffer[bufferSize]; // data buffer - char opened; // open/close state of stream - int mode; // I/O mode - - int flush_buffer(); -public: - gzstreambuf() : opened(0) { - setp( buffer, buffer + (bufferSize-1)); - setg( buffer + 4, // beginning of putback area - buffer + 4, // read position - buffer + 4); // end position - // ASSERT: both input & output capabilities will not be used together - } - int is_open() { return opened; } - gzstreambuf* open( const char* name, int open_mode); - gzstreambuf* close(); - ~gzstreambuf() { close(); } - - virtual int overflow( int c = EOF); - virtual int underflow(); - virtual int sync(); -}; - -class gzstreambase : virtual public std::ios { -protected: - gzstreambuf buf; -public: - gzstreambase() { init(&buf); } - gzstreambase( const char* name, int open_mode); - ~gzstreambase(); - void open( const char* name, int open_mode); - void close(); - gzstreambuf* rdbuf() { return &buf; } -}; - -// ---------------------------------------------------------------------------- -// User classes. Use igzstream and ogzstream analogously to ifstream and -// ofstream respectively. They read and write files based on the gz* -// function interface of the zlib. Files are compatible with gzip compression. -// ---------------------------------------------------------------------------- - -class igzstream : public gzstreambase, public std::istream { -public: - igzstream() : std::istream( &buf) {} - igzstream( const char* name, int open_mode = std::ios::in) - : gzstreambase( name, open_mode), std::istream( &buf) {} - gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } - void open( const char* name, int open_mode = std::ios::in) { - gzstreambase::open( name, open_mode); - } -}; - -class ogzstream : public gzstreambase, public std::ostream { -public: - ogzstream() : std::ostream( &buf) {} - ogzstream( const char* name, int mode = std::ios::out) - : gzstreambase( name, mode), std::ostream( &buf) {} - gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } - void open( const char* name, int open_mode = std::ios::out) { - gzstreambase::open( name, open_mode); - } -}; - -#ifdef GZSTREAM_NAMESPACE -} // namespace GZSTREAM_NAMESPACE -#endif - -#endif // GZSTREAM_H -// ============================================================================ -// EOF // Index: src/support/Makefile.am =================================================================== --- src/support/Makefile.am (revision 13701) +++ src/support/Makefile.am (working copy) @@ -9,10 +9,6 @@ noinst_LTLIBRARIES = libsupport.la -if USE_COMPRESSION -COMPRESSION = gzstream.C gzstream.h -endif - BUILT_SOURCES = $(PCH_FILE) package.C AM_CPPFLAGS += $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES) @@ -46,7 +42,7 @@ fs_extras.C \ fs_extras.h \ getcwd.C \ - $(COMPRESSION) kill.C \ + kill.C \ limited_stack.h \ lstrings.C \ lstrings.h \ Index: src/support/gzstream.C =================================================================== --- src/support/gzstream.C (revision 13701) +++ src/support/gzstream.C (working copy) @@ -1,169 +0,0 @@ -// ============================================================================ -// gzstream, C++ iostream classes wrapping the zlib compression library. -// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library 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 -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// ============================================================================ -// -// File : gzstream.C -// Revision : $Revision: 1.4 $ -// Revision_date : $Date: 2005/04/26 10:30:24 $ -// Author(s) : Deepak Bandyopadhyay, Lutz Kettner -// -// Standard streambuf implementation following Nicolai Josuttis, "The -// Standard C++ Library". -// ============================================================================ - -#include <config.h> - -#include "gzstream.h" -#include <iostream> -#ifdef HAVE_STRING_H -# include <string.h> // for memcpy -#endif - -#ifdef GZSTREAM_NAMESPACE -namespace GZSTREAM_NAMESPACE { -#endif - -// ---------------------------------------------------------------------------- -// Internal classes to implement gzstream. See header file for user classes. -// ---------------------------------------------------------------------------- - -// -------------------------------------- -// class gzstreambuf: -// -------------------------------------- - -gzstreambuf* gzstreambuf::open( const char* name, int open_mode) { - if ( is_open()) - return (gzstreambuf*)0; - mode = open_mode; - // no append nor read/write mode - if ((mode & std::ios::ate) || (mode & std::ios::app) - || ((mode & std::ios::in) && (mode & std::ios::out))) - return (gzstreambuf*)0; - char fmode[10]; - char* fmodeptr = fmode; - if ( mode & std::ios::in) - *fmodeptr++ = 'r'; - else if ( mode & std::ios::out) - *fmodeptr++ = 'w'; - *fmodeptr++ = 'b'; - *fmodeptr = '\0'; - file = gzopen( name, fmode); - if (file == 0) - return (gzstreambuf*)0; - opened = 1; - return this; -} - -gzstreambuf * gzstreambuf::close() { - if ( is_open()) { - sync(); - opened = 0; - if ( gzclose( file) == Z_OK) - return this; - } - return (gzstreambuf*)0; -} - -int gzstreambuf::underflow() { // used for input buffer only - if ( gptr() && ( gptr() < egptr())) - return * reinterpret_cast<unsigned char *>( gptr()); - - if ( ! (mode & std::ios::in) || ! opened) - return EOF; - // Josuttis' implementation of inbuf - int n_putback = gptr() - eback(); - if ( n_putback > 4) - n_putback = 4; - memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback); - - int num = gzread( file, buffer+4, bufferSize-4); - if (num <= 0) // ERROR or EOF - return EOF; - - // reset buffer pointers - setg( buffer + (4 - n_putback), // beginning of putback area - buffer + 4, // read position - buffer + 4 + num); // end of buffer - - // return next character - return * reinterpret_cast<unsigned char *>( gptr()); -} - -int gzstreambuf::flush_buffer() { - // Separate the writing of the buffer from overflow() and - // sync() operation. - int w = pptr() - pbase(); - if ( gzwrite( file, pbase(), w) != w) - return EOF; - pbump( -w); - return w; -} - -int gzstreambuf::overflow( int c) { // used for output buffer only - if ( ! ( mode & std::ios::out) || ! opened) - return EOF; - if (c != EOF) { - *pptr() = c; - pbump(1); - } - if ( flush_buffer() == EOF) - return EOF; - return c; -} - -int gzstreambuf::sync() { - // Changed to use flush_buffer() instead of overflow( EOF) - // which caused improper behavior with std::endl and flush(), - // bug reported by Vincent Ricard. - if ( pptr() && pptr() > pbase()) { - if ( flush_buffer() == EOF) - return -1; - } - return 0; -} - -// -------------------------------------- -// class gzstreambase: -// -------------------------------------- - -gzstreambase::gzstreambase( const char* name, int mode) { - init( &buf); - open( name, mode); -} - -gzstreambase::~gzstreambase() { - buf.close(); -} - -void gzstreambase::open( const char* name, int open_mode) { - if ( ! buf.open( name, open_mode)) - clear( rdstate() | std::ios::badbit); -} - -void gzstreambase::close() { - if ( buf.is_open()) - if ( ! buf.close()) - clear( rdstate() | std::ios::badbit); -} - -#ifdef GZSTREAM_NAMESPACE -} // namespace GZSTREAM_NAMESPACE -#endif - -// ============================================================================ -// EOF // Index: src/tex2lyx/Makefile.am =================================================================== --- src/tex2lyx/Makefile.am (revision 13701) +++ src/tex2lyx/Makefile.am (working copy) @@ -18,7 +18,7 @@ AM_CPPFLAGS += $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES) -BOOST_LIBS = $(BOOST_REGEX) $(BOOST_FILESYSTEM) +BOOST_LIBS = $(BOOST_REGEX) $(BOOST_FILESYSTEM) $(BOOST_IOSTREAMS) if USE_COMPRESSION COMPRESSIONLIB = -lz Index: config/common.am =================================================================== --- config/common.am (revision 13701) +++ config/common.am (working copy) @@ -33,11 +33,13 @@ BOOST_FILESYSTEM = $(top_builddir)/boost/libs/filesystem/src/libboost_filesystem.la BOOST_REGEX = $(top_builddir)/boost/libs/regex/src/libboost_regex.la BOOST_SIGNALS = $(top_builddir)/boost/libs/signals/src/libboost_signals.la +BOOST_IOSTREAMS = $(top_builddir)/boost/libs/iostreams/src/libboost_iostreams.la else BOOST_INCLUDES = BOOST_FILESYSTEM = -lboost_filesystem BOOST_REGEX = -lboost_regex BOOST_SIGNALS = -lboost_signals +BOOST_IOSTREAMS = -lboost_iostreams endif LIBS =