make stringtotokens use vector
This commit is contained in:
parent
c4a818fc64
commit
e327ea0b4e
@ -752,7 +752,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, string& ipath)
|
|||||||
vector<string> vipath(MAXHANDLERS);
|
vector<string> vipath(MAXHANDLERS);
|
||||||
int vipathidx = 0;
|
int vipathidx = 0;
|
||||||
if (!ipath.empty()) {
|
if (!ipath.empty()) {
|
||||||
list<string> lipath;
|
vector<string> lipath;
|
||||||
stringToTokens(ipath, lipath, isep, true);
|
stringToTokens(ipath, lipath, isep, true);
|
||||||
vipath.insert(vipath.begin(), lipath.begin(), lipath.end());
|
vipath.insert(vipath.begin(), lipath.begin(), lipath.end());
|
||||||
if (!m_handlers.back()->skip_to_document(vipath[m_handlers.size()-1])){
|
if (!m_handlers.back()->skip_to_document(vipath[m_handlers.size()-1])){
|
||||||
|
|||||||
@ -102,14 +102,14 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We're expecting something like Name: len\n
|
// We're expecting something like Name: len\n
|
||||||
list<string> tokens;
|
vector<string> tokens;
|
||||||
stringToTokens(ibuf, tokens);
|
stringToTokens(ibuf, tokens);
|
||||||
if (tokens.size() != 2) {
|
if (tokens.size() != 2) {
|
||||||
LOGERR(("MHExecMultiple: bad line in filter output: [%s]\n",
|
LOGERR(("MHExecMultiple: bad line in filter output: [%s]\n",
|
||||||
ibuf.c_str()));
|
ibuf.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
list<string>::iterator it = tokens.begin();
|
vector<string>::iterator it = tokens.begin();
|
||||||
name = *it++;
|
name = *it++;
|
||||||
string& slen = *it;
|
string& slen = *it;
|
||||||
int len;
|
int len;
|
||||||
|
|||||||
@ -208,9 +208,9 @@ void rwSettings(bool writing)
|
|||||||
prefs.allExtraDbs = g_dynconf->getStringList(allEdbsSk);
|
prefs.allExtraDbs = g_dynconf->getStringList(allEdbsSk);
|
||||||
const char *cp;
|
const char *cp;
|
||||||
if ((cp = getenv("RECOLL_EXTRA_DBS")) != 0) {
|
if ((cp = getenv("RECOLL_EXTRA_DBS")) != 0) {
|
||||||
list<string> dbl;
|
vector<string> dbl;
|
||||||
stringToTokens(cp, dbl, ":");
|
stringToTokens(cp, dbl, ":");
|
||||||
for (list<string>::iterator dit = dbl.begin(); dit != dbl.end();
|
for (vector<string>::iterator dit = dbl.begin(); dit != dbl.end();
|
||||||
dit++) {
|
dit++) {
|
||||||
string dbdir = path_canon(*dit);
|
string dbdir = path_canon(*dit);
|
||||||
path_catslash(dbdir);
|
path_catslash(dbdir);
|
||||||
|
|||||||
@ -946,7 +946,7 @@ static bool lookForHtmlBrowser(string &exefile)
|
|||||||
{
|
{
|
||||||
static const char *htmlbrowserlist =
|
static const char *htmlbrowserlist =
|
||||||
"opera konqueror firefox mozilla netscape epiphany";
|
"opera konqueror firefox mozilla netscape epiphany";
|
||||||
list<string> blist;
|
vector<string> blist;
|
||||||
stringToTokens(htmlbrowserlist, blist, " ");
|
stringToTokens(htmlbrowserlist, blist, " ");
|
||||||
|
|
||||||
const char *path = getenv("PATH");
|
const char *path = getenv("PATH");
|
||||||
@ -954,7 +954,7 @@ static bool lookForHtmlBrowser(string &exefile)
|
|||||||
path = "/bin:/usr/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/local/bin";
|
path = "/bin:/usr/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/local/bin";
|
||||||
|
|
||||||
// Look for each browser
|
// Look for each browser
|
||||||
for (list<string>::const_iterator bit = blist.begin();
|
for (vector<string>::const_iterator bit = blist.begin();
|
||||||
bit != blist.end(); bit++) {
|
bit != blist.end(); bit++) {
|
||||||
if (ExecCmd::which(*bit, exefile, path))
|
if (ExecCmd::which(*bit, exefile, path))
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -165,7 +165,7 @@ static void initfiles()
|
|||||||
const char *cp = getenv("DEBUGLOG_FILES");
|
const char *cp = getenv("DEBUGLOG_FILES");
|
||||||
if (!cp)
|
if (!cp)
|
||||||
return;
|
return;
|
||||||
list<string> files;
|
vector<string> files;
|
||||||
stringToTokens(cp, files, ",");
|
stringToTokens(cp, files, ",");
|
||||||
yesfiles.insert(files.begin(), files.end());
|
yesfiles.insert(files.begin(), files.end());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,9 +98,9 @@ bool ExecCmd::which(const string& cmd, string& exepath, const char* path)
|
|||||||
if (pp == 0)
|
if (pp == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
list<string> pels;
|
vector<string> pels;
|
||||||
stringToTokens(pp, pels, ":");
|
stringToTokens(pp, pels, ":");
|
||||||
for (list<string>::iterator it = pels.begin(); it != pels.end(); it++) {
|
for (vector<string>::iterator it = pels.begin(); it != pels.end(); it++) {
|
||||||
if (it->empty())
|
if (it->empty())
|
||||||
*it = ".";
|
*it = ".";
|
||||||
string candidate = (it->empty() ? string(".") : *it) + "/" + cmd;
|
string candidate = (it->empty() ? string(".") : *it) + "/" + cmd;
|
||||||
|
|||||||
@ -606,7 +606,7 @@ time_t rfc2822DateToUxTime(const string& dt)
|
|||||||
{
|
{
|
||||||
// Strip everything up to first comma if any, we don't need weekday,
|
// Strip everything up to first comma if any, we don't need weekday,
|
||||||
// then break into tokens
|
// then break into tokens
|
||||||
list<string> toks;
|
vector<string> toks;
|
||||||
string::size_type idx;
|
string::size_type idx;
|
||||||
if ((idx = dt.find_first_of(",")) != string::npos) {
|
if ((idx = dt.find_first_of(",")) != string::npos) {
|
||||||
if (idx == dt.length() - 1) {
|
if (idx == dt.length() - 1) {
|
||||||
@ -623,16 +623,11 @@ time_t rfc2822DateToUxTime(const string& dt)
|
|||||||
// 0 1 2 3 4 5 6
|
// 0 1 2 3 4 5 6
|
||||||
// and change to: 19 Nov 2006 06:18:41
|
// and change to: 19 Nov 2006 06:18:41
|
||||||
if (toks.size() == 7) {
|
if (toks.size() == 7) {
|
||||||
list<string>::iterator it0 = toks.begin();
|
if (toks[0].length() == 3 &&
|
||||||
if (it0->length() == 3 &&
|
toks[0].find_first_of("0123456789") == string::npos) {
|
||||||
it0->find_first_of("0123456789") == string::npos) {
|
swap(toks[0], toks[2]);
|
||||||
list<string>::iterator it2 = it0;
|
swap(toks[6], toks[2]);
|
||||||
for (int i = 0; i < 2; i++) it2++;
|
toks.pop_back();
|
||||||
list<string>::iterator it6 = it2;
|
|
||||||
for (int i = 0; i < 4; i++) it6++;
|
|
||||||
iter_swap(it0, it2);
|
|
||||||
iter_swap(it6, it2);
|
|
||||||
toks.erase(it6);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -661,7 +656,7 @@ time_t rfc2822DateToUxTime(const string& dt)
|
|||||||
// Load struct tm with appropriate tokens, possibly converting
|
// Load struct tm with appropriate tokens, possibly converting
|
||||||
// when needed
|
// when needed
|
||||||
|
|
||||||
list<string>::iterator it = toks.begin();
|
vector<string>::iterator it = toks.begin();
|
||||||
|
|
||||||
// Day of month: no conversion needed
|
// Day of month: no conversion needed
|
||||||
tm.tm_mday = atoi(it->c_str());
|
tm.tm_mday = atoi(it->c_str());
|
||||||
|
|||||||
@ -331,10 +331,10 @@ extern string path_canon(const string &is)
|
|||||||
}
|
}
|
||||||
s = path_cat(string(buf), s);
|
s = path_cat(string(buf), s);
|
||||||
}
|
}
|
||||||
list<string>elems;
|
vector<string> elems;
|
||||||
stringToTokens(s, elems, "/");
|
stringToTokens(s, elems, "/");
|
||||||
list<string> cleaned;
|
vector<string> cleaned;
|
||||||
for (list<string>::const_iterator it = elems.begin();
|
for (vector<string>::const_iterator it = elems.begin();
|
||||||
it != elems.end(); it++){
|
it != elems.end(); it++){
|
||||||
if (*it == "..") {
|
if (*it == "..") {
|
||||||
if (!cleaned.empty())
|
if (!cleaned.empty())
|
||||||
@ -346,7 +346,7 @@ extern string path_canon(const string &is)
|
|||||||
}
|
}
|
||||||
string ret;
|
string ret;
|
||||||
if (!cleaned.empty()) {
|
if (!cleaned.empty()) {
|
||||||
for (list<string>::const_iterator it = cleaned.begin();
|
for (vector<string>::const_iterator it = cleaned.begin();
|
||||||
it != cleaned.end(); it++) {
|
it != cleaned.end(); it++) {
|
||||||
ret += "/";
|
ret += "/";
|
||||||
ret += *it;
|
ret += *it;
|
||||||
|
|||||||
@ -336,7 +336,7 @@ void stringsToString(const set<string> &tokens, string &s)
|
|||||||
stringsToString<set<string> >(tokens, s);
|
stringsToString<set<string> >(tokens, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stringToTokens(const string& str, list<string>& tokens,
|
void stringToTokens(const string& str, vector<string>& tokens,
|
||||||
const string& delims, bool skipinit)
|
const string& delims, bool skipinit)
|
||||||
{
|
{
|
||||||
string::size_type startPos = 0, pos;
|
string::size_type startPos = 0, pos;
|
||||||
|
|||||||
@ -100,7 +100,7 @@ extern void stringsToString(const set<string> &tokens, string &s);
|
|||||||
/**
|
/**
|
||||||
* Split input string. No handling of quoting
|
* Split input string. No handling of quoting
|
||||||
*/
|
*/
|
||||||
extern void stringToTokens(const string &s, list<string> &tokens,
|
extern void stringToTokens(const string &s, vector<string> &tokens,
|
||||||
const string &delims = " \t", bool skipinit=true);
|
const string &delims = " \t", bool skipinit=true);
|
||||||
|
|
||||||
/** Convert string to boolean */
|
/** Convert string to boolean */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user