]> git.lyx.org Git - features.git/commitdiff
disable some tests for standard C++ features; add a line counting stream for lates...
authorAndré Pönitz <poenitz@gmx.net>
Sun, 12 Aug 2007 08:57:17 +0000 (08:57 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sun, 12 Aug 2007 08:57:17 +0000 (08:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19446 a592a061-630c-0410-9148-cb99ea01b6c8

configure.ac
src/Buffer.cpp
src/BufferParams.cpp
src/insets/ExternalSupport.cpp
src/insets/InsetGraphics.cpp
src/insets/InsetNote.cpp
src/mathed/MathStream.cpp
src/support/LaTeXStream.cpp [new file with mode: 0644]
src/support/Makefile.am
src/support/lyxalgo.h

index f3baf00882805e4ce243d7abf9aefe3ee8198dc1..b0156035f12adca69cf9a742b4e3981f2c779e54 100644 (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)
index 34727d28bf26ba04491fb58d1f8207b8325b2bae..cd56bce44db350d7cbb497e6f25f971c996d5bd4 100644 (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) {
index fc082c178b70a70c126105a14b1e0134e9225ad8..57932680f5bdb2e33fc016e6f287df4f9d463aef 100644 (file)
 #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();
        }
index e214c3e4f253b128acffb7e14a3c8ca1cf157829..2210a1bc721a8b078bd2688939e6bfe732a70b7d 100644 (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 {
index cfb0e326bb381fe8ada9d911745b8a08a56c9f5f..1203d27188d0403ead0365ea58b68ae39c4416e7 100644 (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'));
 }
 
 
index d698f692189348a5ee17ab92f645f6514a392317..1406d0c6873d26340279730d7e140fd0fb230d00 100644 (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'));
 }
 
 
index c1365739571e54ecfc788d8f77f4230045bdeae8..31f69518de7d4a65e67ccc9b73f830e5d506d8f5 100644 (file)
 #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;
 }
 
diff --git a/src/support/LaTeXStream.cpp b/src/support/LaTeXStream.cpp
new file mode 100644 (file)
index 0000000..b3d9f50
--- /dev/null
@@ -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
+
+}
index 2e6fc5aa0bc376ba5b700f3ca4c5c44706e5eea4..d9c74427c4ed723e00659b396954620fb8100e1c 100644 (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 \
index 19c2485a34241b9cf5ee51c69d92360b2a0e24d7..b3a08241b42523727a9cd5777544b8d49f9cb24c 100644 (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)