disable some tests for standard C++ features; add a line counting stream for lates output

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19446 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-08-12 08:57:17 +00:00
parent a4e8658088
commit 2caa98bee0
10 changed files with 120 additions and 32 deletions

View File

@ -77,13 +77,13 @@ AC_LANG(C++)
dnl we do not need that currently (and probably all our supported
dnl compiler allow that)
dnl LYX_CXX_PARTIAL
LYX_CXX_EXPLICIT
dnl LYX_CXX_EXPLICIT
LYX_CXX_GLOBAL_CSTD
LYX_STD_COUNT
dnl LYX_STD_COUNT
dnl we disable rtti for now
dnl LYX_CXX_RTTI
AC_CHECK_HEADERS(ostream istream sstream locale limits ios)
LYX_CXX_STL_MODERN_STREAMS
dnl AC_CHECK_HEADERS(ostream istream sstream locale limits ios)
dnl LYX_CXX_STL_MODERN_STREAMS
### and now some special lyx flags.
AC_ARG_ENABLE(assertions,
@ -100,7 +100,7 @@ if test "x$enable_assertions" = xyes ; then
fi
### Library Files
AC_CHECK_LIB(m, sin)
dnl AC_CHECK_LIB(m, sin)
### Add extra directories to check for libraries.
LYX_WITH_DIR([extra-lib],[extra library directory],extra_lib, NONE)

View File

@ -79,6 +79,7 @@
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/operations.hpp>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <sstream>
@ -1758,7 +1759,7 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to,
} else
getLabelList(labels);
if (lyx::count(labels.begin(), labels.end(), from) > 1)
if (std::count(labels.begin(), labels.end(), from) > 1)
return;
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {

View File

@ -39,14 +39,15 @@
#include "frontends/alert.h"
#include "insets/InsetListingsParams.h"
#include "support/lyxalgo.h" // for lyx::count
#include "support/convert.h"
#include "support/Translator.h"
#include <boost/array.hpp>
#include <algorithm>
#include <sstream>
using std::count;
using std::endl;
using std::string;
using std::istringstream;
@ -1159,7 +1160,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
lyxpreamble += "\\makeatother\n\n";
int const nlines =
int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
int(count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
for (int j = 0; j != nlines; ++j) {
texrow.newline();
}

View File

@ -37,6 +37,8 @@
#include <boost/filesystem/operations.hpp>
#include <algorithm>
using std::endl;
using std::string;
using std::vector;
@ -387,7 +389,7 @@ int writeExternal(InsetExternalParams const & params,
str = substituteOptions(params, str, format);
// FIXME UNICODE
os << from_utf8(str);
return int(lyx::count(str.begin(), str.end(),'\n'));
return int(std::count(str.begin(), str.end(),'\n'));
}
namespace {

View File

@ -76,7 +76,6 @@ TODO
#include "support/convert.h"
#include "support/filetools.h"
#include "support/lyxalgo.h" // count
#include "support/lyxlib.h" // sum
#include "support/lstrings.h"
#include "support/os.h"
@ -85,6 +84,7 @@ TODO
#include <boost/bind.hpp>
#include <boost/tuple/tuple.hpp>
#include <algorithm>
#include <sstream>
@ -823,7 +823,7 @@ int InsetGraphics::latex(Buffer const & buf, odocstream & os,
LYXERR(Debug::GRAPHICS) << "InsetGraphics::latex outputting:\n"
<< latex_str << endl;
// Return how many newlines we issued.
return int(lyx::count(latex_str.begin(), latex_str.end(),'\n'));
return int(std::count(latex_str.begin(), latex_str.end(),'\n'));
}

View File

@ -28,9 +28,9 @@
#include "MetricsInfo.h"
#include "OutputParams.h"
#include "support/lyxalgo.h"
#include "support/Translator.h"
#include <algorithm>
#include <sstream>
@ -323,7 +323,7 @@ int InsetNote::latex(Buffer const & buf, odocstream & os,
os << str;
runparams_in.encoding = runparams.encoding;
// Return how many newlines we issued.
return int(lyx::count(str.begin(), str.end(), '\n'));
return int(std::count(str.begin(), str.end(), '\n'));
}

View File

@ -15,17 +15,15 @@
#include "MathExtern.h"
#include "MathStream.h"
#include "support/lyxalgo.h"
#include "support/textutils.h"
#include <algorithm>
namespace lyx {
using std::strlen;
//////////////////////////////////////////////////////////////////////
@ -154,7 +152,7 @@ WriteStream & operator<<(WriteStream & ws, char const * s)
ws.pendingSpace(false);
}
ws.os() << s;
ws.addlines(int(count(s, s + strlen(s), '\n')));
ws.addlines(int(std::count(s, s + strlen(s), '\n')));
return ws;
}

View File

@ -0,0 +1,99 @@
#include "LaTeXStream.h"
#include <iostream>
#include <streambuf>
namespace lyx {
////////////////////////////////////////////////////////////////
//
// LaTeXStreamBuffer
//
////////////////////////////////////////////////////////////////
class LaTeXStreamBuffer : public std::streambuf
{
public:
explicit LaTeXStreamBuffer(std::streambuf * sbuf);
int line() const { return line_; }
protected:
int overflow(int);
int sync();
private:
std::streambuf * sbuf_;
int line_;
};
LaTeXStreamBuffer::LaTeXStreamBuffer(std::streambuf *sb)
: sbuf_(sb), line_(0)
{
setp(0, 0);
setg(0, 0, 0);
}
int LaTeXStreamBuffer::overflow(int c)
{
if (c == '\n')
++line_;
return c;
}
int LaTeXStreamBuffer::sync()
{
sbuf_->pubsync();
return 0;
}
////////////////////////////////////////////////////////////////
//
// LaTeXStream
//
////////////////////////////////////////////////////////////////
LaTeXStream::LaTeXStream(std::streambuf * sbuf)
: std::ostream(sbuf_ = new LaTeXStreamBuffer(sbuf))
{}
LaTeXStream::~LaTeXStream()
{
delete sbuf_;
}
int LaTeXStream::line() const
{
return sbuf_->line();
}
////////////////////////////////////////////////////////////////
//
// Test
//
////////////////////////////////////////////////////////////////
#if 0
int main(int argc, char *argv[])
{
LaTeXStream out(std::cout.rdbuf());
char c;
while (std::cin) {
if (std::cin.get(c))
out.put(c);
}
std::cout << "line count: " << out.line() << std::endl;
return 0;
}
#endif
}

View File

@ -52,6 +52,8 @@ liblyxsupport_la_SOURCES = \
gzstream.cpp \
gzstream.h \
kill.cpp \
LaTeXStream.cpp \
LaTeXStream.h \
limited_stack.h \
lstrings.cpp \
lstrings.h \

View File

@ -73,21 +73,6 @@ OutputIter copy_if(InputIter first, InputIter last,
}
/// A slot in replacement for std::count for systems where it is broken.
template <class Iterator, class T>
typename std::iterator_traits<Iterator>::difference_type
count (Iterator first, Iterator last, T const & value)
{
#ifdef HAVE_STD_COUNT
return std::count(first, last, value);
#else
typename std::iterator_traits<Iterator>::difference_type n = 0;
while (first != last)
if (*first++ == value) ++n;
return n;
#endif
}
/// Remove all duplicate entries in c.
template<class C>
void eliminate_duplicates(C & c)