rclutil.cpp (recoll-1.27.11) | : | rclutil.cpp (recoll-1.27.12) | ||
---|---|---|---|---|
skipping to change at line 44 | skipping to change at line 44 | |||
#include <math.h> | #include <math.h> | |||
#include <errno.h> | #include <errno.h> | |||
#include <sys/types.h> | #include <sys/types.h> | |||
#include "safesysstat.h" | #include "safesysstat.h" | |||
#include <mutex> | #include <mutex> | |||
#include <map> | #include <map> | |||
#include <unordered_map> | #include <unordered_map> | |||
#include <list> | #include <list> | |||
#include <vector> | #include <vector> | |||
#include <numeric> | ||||
#include "rclutil.h" | #include "rclutil.h" | |||
#include "pathut.h" | #include "pathut.h" | |||
#include "wipedir.h" | #include "wipedir.h" | |||
#include "transcode.h" | #include "transcode.h" | |||
#include "md5ut.h" | #include "md5ut.h" | |||
#include "log.h" | #include "log.h" | |||
#include "smallut.h" | #include "smallut.h" | |||
#include "rclconfig.h" | #include "rclconfig.h" | |||
skipping to change at line 650 | skipping to change at line 651 | |||
// File does not exist. Path corresponds to the large version at this point, | // File does not exist. Path corresponds to the large version at this point, | |||
// fix it if needed. | // fix it if needed. | |||
if (size <= 128) { | if (size <= 128) { | |||
path = path_cat(path_home(), thmbdirnormal); | path = path_cat(path_home(), thmbdirnormal); | |||
path = path_cat(path, name); | path = path_cat(path, name); | |||
} | } | |||
return false; | return false; | |||
} | } | |||
// Compare charset names, removing the more common spelling variations | ||||
bool samecharset(const string& cs1, const string& cs2) | ||||
{ | ||||
auto mcs1 = std::accumulate(cs1.begin(), cs1.end(), "", [](const char* m, ch | ||||
ar i) { return (i != '_' && i != '-') ? m + ::tolower(i) : m; }); | ||||
auto mcs2 = std::accumulate(cs2.begin(), cs2.end(), "", [](const char* m, ch | ||||
ar i) { return (i != '_' && i != '-') ? m + ::tolower(i) : m; }); | ||||
return mcs1 == mcs2; | ||||
} | ||||
static const std::unordered_map<string, string> lang_to_code { | ||||
{"be", "cp1251"}, | ||||
{"bg", "cp1251"}, | ||||
{"cs", "iso-8859-2"}, | ||||
{"el", "iso-8859-7"}, | ||||
{"he", "iso-8859-8"}, | ||||
{"hr", "iso-8859-2"}, | ||||
{"hu", "iso-8859-2"}, | ||||
{"ja", "eucjp"}, | ||||
{"kk", "pt154"}, | ||||
{"ko", "euckr"}, | ||||
{"lt", "iso-8859-13"}, | ||||
{"lv", "iso-8859-13"}, | ||||
{"pl", "iso-8859-2"}, | ||||
{"rs", "iso-8859-2"}, | ||||
{"ro", "iso-8859-2"}, | ||||
{"ru", "koi8-r"}, | ||||
{"sk", "iso-8859-2"}, | ||||
{"sl", "iso-8859-2"}, | ||||
{"sr", "iso-8859-2"}, | ||||
{"th", "iso-8859-11"}, | ||||
{"tr", "iso-8859-9"}, | ||||
{"uk", "koi8-u"}, | ||||
}; | ||||
string langtocode(const string& lang) | ||||
{ | ||||
const auto it = lang_to_code.find(lang); | ||||
// Use cp1252 by default... | ||||
if (it == lang_to_code.end()) { | ||||
return cstr_cp1252; | ||||
} | ||||
return it->second; | ||||
} | ||||
string localelang() | ||||
{ | ||||
const char *lang = getenv("LANG"); | ||||
if (lang == nullptr || *lang == 0 || !strcmp(lang, "C") || | ||||
!strcmp(lang, "POSIX")) { | ||||
return "en"; | ||||
} | ||||
string locale(lang); | ||||
string::size_type under = locale.find_first_of('_'); | ||||
if (under == string::npos) { | ||||
return locale; | ||||
} | ||||
return locale.substr(0, under); | ||||
} | ||||
void rclutil_init_mt() | void rclutil_init_mt() | |||
{ | { | |||
path_pkgdatadir(); | path_pkgdatadir(); | |||
tmplocation(); | tmplocation(); | |||
thumbnailsdir(); | thumbnailsdir(); | |||
// Init langtocode() static table | ||||
langtocode(""); | ||||
} | } | |||
End of changes. 3 change blocks. | ||||
0 lines changed or deleted | 66 lines changed or added |