]> git.lyx.org Git - lyx.git/blobdiff - src/support/lyxsum.cpp
Revert qprocess code. Revisions reverted: 22026, 22030, 22044, 22048,
[lyx.git] / src / support / lyxsum.cpp
index 165aff3273baaaed2039493dc5003421cfce3afb..781ca7f5591b1d8cfb9f8385f9201a425dee270c 100644 (file)
 #include <config.h>
 
 #include "support/lyxlib.h"
-
-#include "debug.h"
-
+#include "support/debug.h"
 #include "support/FileName.h"
 
 #include <boost/crc.hpp>
 
 #include <algorithm>
+#include <iomanip>
 
-using std::endl;
-using std::string;
-
+using namespace std;
 
 // OK, this is ugly, but it is the only workaround I found to compile
 // with gcc (any version) on a system which uses a non-GNU toolchain.
@@ -37,10 +34,6 @@ template struct boost::detail::crc_table_t<32, 0x04C11DB7, true>;
 // are available. Order is faster to slowest.
 #if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
 
-// Make sure we get modern version of mmap and friends with void*,
-// not `compatibility' version with caddr_t.
-#define _POSIX_C_SOURCE 199506L
-
 #ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
@@ -58,12 +51,11 @@ template struct boost::detail::crc_table_t<32, 0x04C11DB7, true>;
 namespace lyx {
 namespace support {
 
-unsigned long sum(FileName const & file)
+unsigned long sum(char const * file)
 {
-       LYXERR(Debug::FILES) << "lyx::sum() using mmap (lightning fast)"
-                            << endl;
+       //LYXERR(Debug::FILES, "lyx::sum() using mmap (lightning fast)");
 
-       int fd = open(file.toFilesystemEncoding().c_str(), O_RDONLY);
+       int fd = open(file, O_RDONLY);
        if (!fd)
                return 0;
 
@@ -99,7 +91,6 @@ unsigned long sum(FileName const & file)
 #include <fstream>
 #include <iterator>
 
-
 namespace {
 
 template<typename InputIterator>
@@ -117,44 +108,26 @@ unsigned long do_crc(InputIterator first, InputIterator last)
 namespace lyx {
 namespace support {
 
-using std::ifstream;
-#if HAVE_DECL_ISTREAMBUF_ITERATOR
-using std::istreambuf_iterator;
 
-unsigned long sum(FileName const & file)
+unsigned long sum(char const * file)
 {
-       LYXERR(Debug::FILES) << "lyx::sum() using istreambuf_iterator (fast)"
-                            << endl;
-
-       ifstream ifs(file.toFilesystemEncoding().c_str());
-       if (!ifs) return 0;
+       ifstream ifs(file, ios_base::in | ios_base::binary);
+       if (!ifs)
+               return 0;
 
+#if HAVE_DECL_ISTREAMBUF_ITERATOR
+       //LYXERR(Debug::FILES, "lyx::sum() using istreambuf_iterator (fast)");
        istreambuf_iterator<char> beg(ifs);
        istreambuf_iterator<char> end;
-
-       return do_crc(beg,end);
-}
 #else
-
-using std::istream_iterator;
-using std::ios;
-
-unsigned long sum(FileName const & file)
-{
-       LYXERR(Debug::FILES)
-               << "lyx::sum() using istream_iterator (slow as a snail)"
-               << endl;
-
-       ifstream ifs(file.toFilesystemEncoding().c_str());
-       if (!ifs) return 0;
-
+       //LYXERR(Debug::FILES, "lyx::sum() using istream_iterator (slow as a snail)");
        ifs.unsetf(ios::skipws);
        istream_iterator<char> beg(ifs);
        istream_iterator<char> end;
+#endif
 
        return do_crc(beg,end);
 }
-#endif
 
 } // namespace support
 } // namespace lyx