]> git.lyx.org Git - lyx.git/blobdiff - src/support/lyxsum.C
remove !NEW_INSETS cruft
[lyx.git] / src / support / lyxsum.C
index 26028bb1030ed83d8edabeac7f483a8de61e4455..c74cbafe394a0c8d08cbb087124c365691922d0d 100644 (file)
 
 #include <fstream>
 
-#ifdef HAVE_SSTREAM
-#include <sstream>
-using std::ostringstream;
-#else
-#include <strstream>
-#endif
+#include "Lsstream.h"
 
 #include "support/lyxlib.h"
 
 using std::ifstream;
 using std::ios;
 
+namespace {
+
 // DO _NOT_ CHANGE _ANYTHING_ IN THIS TABLE
-static
 unsigned long const crctab[256] =
 {
        0x0,
@@ -91,7 +87,7 @@ unsigned long const crctab[256] =
    Return crc if successful, 0 if an error occurs. */
  
 template<typename InputIterator>
-static inline
+inline
 unsigned long do_crc(InputIterator first, InputIterator last)
 {
        unsigned long crc = 0;
@@ -109,28 +105,20 @@ unsigned long do_crc(InputIterator first, InputIterator last)
        return ~crc & 0xFFFFFFFF;
 }
 
+} // namespace
+
 
 // And this would be the file interface.
-unsigned long lyx::sum(char const * file)
+unsigned long lyx::sum(string const & file)
 {
-       ifstream ifs(file);
+       ifstream ifs(file.c_str());
        if (!ifs) return 0;
        ifs.unsetf(ios::skipws);
-#ifdef HAVE_SSTREAM
        ostringstream ostr;
        ostr << ifs.rdbuf();
        // The .c_str() is here in case we use our lyxstring class
        // instead of standard string. 
        string w = ostr.str().c_str();
        return do_crc(w.begin(), w.end());
-#else
-       ostrstream ostr;
-       ostr << ifs.rdbuf();
-       char * tmp = ostr.str();
-       if (!tmp) return 0; // empty file
-       string w(tmp, ostr.tellp());
-       unsigned long crc = do_crc(w.begin(), w.end());
-       delete tmp;
-       return crc;
-#endif
 }
+