|
a/src/common/rclconfig.cpp |
|
b/src/common/rclconfig.cpp |
|
... |
|
... |
63 |
bool o_uptodate_test_use_mtime = false;
|
63 |
bool o_uptodate_test_use_mtime = false;
|
64 |
|
64 |
|
65 |
string RclConfig::o_localecharset;
|
65 |
string RclConfig::o_localecharset;
|
66 |
string RclConfig::o_origcwd;
|
66 |
string RclConfig::o_origcwd;
|
67 |
|
67 |
|
68 |
// Compute the difference of 1st to 2nd set<string> and return as
|
68 |
// Compute the difference of 1st to 2nd sets and return as plus/minus
|
69 |
// plus/minus strings
|
69 |
// sets. Some args are std::set and some others stringToString()
|
70 |
static void setPlusMinus(const set<string>& base, const set<string>& upd,
|
70 |
// strings for convenience
|
|
|
71 |
void RclConfig::setPlusMinus(const string& sbase, const set<string>& upd,
|
71 |
string& plus, string& minus)
|
72 |
string& splus, string& sminus)
|
72 |
{
|
73 |
{
|
|
|
74 |
set<string> base;
|
|
|
75 |
stringToStrings(sbase, base);
|
|
|
76 |
|
73 |
vector<string> diff;
|
77 |
vector<string> diff;
|
74 |
auto it =
|
78 |
auto it =
|
75 |
set_difference(base.begin(), base.end(), upd.begin(), upd.end(),
|
79 |
set_difference(base.begin(), base.end(), upd.begin(), upd.end(),
|
76 |
std::inserter(diff, diff.begin()));
|
80 |
std::inserter(diff, diff.begin()));
|
77 |
minus = stringsToString(diff);
|
81 |
sminus = stringsToString(diff);
|
78 |
|
82 |
|
79 |
diff.clear();
|
83 |
diff.clear();
|
80 |
it = set_difference(upd.begin(), upd.end(), base.begin(), base.end(),
|
84 |
it = set_difference(upd.begin(), upd.end(), base.begin(), base.end(),
|
81 |
std::inserter(diff, diff.begin()));
|
85 |
std::inserter(diff, diff.begin()));
|
82 |
plus = stringsToString(diff);
|
86 |
splus = stringsToString(diff);
|
83 |
}
|
87 |
}
|
84 |
|
88 |
|
|
|
89 |
/* Compute result of substracting strminus and adding strplus to base string.
|
|
|
90 |
All string represent sets of values to be computed with stringToStrings() */
|
85 |
static void computeBasePlusMinus(set<string>& res, const string& strbase,
|
91 |
static void computeBasePlusMinus(set<string>& res, const string& strbase,
|
86 |
const string& strplus, const string& strminus)
|
92 |
const string& strplus, const string& strminus)
|
87 |
{
|
93 |
{
|
88 |
set<string> plus, minus;
|
94 |
set<string> plus, minus;
|
|
|
95 |
res.clear();
|
89 |
stringToStrings(strbase, res);
|
96 |
stringToStrings(strbase, res);
|
90 |
stringToStrings(strplus, plus);
|
97 |
stringToStrings(strplus, plus);
|
91 |
stringToStrings(strminus, minus);
|
98 |
stringToStrings(strminus, minus);
|
92 |
for (auto& it : minus) {
|
99 |
for (auto& it : minus) {
|
93 |
auto it1 = res.find(it);
|
100 |
auto it1 = res.find(it);
|
|
... |
|
... |
658 |
++r1; ++r2;
|
665 |
++r1; ++r2;
|
659 |
}
|
666 |
}
|
660 |
return 0;
|
667 |
return 0;
|
661 |
}
|
668 |
}
|
662 |
};
|
669 |
};
|
|
|
670 |
|
663 |
typedef multiset<SfString, SuffCmp> SuffixStore;
|
671 |
typedef multiset<SfString, SuffCmp> SuffixStore;
|
664 |
|
|
|
665 |
#define STOPSUFFIXES ((SuffixStore *)m_stopsuffixes)
|
672 |
#define STOPSUFFIXES ((SuffixStore *)m_stopsuffixes)
|
666 |
|
673 |
|
667 |
bool RclConfig::inStopSuffixes(const string& fni)
|
674 |
vector<string>& RclConfig::getStopSuffixes()
|
668 |
{
|
675 |
{
|
669 |
LOGDEB2("RclConfig::inStopSuffixes(" << fni << ")\n");
|
|
|
670 |
// Beware: both needrecompute() need to be called always hence the
|
|
|
671 |
// bizarre way we do things
|
|
|
672 |
bool needrecompute = m_stpsuffstate.needrecompute();
|
676 |
bool needrecompute = m_stpsuffstate.needrecompute();
|
673 |
needrecompute = m_oldstpsuffstate.needrecompute() || needrecompute;
|
677 |
needrecompute = m_oldstpsuffstate.needrecompute() || needrecompute;
|
674 |
if (needrecompute || m_stopsuffixes == 0) {
|
678 |
if (needrecompute || m_stopsuffixes == 0) {
|
675 |
// Need to initialize the suffixes
|
679 |
// Need to initialize the suffixes
|
676 |
delete STOPSUFFIXES;
|
680 |
|
677 |
if ((m_stopsuffixes = new SuffixStore) == 0) {
|
|
|
678 |
LOGERR("RclConfig::inStopSuffixes: out of memory\n");
|
|
|
679 |
return false;
|
|
|
680 |
}
|
|
|
681 |
// Let the old customisation have priority: if recoll_noindex
|
681 |
// Let the old customisation have priority: if recoll_noindex from
|
682 |
// from mimemap is set, it the user's (the default value is
|
682 |
// mimemap is set, it the user's (the default value is gone). Else
|
683 |
// gone). Else use the new variable
|
683 |
// use the new variable
|
684 |
set<string> stoplist;
|
|
|
685 |
if (!m_oldstpsuffstate.getvalue(0).empty()) {
|
684 |
if (!m_oldstpsuffstate.getvalue(0).empty()) {
|
686 |
stringToStrings(m_oldstpsuffstate.getvalue(0), stoplist);
|
685 |
stringToStrings(m_oldstpsuffstate.getvalue(0), m_stopsuffvec);
|
687 |
} else {
|
686 |
} else {
|
|
|
687 |
std::set<string> ss;
|
688 |
computeBasePlusMinus(stoplist, m_stpsuffstate.getvalue(0),
|
688 |
computeBasePlusMinus(ss, m_stpsuffstate.getvalue(0),
|
689 |
m_stpsuffstate.getvalue(1),
|
689 |
m_stpsuffstate.getvalue(1),
|
690 |
m_stpsuffstate.getvalue(2));
|
690 |
m_stpsuffstate.getvalue(2));
|
|
|
691 |
m_stopsuffvec = vector<string>(ss.begin(), ss.end());
|
691 |
}
|
692 |
}
|
692 |
for (auto& it : stoplist) {
|
693 |
|
|
|
694 |
// Compute the special suffixes store
|
|
|
695 |
delete STOPSUFFIXES;
|
|
|
696 |
if ((m_stopsuffixes = new SuffixStore) == 0) {
|
|
|
697 |
LOGERR("RclConfig::inStopSuffixes: out of memory\n");
|
|
|
698 |
return m_stopsuffvec;
|
|
|
699 |
}
|
|
|
700 |
m_maxsufflen = 0;
|
|
|
701 |
for (const auto& entry : m_stopsuffvec) {
|
693 |
STOPSUFFIXES->insert(SfString(stringtolower(it)));
|
702 |
STOPSUFFIXES->insert(SfString(stringtolower(entry)));
|
694 |
if (m_maxsufflen < it.length())
|
703 |
if (m_maxsufflen < entry.length())
|
695 |
m_maxsufflen = int(it.length());
|
704 |
m_maxsufflen = int(entry.length());
|
|
|
705 |
}
|
|
|
706 |
}
|
|
|
707 |
LOGDEB1("RclConfig::getStopSuffixes: ->" <<
|
|
|
708 |
stringsToString(m_stopsuffvec) << endl);
|
|
|
709 |
return m_stopsuffvec;
|
696 |
}
|
710 |
}
|
697 |
}
|
711 |
|
|
|
712 |
bool RclConfig::inStopSuffixes(const string& fni)
|
|
|
713 |
{
|
|
|
714 |
LOGDEB2("RclConfig::inStopSuffixes(" << fni << ")\n");
|
|
|
715 |
|
|
|
716 |
// Call getStopSuffixes() to possibly update state, ignore result
|
|
|
717 |
getStopSuffixes();
|
698 |
|
718 |
|
699 |
// Only need a tail as long as the longest suffix.
|
719 |
// Only need a tail as long as the longest suffix.
|
700 |
int pos = MAX(0, int(fni.length() - m_maxsufflen));
|
720 |
int pos = MAX(0, int(fni.length() - m_maxsufflen));
|
701 |
string fn(fni, pos);
|
721 |
string fn(fni, pos);
|
702 |
|
722 |
|
|
... |
|
... |
1095 |
bool RclConfig::setMimeViewerAllEx(const set<string>& allex)
|
1115 |
bool RclConfig::setMimeViewerAllEx(const set<string>& allex)
|
1096 |
{
|
1116 |
{
|
1097 |
if (mimeview == 0)
|
1117 |
if (mimeview == 0)
|
1098 |
return false;
|
1118 |
return false;
|
1099 |
|
1119 |
|
1100 |
string s;
|
1120 |
string sbase;
|
1101 |
mimeview->get("xallexcepts", s, "");
|
1121 |
mimeview->get("xallexcepts", sbase, "");
|
1102 |
set<string> base;
|
|
|
1103 |
stringToStrings(s, base);
|
|
|
1104 |
|
1122 |
|
1105 |
string splus, sminus;
|
1123 |
string splus, sminus;
|
1106 |
setPlusMinus(base, allex, splus, sminus);
|
1124 |
setPlusMinus(sbase, allex, splus, sminus);
|
1107 |
|
1125 |
|
1108 |
if (!mimeview->set("xallexcepts-", sminus, "")) {
|
1126 |
if (!mimeview->set("xallexcepts-", sminus, "")) {
|
1109 |
m_reason = string("RclConfig:: cant set value. Readonly?");
|
1127 |
m_reason = string("RclConfig:: cant set value. Readonly?");
|
1110 |
return false;
|
1128 |
return false;
|
1111 |
}
|
1129 |
}
|
|
... |
|
... |
1617 |
m_aliastoqcanon = r.m_aliastoqcanon;
|
1635 |
m_aliastoqcanon = r.m_aliastoqcanon;
|
1618 |
m_storedFields = r.m_storedFields;
|
1636 |
m_storedFields = r.m_storedFields;
|
1619 |
m_xattrtofld = r.m_xattrtofld;
|
1637 |
m_xattrtofld = r.m_xattrtofld;
|
1620 |
m_maxsufflen = r.m_maxsufflen;
|
1638 |
m_maxsufflen = r.m_maxsufflen;
|
1621 |
m_skpnlist = r.m_skpnlist;
|
1639 |
m_skpnlist = r.m_skpnlist;
|
|
|
1640 |
m_stopsuffixes = r.m_stopsuffixes;
|
1622 |
m_defcharset = r.m_defcharset;
|
1641 |
m_defcharset = r.m_defcharset;
|
1623 |
m_restrictMTypes = r.m_restrictMTypes;
|
1642 |
m_restrictMTypes = r.m_restrictMTypes;
|
1624 |
m_excludeMTypes = r.m_excludeMTypes;
|
1643 |
m_excludeMTypes = r.m_excludeMTypes;
|
1625 |
m_thrConf = r.m_thrConf;
|
1644 |
m_thrConf = r.m_thrConf;
|
1626 |
m_mdreapers = r.m_mdreapers;
|
1645 |
m_mdreapers = r.m_mdreapers;
|