From 631532f100ce77009c363dc2e9fbd1edd9ba927a Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Mon, 11 May 2020 07:02:46 +0100 Subject: [PATCH] Recoll windows build: adjust to pathut wchar-utf8 changes --- src/utils/pathut.cpp | 20 +++++++++----- src/utils/transcode.cpp | 53 ------------------------------------ src/utils/transcode.h | 10 ++----- src/windows/recoll-setup.iss | 2 +- 4 files changed, 16 insertions(+), 69 deletions(-) diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index b7d0da59..1200eb0e 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -47,6 +47,13 @@ #include "pathut.h" +#include "smallut.h" +#ifdef MDU_INCLUDE_LOG +#include MDU_INCLUDE_LOG +#else +#include "log.h" +#endif + #include #include #include @@ -118,6 +125,12 @@ #define ftruncate _chsize_s +#ifdef _MSC_VER +// For getpid +#include +#define getpid _getpid +#endif + #else /* !_WIN32 -> */ #include @@ -144,13 +157,6 @@ #endif /* !_WIN32 */ -#include "smallut.h" -#ifdef MDU_INCLUDE_LOG -#include MDU_INCLUDE_LOG -#else -#include "log.h" -#endif - using namespace std; #ifdef _WIN32 diff --git a/src/utils/transcode.cpp b/src/utils/transcode.cpp index 804ede3d..b6791a5e 100644 --- a/src/utils/transcode.cpp +++ b/src/utils/transcode.cpp @@ -23,7 +23,6 @@ #include #include -#include #include "transcode.h" #include "log.h" @@ -153,55 +152,3 @@ error: return ret; } -bool wchartoutf8(const wchar_t *in, std::string& out) -{ - static iconv_t ic = (iconv_t)-1; - if (ic == (iconv_t)-1) { - if((ic = iconv_open("UTF-8", "WCHAR_T")) == (iconv_t)-1) { - LOGERR("wchartoutf8: iconv_open failed\n"); - return false; - } - } - const int OBSIZ = 8192; - char obuf[OBSIZ], *op; - out.erase(); - size_t isiz = 2 * wcslen(in); - out.reserve(isiz); - const char *ip = (const char *)in; - - while (isiz > 0) { - size_t osiz; - op = obuf; - osiz = OBSIZ; - - if(iconv(ic, (ICONV_CONST char **)&ip, &isiz, &op, &osiz) == (size_t)-1 - && errno != E2BIG) { - LOGERR("wchartoutf8: iconv error, errno: " << errno << endl); - return false; - } - out.append(obuf, OBSIZ - osiz); - } - return true; -} - -bool utf8towchar(const std::string& in, wchar_t *out, size_t obytescap) -{ - static iconv_t ic = (iconv_t)-1; - if (ic == (iconv_t)-1) { - if((ic = iconv_open("WCHAR_T", "UTF-8")) == (iconv_t)-1) { - LOGERR("utf8towchar: iconv_open failed\n"); - return false; - } - } - size_t isiz = in.size(); - const char *ip = in.c_str(); - size_t osiz = (size_t)obytescap-2; - char *op = (char *)out; - if (iconv(ic, (ICONV_CONST char **)&ip, &isiz, &op, &osiz) == (size_t)-1) { - LOGERR("utf8towchar: iconv error, errno: " << errno << endl); - return false; - } - *op++ = 0; - *op = 0; - return true; -} diff --git a/src/utils/transcode.h b/src/utils/transcode.h index cda1aa77..3da72830 100644 --- a/src/utils/transcode.h +++ b/src/utils/transcode.h @@ -16,10 +16,9 @@ */ #ifndef _TRANSCODE_H_INCLUDED_ #define _TRANSCODE_H_INCLUDED_ -/** - * - */ + #include + /** * c++ized interface to iconv * @@ -36,9 +35,4 @@ extern bool transcode(const std::string &in, std::string &out, const std::string &ocode, int *ecnt = 0); -#ifdef _WIN32 -extern bool wchartoutf8(const wchar_t *in, std::string& out); -extern bool utf8towchar(const std::string& in, wchar_t *out, size_t obytescap); -#endif - #endif /* _TRANSCODE_H_INCLUDED_ */ diff --git a/src/windows/recoll-setup.iss b/src/windows/recoll-setup.iss index 6aa70e34..1f81d800 100644 --- a/src/windows/recoll-setup.iss +++ b/src/windows/recoll-setup.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Recoll" -#define MyAppVersion "1.27.0-20200407-wip" +#define MyAppVersion "1.27.1-20200511-d8edbcbc" #define MyAppPublisher "Recoll.org" #define MyAppURL "http://www.recoll.org" #define MyAppExeName "recoll.exe"