From e327ea0b4e7d9cde41de3adc2b466e2090a3ca80 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Mon, 13 Sep 2010 14:17:22 +0200 Subject: [PATCH] make stringtotokens use vector --- src/internfile/internfile.cpp | 2 +- src/internfile/mh_execm.cpp | 4 ++-- src/qtgui/guiutils.cpp | 4 ++-- src/qtgui/rclmain_w.cpp | 4 ++-- src/utils/debuglog.cpp | 2 +- src/utils/execmd.cpp | 4 ++-- src/utils/mimeparse.cpp | 19 +++++++------------ src/utils/pathut.cpp | 8 ++++---- src/utils/smallut.cpp | 2 +- src/utils/smallut.h | 2 +- 10 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp index a88cac39..9ef4059e 100644 --- a/src/internfile/internfile.cpp +++ b/src/internfile/internfile.cpp @@ -752,7 +752,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, string& ipath) vector vipath(MAXHANDLERS); int vipathidx = 0; if (!ipath.empty()) { - list lipath; + vector lipath; stringToTokens(ipath, lipath, isep, true); vipath.insert(vipath.begin(), lipath.begin(), lipath.end()); if (!m_handlers.back()->skip_to_document(vipath[m_handlers.size()-1])){ diff --git a/src/internfile/mh_execm.cpp b/src/internfile/mh_execm.cpp index 3b63ad93..54faeb23 100644 --- a/src/internfile/mh_execm.cpp +++ b/src/internfile/mh_execm.cpp @@ -102,14 +102,14 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data) } // We're expecting something like Name: len\n - list tokens; + vector tokens; stringToTokens(ibuf, tokens); if (tokens.size() != 2) { LOGERR(("MHExecMultiple: bad line in filter output: [%s]\n", ibuf.c_str())); return false; } - list::iterator it = tokens.begin(); + vector::iterator it = tokens.begin(); name = *it++; string& slen = *it; int len; diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 9406c191..550499ff 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -208,9 +208,9 @@ void rwSettings(bool writing) prefs.allExtraDbs = g_dynconf->getStringList(allEdbsSk); const char *cp; if ((cp = getenv("RECOLL_EXTRA_DBS")) != 0) { - list dbl; + vector dbl; stringToTokens(cp, dbl, ":"); - for (list::iterator dit = dbl.begin(); dit != dbl.end(); + for (vector::iterator dit = dbl.begin(); dit != dbl.end(); dit++) { string dbdir = path_canon(*dit); path_catslash(dbdir); diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index e7f498e3..ed114271 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -946,7 +946,7 @@ static bool lookForHtmlBrowser(string &exefile) { static const char *htmlbrowserlist = "opera konqueror firefox mozilla netscape epiphany"; - list blist; + vector blist; stringToTokens(htmlbrowserlist, blist, " "); 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"; // Look for each browser - for (list::const_iterator bit = blist.begin(); + for (vector::const_iterator bit = blist.begin(); bit != blist.end(); bit++) { if (ExecCmd::which(*bit, exefile, path)) return true; diff --git a/src/utils/debuglog.cpp b/src/utils/debuglog.cpp index 31609a75..c3323459 100644 --- a/src/utils/debuglog.cpp +++ b/src/utils/debuglog.cpp @@ -165,7 +165,7 @@ static void initfiles() const char *cp = getenv("DEBUGLOG_FILES"); if (!cp) return; - list files; + vector files; stringToTokens(cp, files, ","); yesfiles.insert(files.begin(), files.end()); } diff --git a/src/utils/execmd.cpp b/src/utils/execmd.cpp index 2bb1223e..423e5d5c 100644 --- a/src/utils/execmd.cpp +++ b/src/utils/execmd.cpp @@ -98,9 +98,9 @@ bool ExecCmd::which(const string& cmd, string& exepath, const char* path) if (pp == 0) return false; - list pels; + vector pels; stringToTokens(pp, pels, ":"); - for (list::iterator it = pels.begin(); it != pels.end(); it++) { + for (vector::iterator it = pels.begin(); it != pels.end(); it++) { if (it->empty()) *it = "."; string candidate = (it->empty() ? string(".") : *it) + "/" + cmd; diff --git a/src/utils/mimeparse.cpp b/src/utils/mimeparse.cpp index 071fd2a6..a4c2af57 100644 --- a/src/utils/mimeparse.cpp +++ b/src/utils/mimeparse.cpp @@ -606,7 +606,7 @@ time_t rfc2822DateToUxTime(const string& dt) { // Strip everything up to first comma if any, we don't need weekday, // then break into tokens - list toks; + vector toks; string::size_type idx; if ((idx = dt.find_first_of(",")) != string::npos) { if (idx == dt.length() - 1) { @@ -623,16 +623,11 @@ time_t rfc2822DateToUxTime(const string& dt) // 0 1 2 3 4 5 6 // and change to: 19 Nov 2006 06:18:41 if (toks.size() == 7) { - list::iterator it0 = toks.begin(); - if (it0->length() == 3 && - it0->find_first_of("0123456789") == string::npos) { - list::iterator it2 = it0; - for (int i = 0; i < 2; i++) it2++; - list::iterator it6 = it2; - for (int i = 0; i < 4; i++) it6++; - iter_swap(it0, it2); - iter_swap(it6, it2); - toks.erase(it6); + if (toks[0].length() == 3 && + toks[0].find_first_of("0123456789") == string::npos) { + swap(toks[0], toks[2]); + swap(toks[6], toks[2]); + toks.pop_back(); } } } @@ -661,7 +656,7 @@ time_t rfc2822DateToUxTime(const string& dt) // Load struct tm with appropriate tokens, possibly converting // when needed - list::iterator it = toks.begin(); + vector::iterator it = toks.begin(); // Day of month: no conversion needed tm.tm_mday = atoi(it->c_str()); diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index 08480ce6..0571032b 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -331,10 +331,10 @@ extern string path_canon(const string &is) } s = path_cat(string(buf), s); } - listelems; + vector elems; stringToTokens(s, elems, "/"); - list cleaned; - for (list::const_iterator it = elems.begin(); + vector cleaned; + for (vector::const_iterator it = elems.begin(); it != elems.end(); it++){ if (*it == "..") { if (!cleaned.empty()) @@ -346,7 +346,7 @@ extern string path_canon(const string &is) } string ret; if (!cleaned.empty()) { - for (list::const_iterator it = cleaned.begin(); + for (vector::const_iterator it = cleaned.begin(); it != cleaned.end(); it++) { ret += "/"; ret += *it; diff --git a/src/utils/smallut.cpp b/src/utils/smallut.cpp index 8fc3d046..7cdcf21f 100644 --- a/src/utils/smallut.cpp +++ b/src/utils/smallut.cpp @@ -336,7 +336,7 @@ void stringsToString(const set &tokens, string &s) stringsToString >(tokens, s); } -void stringToTokens(const string& str, list& tokens, +void stringToTokens(const string& str, vector& tokens, const string& delims, bool skipinit) { string::size_type startPos = 0, pos; diff --git a/src/utils/smallut.h b/src/utils/smallut.h index 2967a0a6..ee8f89be 100644 --- a/src/utils/smallut.h +++ b/src/utils/smallut.h @@ -100,7 +100,7 @@ extern void stringsToString(const set &tokens, string &s); /** * Split input string. No handling of quoting */ -extern void stringToTokens(const string &s, list &tokens, +extern void stringToTokens(const string &s, vector &tokens, const string &delims = " \t", bool skipinit=true); /** Convert string to boolean */