From 2ac6d6da48c8e8ea87529088685337cc4bf7b87c Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 13 Oct 1999 10:34:07 +0000 Subject: [PATCH] Some cleanups to compile with dec cxx. We are not there yet though. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@189 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 18 ++++++++++++++++ src/commandtags.h | 2 +- src/debug.h | 5 +++-- src/insets/Makefile.am | 4 ++-- src/lyxfont.h | 1 + src/mathed/Makefile.am | 2 +- src/mathed/math_defs.h | 1 + src/support/DebugStream.C | 44 +++++++++++++++++++-------------------- src/support/DebugStream.h | 18 ++++++++++++---- src/support/filetools.C | 1 + 10 files changed, 64 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index f8f15495cb..ca42a9ae85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +1999-10-13 Jean-Marc Lasgouttes + + * src/support/DebugStream.[Ch]: remove the explicit std:: before + streams classes and types, add the proper 'using' statements when + MODERN_STL is defined. + + * src/debug.h: move the << operator definition after the inclusion + of DebugStream.h + + * src/support/filetools.C: include "LAssert.h", which is needed + later. + + * src/insets/Makefile.am, src/mathed/Makefile.am: add src/support + to includes. + + * src/lyxfont.h, src/commandtags.h, src/mathed/math_defs.h: + include "debug.h" to define a proper ostream. + 1999-10-12 Asger Alstrup Nielsen * src/sys*: Cleaned up the Systemcall stuff a bit. Added "kill(int)" diff --git a/src/commandtags.h b/src/commandtags.h index c5461022e9..a8c36d313c 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -10,6 +10,7 @@ #ifndef COMMANDTAGS_H #define COMMANDTAGS_H +#include "debug.h" /** These are all the lyxfunctions (as enums). */ @@ -240,7 +241,6 @@ enum kb_action { LFUN_LASTACTION /* this marks the end of the table */ }; -class ostream; ostream & operator<<(ostream &, kb_action); #endif diff --git a/src/debug.h b/src/debug.h index a6495f33fd..0dd2501c60 100644 --- a/src/debug.h +++ b/src/debug.h @@ -82,11 +82,12 @@ struct Debug { } }; -/// -ostream & operator<<(ostream & o, Debug::type t); #include "support/DebugStream.h" +/// +ostream & operator<<(ostream & o, Debug::type t); + extern DebugStream lyxerr; #endif diff --git a/src/insets/Makefile.am b/src/insets/Makefile.am index cfa746538d..aac101d030 100644 --- a/src/insets/Makefile.am +++ b/src/insets/Makefile.am @@ -4,7 +4,7 @@ noinst_PROGRAMS = insets.o LIBS= LDFLAGS= ETAGS_ARGS = --c++ -INCLUDES = -I${srcdir}/../ +INCLUDES = -I${srcdir}/../ -I${srcdir}/../support CXXLINK = $(LD) -r -o $(noinst_PROGRAMS) insets_o_SOURCES = \ @@ -47,4 +47,4 @@ insets_o_SOURCES = \ insettoc.h \ inseturl.C \ inseturl.h \ - lyxinset.h \ No newline at end of file + lyxinset.h diff --git a/src/lyxfont.h b/src/lyxfont.h index 6c0287b5d6..8de7868ea4 100644 --- a/src/lyxfont.h +++ b/src/lyxfont.h @@ -17,6 +17,7 @@ #include FORMS_H_LOCATION #include "LString.h" +#include "debug.h" // It might happen that locale.h defines ON and OFF. This is not good // for us, since we use these names below. But of course this is due diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index e0562fc8a6..06aadaec5f 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -4,7 +4,7 @@ noinst_PROGRAMS = mathed.o LIBS= LDFLAGS= ETAGS_ARGS = --c++ -INCLUDES = -I${top_srcdir}/images -I${srcdir}/../ +INCLUDES = -I${top_srcdir}/images -I${srcdir}/../ -I${srcdir}/../support CXXLINK = $(LD) -r -o $(noinst_PROGRAMS) mathed_o_SOURCES = array.h \ diff --git a/src/mathed/math_defs.h b/src/mathed/math_defs.h index 0a8970a0ff..0e34bb0ce4 100644 --- a/src/mathed/math_defs.h +++ b/src/mathed/math_defs.h @@ -26,6 +26,7 @@ #include #include "LString.h" +#include "debug.h" #include "array.h" diff --git a/src/support/DebugStream.C b/src/support/DebugStream.C index 37ca1fcf96..a450373c73 100644 --- a/src/support/DebugStream.C +++ b/src/support/DebugStream.C @@ -27,12 +27,12 @@ ostream & operator<<(ostream & o, Debug::type t) that is the intention. You can call it a no-op streambuffer, and the ostream that uses it will be a no-op stream. */ -class nullbuf : public std::streambuf { +class nullbuf : public streambuf { protected: /// virtual int sync() { return 0; } /// - virtual std::streamsize xsputn(char const *, std::streamsize n) { + virtual streamsize xsputn(char const *, streamsize n) { // fakes a purge of the buffer by returning n return n; } @@ -46,11 +46,11 @@ protected: /** A streambuf that sends the output to two different streambufs. These can be any kind of streambufs. */ -class teebuf : public std::streambuf { +class teebuf : public streambuf { public: /// - teebuf(std::streambuf * b1, std::streambuf * b2) - : std::streambuf(), sb1(b1), sb2(b2) {} + teebuf(streambuf * b1, streambuf * b2) + : streambuf(), sb1(b1), sb2(b2) {} protected: /// virtual int sync() { @@ -63,7 +63,7 @@ protected: #endif } /// - virtual std::streamsize xsputn(char const * p, std::streamsize n) { + virtual streamsize xsputn(char const * p, streamsize n) { #ifdef MODERN_STL sb2->sputn(p, n); return sb1->sputn(p, n); @@ -84,17 +84,17 @@ protected: } private: /// - std::streambuf * sb1; + streambuf * sb1; /// - std::streambuf * sb2; + streambuf * sb2; }; /// -class debugbuf : public std::streambuf { +class debugbuf : public streambuf { public: /// - debugbuf(std::streambuf * b) - : std::streambuf(), sb(b) {} + debugbuf(streambuf * b) + : streambuf(), sb(b) {} protected: /// virtual int sync() { @@ -105,7 +105,7 @@ protected: #endif } /// - virtual std::streamsize xsputn(char const * p, std::streamsize n) { + virtual streamsize xsputn(char const * p, streamsize n) { #ifdef MODERN_STL return sb->sputn(p, n); #else @@ -122,29 +122,29 @@ protected: } private: /// - std::streambuf * sb; + streambuf * sb; }; /// So that public parts of DebugStream does not need to know about filebuf struct DebugStream::debugstream_internal { /// Used when logging to file. - std::filebuf fbuf; + filebuf fbuf; }; /// Constructor, sets the debug level to t. DebugStream::DebugStream(Debug::type t) - : std::ostream(new debugbuf(std::cerr.rdbuf())), + : ostream(new debugbuf(cerr.rdbuf())), dt(t), nullstream(new nullbuf), internal(0) {} /// Constructor, sets the log file to f, and the debug level to t. DebugStream::DebugStream(char const * f, Debug::type t) - : std::ostream(new debugbuf(std::cerr.rdbuf())), + : ostream(new debugbuf(cerr.rdbuf())), dt(t), nullstream(new nullbuf), internal(new debugstream_internal) { - internal->fbuf.open(f, std::ios::out|std::ios::app); - delete rdbuf(new teebuf(std::cerr.rdbuf(), + internal->fbuf.open(f, ios::out|ios::app); + delete rdbuf(new teebuf(cerr.rdbuf(), &internal->fbuf)); } @@ -165,8 +165,8 @@ void DebugStream::logFile(char const * f) } else { internal = new debugstream_internal; } - internal->fbuf.open(f, std::ios::out|std::ios::app); - delete rdbuf(new teebuf(std::cerr.rdbuf(), + internal->fbuf.open(f, ios::out|ios::app); + delete rdbuf(new teebuf(cerr.rdbuf(), &internal->fbuf)); } @@ -250,12 +250,12 @@ int main(int, char **) // support partial specialization. In egcs this should not be // needed. debugstream << "automatic " << &i - << ", free store " << p << std::endl; + << ", free store " << p << endl; delete p; /* for (int j = 0; j < 200000; ++j) { DebugStream tmp; - tmp << "Test" << std::endl; + tmp << "Test" << endl; } */ } diff --git a/src/support/DebugStream.h b/src/support/DebugStream.h index cdf5e0841a..d5be8b609d 100644 --- a/src/support/DebugStream.h +++ b/src/support/DebugStream.h @@ -22,6 +22,16 @@ #include #endif +#ifdef MODERN_STL +using std::ostream; +using std::streambuf; +using std::streamsize; +using std::filebuf; +using std::cerr; +using std::ios; +using std::endl; +#endif + #ifdef TEST_DEBUGSTREAM #include struct Debug { @@ -90,7 +100,7 @@ struct Debug { debug[Debug::type(Debug::INFO | Debug::CRIT)] << "...info/crit...\n"; */ -class DebugStream : public std::ostream { +class DebugStream : public ostream { public: /// Constructor, sets the debug level to t. DebugStream(Debug::type t = Debug::NONE); @@ -136,7 +146,7 @@ public: current debug level otherwise the real debug stream is used. */ - std::ostream & debug(Debug::type t = Debug::ANY) { + ostream & debug(Debug::type t = Debug::ANY) { if (dt & t) return *this; return nullstream; } @@ -145,14 +155,14 @@ public: /** This is an operator to give a more convenient use: dbgstream[Debug::INFO] << "Info!\n"; */ - std::ostream & operator[](Debug::type t) { + ostream & operator[](Debug::type t) { return debug(t); } private: /// The current debug level Debug::type dt; /// The no-op stream. - std::ostream nullstream; + ostream nullstream; struct debugstream_internal; debugstream_internal * internal; }; diff --git a/src/support/filetools.C b/src/support/filetools.C index cb824cb840..ad1f61d745 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -27,6 +27,7 @@ #include "FileInfo.h" #include "pathstack.h" // I know it's OS/2 specific (SMiyata) #include "gettext.h" +#include "LAssert.h" // Which part of this is still necessary? (JMarc). #if HAVE_DIRENT_H -- 2.39.5