diff --git a/src/internfile/mh_mbox.cpp b/src/internfile/mh_mbox.cpp index f626b31f..32a72452 100644 --- a/src/internfile/mh_mbox.cpp +++ b/src/internfile/mh_mbox.cpp @@ -23,7 +23,7 @@ #include "safesysstat.h" #include -#if 1 || defined(_WIN32) +#if defined(_WIN32) #define USING_STD_REGEX #endif diff --git a/src/utils/circache.cpp b/src/utils/circache.cpp index eb33ce9b..e3dc8fe0 100644 --- a/src/utils/circache.cpp +++ b/src/utils/circache.cpp @@ -33,6 +33,7 @@ #ifndef _WIN32 #include +#define O_BINARY 0 #else struct iovec { void *iov_base; @@ -722,7 +723,7 @@ bool CirCache::create(off_t maxsize, int flags) } if ((m_d->m_fd = ::open(m_d->datafn(m_dir).c_str(), - O_CREAT | O_RDWR | O_TRUNC, 0666)) < 0) { + O_CREAT|O_RDWR|O_TRUNC|O_BINARY, 0666)) < 0) { m_d->m_reason << "CirCache::create: open/creat(" << m_d->datafn(m_dir) << ") failed " << "errno " << errno; return false; @@ -754,7 +755,8 @@ bool CirCache::open(OpMode mode) ::close(m_d->m_fd); if ((m_d->m_fd = ::open(m_d->datafn(m_dir).c_str(), - mode == CC_OPREAD ? O_RDONLY : O_RDWR)) < 0) { + mode == CC_OPREAD ? + O_RDONLY|O_BINARY : O_RDWR|O_BINARY)) < 0) { m_d->m_reason << "CirCache::open: open(" << m_d->datafn(m_dir) << ") failed " << "errno " << errno; return false; diff --git a/src/utils/readfile.cpp b/src/utils/readfile.cpp index 4858a53d..a6b16f96 100644 --- a/src/utils/readfile.cpp +++ b/src/utils/readfile.cpp @@ -22,7 +22,9 @@ #include #include "safesysstat.h" #include "safeunistd.h" - +#ifndef _WIN32 +#define O_BINARY 0 +#endif #include #include "readfile.h" @@ -92,7 +94,7 @@ bool file_scan(const string &fn, FileScanDo* doer, off_t startoffs, // If we have a file name, open it, else use stdin. if (!fn.empty()) { - fd = open(fn.c_str(), O_RDONLY); + fd = open(fn.c_str(), O_RDONLY|O_BINARY); if (fd < 0 || fstat(fd, &st) < 0) { catstrerror(reason, "open/stat", errno); return false;