mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
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
This commit is contained in:
parent
3635ff7370
commit
2ac6d6da48
18
ChangeLog
18
ChangeLog
@ -1,3 +1,21 @@
|
||||
1999-10-13 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* 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 <alstrup@alstrup.galaxy.dk>
|
||||
|
||||
* src/sys*: Cleaned up the Systemcall stuff a bit. Added "kill(int)"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 = \
|
||||
|
@ -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
|
||||
|
@ -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 \
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include "LString.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "array.h"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -22,6 +22,16 @@
|
||||
#include <iostream>
|
||||
#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 <string>
|
||||
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;
|
||||
};
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user