From 1b9673deb1dec7516ca8952c041af84153c6e4a3 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Tue, 1 Sep 2015 15:03:21 +0200 Subject: [PATCH] More small windows int types fixes. --- src/internfile/mh_text.cpp | 7 ++++++- src/internfile/mh_text.h | 17 ++++++++--------- src/unac/unac.c | 14 ++++++++------ src/utils/idfile.cpp | 4 +++- src/utils/pathut.cpp | 2 +- src/windows/Win32ProjectRecoll.vcxproj | 2 +- src/windows/recollindex/recollindex.vcxproj | 2 +- src/windows/recollq/recollq.vcxproj | 2 +- 8 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/internfile/mh_text.cpp b/src/internfile/mh_text.cpp index ec629947..a72b14e8 100644 --- a/src/internfile/mh_text.cpp +++ b/src/internfile/mh_text.cpp @@ -43,10 +43,15 @@ const int KB = 1024; // Process a plain text file bool MimeHandlerText::set_document_file(const string& mt, const string &fn) { - LOGDEB(("MimeHandlerText::set_document_file: [%s]\n", fn.c_str())); + LOGDEB(("MimeHandlerText::set_document_file: [%s] offs %lld\n", + fn.c_str(), m_offs)); RecollFilter::set_document_file(mt, fn); + m_fn = fn; + // This should not be necessary, but it happens on msw that offset is large + // negative at this point, could not find the reason (still trying). + m_offs = 0; // file size for oversize check long long fsize = path_filesize(m_fn); diff --git a/src/internfile/mh_text.h b/src/internfile/mh_text.h index 1861ee76..9e4dfe12 100644 --- a/src/internfile/mh_text.h +++ b/src/internfile/mh_text.h @@ -19,7 +19,6 @@ #include #include -using std::string; #include "mimehandler.h" @@ -30,22 +29,22 @@ using std::string; */ class MimeHandlerText : public RecollFilter { public: - MimeHandlerText(RclConfig *cnf, const string& id) - : RecollFilter(cnf, id), m_paging(false), m_offs(0) + MimeHandlerText(RclConfig *cnf, const std::string& id) + : RecollFilter(cnf, id), m_paging(false), m_offs(0), m_pagesz(0) { } virtual ~MimeHandlerText() { } - virtual bool set_document_file(const string& mt, const string &file_path); - virtual bool set_document_string(const string&, const string&); + virtual bool set_document_file(const std::string& mt, const std::string &file_path); + virtual bool set_document_string(const std::string&, const std::string&); virtual bool is_data_input_ok(DataInput input) const { if (input == DOCUMENT_FILE_NAME || input == DOCUMENT_STRING) return true; return false; } virtual bool next_document(); - virtual bool skip_to_document(const string& s); + virtual bool skip_to_document(const std::string& s); virtual void clear() { m_paging = false; @@ -56,11 +55,11 @@ class MimeHandlerText : public RecollFilter { } private: bool m_paging; - string m_text; - string m_fn; + std::string m_text; + std::string m_fn; off_t m_offs; // Offset of next read in file if we're paging size_t m_pagesz; - string m_charsetfromxattr; + std::string m_charsetfromxattr; bool readnext(); }; diff --git a/src/unac/unac.c b/src/unac/unac.c index 8e90e1e6..358c88f3 100644 --- a/src/unac/unac.c +++ b/src/unac/unac.c @@ -29,6 +29,7 @@ #include #include #include +#include #include UNORDERED_MAP_INCLUDE using std::string; @@ -14169,7 +14170,7 @@ int unacmaybefold_string_utf16(const char* in, size_t in_length, char** outp, size_t* out_lengthp, int what) { char* out; - int out_size; + size_t out_size; int out_length; unsigned int i; @@ -14189,7 +14190,7 @@ int unacmaybefold_string_utf16(const char* in, size_t in_length, for(i = 0; i < in_length; i += 2) { unsigned short c; unsigned short* p; - int l; + size_t l; int k; c = (in[i] << 8) | (in[i + 1] & 0xff); /* @@ -14435,10 +14436,11 @@ static int convert(const char* from, const char* to, const char* tmp = space; size_t tmp_length = 2; if(iconv(cd, (ICONV_CONST char **) &tmp, &tmp_length, &out, &out_remain) == (size_t)-1) { - if(errno == E2BIG) + if(errno == E2BIG) { /* fall thru to the E2BIG case below */; - else - goto out; + } else { + goto out; + } } else { /* The offending character was replaced by a SPACE, skip it. */ in += 2; @@ -14454,7 +14456,7 @@ static int convert(const char* from, const char* to, /* * The output does not fit in the current out buffer, enlarge it. */ - int length = out - out_base; + size_t length = out - out_base; out_size *= 2; { char *saved = out_base; diff --git a/src/utils/idfile.cpp b/src/utils/idfile.cpp index a6ab359e..4c13683b 100644 --- a/src/utils/idfile.cpp +++ b/src/utils/idfile.cpp @@ -125,7 +125,9 @@ static string idFileInternal(istream& input, const char *fn) // Except for a possible first line with 'From ', lines must // begin with whitespace or have a colon // (hope no one comes up with a longer header name ! - if (!isspace(cline[0])) { + // Take care to convert to unsigned char because ms ctype does + // like negative values + if (!isspace((unsigned char)cline[0])) { char *cp = strchr(cline, ':'); if (cp == 0 || (cp - cline) > 70) { LOGDEB2(("idfile: can't be mail header line: [%s]\n", cline)); diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index 93b7eeff..2f54fa71 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -520,7 +520,7 @@ bool path_isroot(const string& path) if (path.size() == 1 && path[0] == '/') return true; #ifdef _WIN32 - if (path.size == 3 && isalpha(path[0]) && path[1] == ':' && path[2] == '/') + if (path.size() == 3 && isalpha(path[0]) && path[1] == ':' && path[2] == '/') return true; #endif return false; diff --git a/src/windows/Win32ProjectRecoll.vcxproj b/src/windows/Win32ProjectRecoll.vcxproj index 1384f8bb..5bdffe40 100644 --- a/src/windows/Win32ProjectRecoll.vcxproj +++ b/src/windows/Win32ProjectRecoll.vcxproj @@ -92,7 +92,7 @@ Disabled BUILDING_RECOLL;__WIN32__;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) false - C:\Iconv\include;C:\xapian\xapian-core-1.2.8\include;C:\Users\Bill\recoll\src\internfile;C:\Users\Bill\recoll\src\rcldb;C:\Users\Bill\recoll\src\index;C:\Users\Bill\recoll\src\bincimapmime;C:\Users\Bill\recoll\src\unac;C:\Users\Bill\recoll\src\windows;C:\zlib\include;C:\pthreads-w32\Pre-built.2\include;C:\Users\Bill\recoll\src\xaposix;C:\Users\Bill\recoll\src\common;C:\Users\Bill\recoll\src\utils;%(AdditionalIncludeDirectories) + C:\Iconv64\include;C:\xapian\xapian-core-1.2.8\include;C:\Users\Bill\recoll\src\internfile;C:\Users\Bill\recoll\src\rcldb;C:\Users\Bill\recoll\src\index;C:\Users\Bill\recoll\src\bincimapmime;C:\Users\Bill\recoll\src\unac;C:\Users\Bill\recoll\src\windows;C:\zlib\include;C:\pthreads-w32\Pre-built.2\include;C:\Users\Bill\recoll\src\xaposix;C:\Users\Bill\recoll\src\common;C:\Users\Bill\recoll\src\utils;%(AdditionalIncludeDirectories) 4800;4996 diff --git a/src/windows/recollindex/recollindex.vcxproj b/src/windows/recollindex/recollindex.vcxproj index 0068ba99..40f32fa7 100644 --- a/src/windows/recollindex/recollindex.vcxproj +++ b/src/windows/recollindex/recollindex.vcxproj @@ -110,7 +110,7 @@ Console true C:\xapian\xapian-core-1.2.8\win32\x64\Debug;C:\Users\Bill\recoll\src\windows\x64\Debug;C:\pthreads-w32\Pre-built.2\lib\x64;%(AdditionalLibraryDirectories) - Win32ProjectRecoll.lib;C:\zlib64\zlib-win64\x64\Debug\zlib.lib;xapian-core.lib;C:\iconv64\Debug_x64\libiconvD.lib;Ws2_32.lib;Rpcrt4.lib;pthreadVC2.lib;%(AdditionalDependencies) + Win32ProjectRecoll.lib;C:\zlib64\zlib-win64\x64\Debug\zlib.lib;xapian-core.lib;C:\iconv64\libiconv\x64\Debug\libiconv.lib;Ws2_32.lib;Rpcrt4.lib;pthreadVC2.lib;%(AdditionalDependencies) diff --git a/src/windows/recollq/recollq.vcxproj b/src/windows/recollq/recollq.vcxproj index 68ec3cf2..e07007bf 100644 --- a/src/windows/recollq/recollq.vcxproj +++ b/src/windows/recollq/recollq.vcxproj @@ -108,7 +108,7 @@ Console true C:\xapian\xapian-core-1.2.8\win32\x64\Debug;C:\Users\Bill\recoll\src\windows\x64\Debug;C:\pthreads-w32\Pre-built.2\lib\x64;%(AdditionalLibraryDirectories) - Win32ProjectRecoll.lib;C:\zlib64\zlib-win64\x64\Debug\zlib.lib;xapian-core.lib;C:\iconv64\Debug_x64\libiconvD.lib;Ws2_32.lib;Rpcrt4.lib;pthreadVC2.lib;%(AdditionalDependencies) + Win32ProjectRecoll.lib;C:\zlib64\zlib-win64\x64\Debug\zlib.lib;xapian-core.lib;C:\iconv64\libiconv\x64\Debug\libiconv.lib;Ws2_32.lib;Rpcrt4.lib;pthreadVC2.lib;%(AdditionalDependencies)