diff --git a/src/common/conf_post.h b/src/common/conf_post.h index b018ae56..6c552d63 100644 --- a/src/common/conf_post.h +++ b/src/common/conf_post.h @@ -41,20 +41,22 @@ typedef int mode_t; #define ftruncate _chsize_s #define PATH_MAX MAX_PATH #define RCL_ICONV_INBUF_CONST 1 -#else -// Gminw -#undef RCL_ICONV_INBUF_CONST -#endif +#define HAVE_STRUCT_TIMESPEC +#define strdup _strdup +#define timegm _mkgmtime +#else // End _MSC_VER -> Gminw + +#define timegm portable_timegm + +#undef RCL_ICONV_INBUF_CONST + +#endif // GMinw only typedef int pid_t; inline int readlink(const char *cp, void *buf, int cnt) { return -1; } -#define HAVE_STRUCT_TIMESPEC -#define strdup _strdup -#define timegm _mkgmtime - #define MAXPATHLEN PATH_MAX typedef DWORD32 u_int32_t; @@ -67,11 +69,12 @@ typedef int ssize_t; #define R_OK 4 #define W_OK 2 +#ifndef X_OK #define X_OK 4 +#endif #define RECOLL_DATADIR "C:\\recoll\\" #define S_ISLNK(X) false #define lstat stat -#define timegm _mkgmtime #endif diff --git a/src/index/fsfetcher.cpp b/src/index/fsfetcher.cpp index a62c330b..5441f990 100644 --- a/src/index/fsfetcher.cpp +++ b/src/index/fsfetcher.cpp @@ -33,12 +33,12 @@ static bool urltopath(RclConfig* cnf, const Rcl::Doc& idoc, string& fn, struct stat& st) { // The url has to be like file:// - if (idoc.url.find(cstr_fileu) != 0) { + fn = fileurltolocalpath(idoc.url); + if (fn.empty()) { LOGERR(("FSDocFetcher::fetch/sig: non fs url: [%s]\n", idoc.url.c_str())); return false; } - fn = idoc.url.substr(7, string::npos); cnf->setKeyDir(path_getfather(fn)); bool follow = false; cnf->getConfParam("followLinks", &follow); diff --git a/src/librecoll/librecoll.pro b/src/librecoll/librecoll.pro new file mode 100644 index 00000000..5423b607 --- /dev/null +++ b/src/librecoll/librecoll.pro @@ -0,0 +1,128 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-10-03T09:04:49 +# +#------------------------------------------------- + +QT -= core gui + +TARGET = librecoll +TEMPLATE = lib + +DEFINES += LIBRECOLL_LIBRARY BUILDING_RECOLL +DEFINES -= UNICODE +DEFINES -= _UNICODE +DEFINES += _MBCS + +SOURCES += \ +../aspell/rclaspell.cpp \ +../bincimapmime/convert.cc \ +../bincimapmime/mime-parsefull.cc \ +../bincimapmime/mime-parseonlyheader.cc \ +../bincimapmime/mime-printbody.cc \ +../bincimapmime/mime.cc \ +../common/beaglequeuecache.cpp \ +../common/cstr.cpp \ +../common/rclconfig.cpp \ +../common/rclinit.cpp \ +../common/syngroups.cpp \ +../common/textsplit.cpp \ +../common/unacpp.cpp \ +../index/beaglequeue.cpp \ +../index/bglfetcher.cpp \ +../index/checkretryfailed.cpp \ +../index/fetcher.cpp \ +../index/fsfetcher.cpp \ +../index/fsindexer.cpp \ +../index/indexer.cpp \ +../index/mimetype.cpp \ +../index/subtreelist.cpp \ +../internfile/extrameta.cpp \ +../internfile/htmlparse.cpp \ +../internfile/internfile.cpp \ +../internfile/mh_exec.cpp \ +../internfile/mh_execm.cpp \ +../internfile/mh_html.cpp \ +../internfile/mh_mail.cpp \ +../internfile/mh_mbox.cpp \ +../internfile/mh_text.cpp \ +../internfile/mimehandler.cpp \ +../internfile/myhtmlparse.cpp \ +../internfile/txtdcode.cpp \ +../internfile/uncomp.cpp \ +../query/docseq.cpp \ +../query/docseqdb.cpp \ +../query/docseqhist.cpp \ +../query/dynconf.cpp \ +../query/filtseq.cpp \ +../query/plaintorich.cpp \ +../query/recollq.cpp \ +../query/reslistpager.cpp \ +../query/sortseq.cpp \ +../query/wasaparse.cpp \ +../query/wasaparseaux.cpp \ +../rcldb/daterange.cpp \ +../rcldb/expansiondbs.cpp \ +../rcldb/rclabstract.cpp \ +../rcldb/rcldb.cpp \ +../rcldb/rcldoc.cpp \ +../rcldb/rcldups.cpp \ +../rcldb/rclquery.cpp \ +../rcldb/rclterms.cpp \ +../rcldb/searchdata.cpp \ +../rcldb/searchdatatox.cpp \ +../rcldb/searchdataxml.cpp \ +../rcldb/stemdb.cpp \ +../rcldb/stoplist.cpp \ +../rcldb/synfamily.cpp \ +../unac/unac.cpp \ +../utils/appformime.cpp \ +../utils/base64.cpp \ +../utils/circache.cpp \ +../utils/conftree.cpp \ +../utils/copyfile.cpp \ +../utils/cpuconf.cpp \ +../utils/debuglog.cpp \ +../utils/ecrontab.cpp \ +../windows/execmd_w.cpp \ +../windows/fnmatch.c \ +../utils/fileudi.cpp \ +../utils/fstreewalk.cpp \ +../utils/idfile.cpp \ +../utils/md5.cpp \ +../utils/md5ut.cpp \ +../utils/mimeparse.cpp \ +../utils/pathut.cpp \ +../utils/pxattr.cpp \ +../utils/rclionice.cpp \ +../utils/readfile.cpp \ +../utils/smallut.cpp \ +../utils/strmatcher.cpp \ +../utils/transcode.cpp \ +../utils/wipedir.cpp \ +../windows/strptime.cpp \ +../windows/dirent.c + +HEADERS += + +INCLUDEPATH += ../common ../index ../internfile ../query ../unac \ + ../utils ../aspell ../rcldb ../qtgui ../xaposix \ + ../confgui ../bincimapmime ../windows \ + c:/recolldeps/xapian/xapian-core-1.2.8/include + +windows{ + contains(QMAKE_CC, gcc){ + # MingW + QMAKE_CXXFLAGS += -std=c++11 -Wno-unused-parameter + } + contains(QMAKE_CC, cl){ + # Visual Studio + } + LIBS += c:/recolldeps/xapian/xapian-core-1.2.21/.libs/libxapian-22.dll \ + c:/recolldeps/zlib-1.2.8/zlib1.dll -liconv -lshlwapi -lkernel32 +} + +unix { + target.path = /usr/lib + INSTALLS += target +} diff --git a/src/qtgui/recoll.pro b/src/qtgui/recoll.pro index e032895f..07c72466 100644 --- a/src/qtgui/recoll.pro +++ b/src/qtgui/recoll.pro @@ -12,7 +12,7 @@ QT += webkit QT += xml greaterThan(QT_MAJOR_VERSION, 4): QT += widgets webkitwidgets printsupport -CONFIG += qt warn_on thread release +CONFIG += qt warn_on thread debug HEADERS += \ advsearch_w.h \ @@ -100,11 +100,12 @@ INCLUDEPATH += ../common ../index ../internfile ../query ../unac \ windows{ contains(QMAKE_CC, gcc){ # MingW - QMAKE_CXXFLAGS += -std=c++0x -Wno-unused-parameter + QMAKE_CXXFLAGS += -std=c++11 -Wno-unused-parameter } contains(QMAKE_CC, cl){ # Visual Studio } + LIBS += C:/recoll/src/build-librecoll-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/librecoll.dll } diff --git a/src/query/reslistpager.cpp b/src/query/reslistpager.cpp index 577af8f0..fdcfad14 100644 --- a/src/query/reslistpager.cpp +++ b/src/query/reslistpager.cpp @@ -151,18 +151,10 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc, const HighlightData& hdata, const string& sh) { ostringstream chunk; - int percent; - if (doc.pc == -1) { - percent = 0; - // Document not available, maybe other further, will go on. - doc.meta[Rcl::Doc::keyabs] = string(trans("Unavailable document")); - } else { - percent = doc.pc; - } // Determine icon to display if any string iconurl = iconUrl(config, doc); - + // Printable url: either utf-8 if transcoding succeeds, or url-encoded string url; printableUrl(config->getDefCharset(), doc.url, url); @@ -493,7 +485,7 @@ string ResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc) string apptag; doc.getmeta(Rcl::Doc::keyapptg, &apptag); - return cstr_fileu + config->getMimeIconPath(doc.mimetype, apptag); + return path_pathtofileurl(config->getMimeIconPath(doc.mimetype, apptag)); } bool ResListPager::append(const string& data) diff --git a/src/utils/smallut.cpp b/src/utils/smallut.cpp index ed729256..9314d543 100644 --- a/src/utils/smallut.cpp +++ b/src/utils/smallut.cpp @@ -995,12 +995,47 @@ static bool parseperiod(vector::const_iterator& it, return true; } +#ifdef _WIN32 +int setenv(const char *name, const char *value, int overwrite) +{ + if(!overwrite) { + const char *cp = getenv(name); + if (cp) + return -1; + } + return _putenv_s(name, value); +} +void unsetenv(const char *name) +{ + _putenv_s(name, ""); +} +#endif + +time_t portable_timegm(struct tm *tm) +{ + time_t ret; + char *tz; + + tz = getenv("TZ"); + setenv("TZ", "", 1); + tzset(); + ret = mktime(tm); + if (tz) + setenv("TZ", tz, 1); + else + unsetenv("TZ"); + tzset(); + return ret; +} + +#if 0 static void cerrdip(const string& s, DateInterval *dip) { cerr << s << dip->y1 << "-" << dip->m1 << "-" << dip->d1 << "/" << dip->y2 << "-" << dip->m2 << "-" << dip->d2 << endl; } +#endif // Compute date + period. Won't work out of the unix era. // or pre-1970 dates. Just convert everything to unixtime and @@ -1015,13 +1050,8 @@ static bool addperiod(DateInterval *dp, DateInterval *pp) tm.tm_year = dp->y1 - 1900 + pp->y1; tm.tm_mon = dp->m1 + pp->m1 -1; tm.tm_mday = dp->d1 + pp->d1; -#ifdef sun time_t tres = mktime(&tm); localtime_r(&tres, &tm); -#else - time_t tres = timegm(&tm); - gmtime_r(&tres, &tm); -#endif dp->y1 = tm.tm_year + 1900; dp->m1 = tm.tm_mon + 1; dp->d1 = tm.tm_mday; diff --git a/src/utils/smallut.h b/src/utils/smallut.h index 95c989f8..de32586f 100644 --- a/src/utils/smallut.h +++ b/src/utils/smallut.h @@ -153,6 +153,11 @@ bool pcSubst(const string& in, string& out, const map& subs); /** Append system error message */ void catstrerror(string *reason, const char *what, int _errno); +/** Portable timegm. MS C has _mkgmtime, but there is a bug in Gminw which + * makes it inaccessible */ +struct tm; +time_t portable_timegm(struct tm *tm); + /** Compute times to help with perf issues */ class Chrono { public: diff --git a/src/windows/strptime.cpp b/src/windows/strptime.cpp index 0021aa99..09cb5ffc 100644 --- a/src/windows/strptime.cpp +++ b/src/windows/strptime.cpp @@ -4,7 +4,6 @@ #include #include -#ifdef _MSC_VER const char * strp_weekdays[] = { "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" }; const char * strp_monthnames[] = @@ -252,4 +251,3 @@ char * strptime(const char *s, const char *format, struct tm *tm) } return (working ? (char *)s : 0); } -#endif // _MSC_VER diff --git a/src/xaposix/safeunistd.h b/src/xaposix/safeunistd.h index 0045c417..ee5971ff 100644 --- a/src/xaposix/safeunistd.h +++ b/src/xaposix/safeunistd.h @@ -51,7 +51,8 @@ #endif #ifdef __WIN32__ - +#ifdef _MSC_VER +/* Recent MinGW versions define this */ inline unsigned int sleep(unsigned int seconds) { @@ -72,7 +73,7 @@ sleep(unsigned int seconds) xapian_sleep_milliseconds(seconds * 1000u); return 0; } - -#endif +#endif /* _MSC_VER*/ +#endif /* __WIN32__ */ #endif /* XAPIAN_INCLUDED_SAFEUNISTD_H */