use vector instead of list for execmd arg list

This commit is contained in:
Jean-Francois Dockes 2012-04-11 15:36:49 +02:00
parent c7c9c49437
commit 78bd8d63da
14 changed files with 28 additions and 32 deletions

View File

@ -1 +1 @@
1.17.2 1.18.0

View File

@ -284,7 +284,7 @@ bool Aspell::buildDict(Rcl::Db &db, string &reason)
// We create the dictionary by executing the aspell command: // We create the dictionary by executing the aspell command:
// aspell --lang=[lang] create master [dictApath] // aspell --lang=[lang] create master [dictApath]
ExecCmd aspell; ExecCmd aspell;
list<string> args; vector<string> args;
args.push_back(string("--lang=")+ m_lang); args.push_back(string("--lang=")+ m_lang);
args.push_back("--encoding=utf-8"); args.push_back("--encoding=utf-8");
args.push_back("create"); args.push_back("create");

View File

@ -57,7 +57,7 @@ static string mimetypefromdata(const string &fn, bool usfc)
#ifdef USE_SYSTEM_FILE_COMMAND #ifdef USE_SYSTEM_FILE_COMMAND
if (usfc && mime.empty()) { if (usfc && mime.empty()) {
// Last resort: use "file -i" // Last resort: use "file -i"
list<string> args; vector<string> args;
args.push_back("-i"); args.push_back("-i");
args.push_back(fn); args.push_back(fn);

View File

@ -143,7 +143,7 @@ static bool uncompressfile(RclConfig *conf, const string& ifn,
// Substitute file name and temp dir in command elements // Substitute file name and temp dir in command elements
list<string>::const_iterator it = cmdv.begin(); list<string>::const_iterator it = cmdv.begin();
++it; ++it;
list<string> args; vector<string> args;
map<char, string> subs; map<char, string> subs;
subs['f'] = ifn; subs['f'] = ifn;
subs['t'] = tdir.dirname(); subs['t'] = tdir.dirname();

View File

@ -88,7 +88,7 @@ bool MimeHandlerExec::next_document()
// Build parameter list: delete cmd name and add the file name // Build parameter list: delete cmd name and add the file name
list<string>::iterator it = params.begin(); list<string>::iterator it = params.begin();
list<string>myparams(++it, params.end()); vector<string>myparams(++it, params.end());
myparams.push_back(m_fn); myparams.push_back(m_fn);
if (!m_ipath.empty()) if (!m_ipath.empty())
myparams.push_back(m_ipath); myparams.push_back(m_ipath);

View File

@ -52,7 +52,7 @@ bool MimeHandlerExecMultiple::startCmd()
// Build parameter list: delete cmd name // Build parameter list: delete cmd name
list<string>::iterator it = params.begin(); list<string>::iterator it = params.begin();
list<string>myparams(++it, params.end()); vector<string>myparams(++it, params.end());
// Start filter // Start filter
m_cmd.putenv(m_forPreview ? "RECOLL_FILTER_FORPREVIEW=yes" : m_cmd.putenv(m_forPreview ? "RECOLL_FILTER_FORPREVIEW=yes" :

View File

@ -340,7 +340,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
m_widgets.push_back(eskn); m_widgets.push_back(eskn);
gl1->addWidget(eskn, 0, 0, 1, 2); gl1->addWidget(eskn, 0, 0, 1, 2);
list<string> args; vector<string> args;
args.push_back("-l"); args.push_back("-l");
ExecCmd ex; ExecCmd ex;
string icout; string icout;

View File

@ -703,7 +703,7 @@ void RclMain::toggleIndexing()
break; break;
case IXST_NOTRUNNING: case IXST_NOTRUNNING:
{ {
list<string> args; vector<string> args;
args.push_back("-c"); args.push_back("-c");
args.push_back(theconfig->getConfDir()); args.push_back(theconfig->getConfDir());
m_idxproc = new ExecCmd; m_idxproc = new ExecCmd;
@ -729,7 +729,7 @@ void RclMain::rebuildIndex()
QMessageBox::Cancel, QMessageBox::Cancel,
QMessageBox::NoButton); QMessageBox::NoButton);
if (rep == QMessageBox::Ok) { if (rep == QMessageBox::Ok) {
list<string> args; vector<string> args;
args.push_back("-c"); args.push_back("-c");
args.push_back(theconfig->getConfDir()); args.push_back(theconfig->getConfDir());
args.push_back("-z"); args.push_back("-z");
@ -1256,7 +1256,7 @@ void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
vector<string> paths; vector<string> paths;
if (ConfIndexer::docsToPaths(docs, paths)) { if (ConfIndexer::docsToPaths(docs, paths)) {
list<string> args; vector<string> args;
args.push_back("-c"); args.push_back("-c");
args.push_back(theconfig->getConfDir()); args.push_back(theconfig->getConfDir());
args.push_back("-i"); args.push_back("-i");
@ -1522,7 +1522,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
ignoreipath = stringToBool(cmdplusattr); ignoreipath = stringToBool(cmdplusattr);
// Split the command line // Split the command line
list<string> lcmd; vector<string> lcmd;
if (!stringToStrings(cmd, lcmd)) { if (!stringToStrings(cmd, lcmd)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("Bad viewer command line for %1: [%2]\n" tr("Bad viewer command line for %1: [%2]\n"
@ -1633,7 +1633,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
} }
// Get rid of the command name. lcmd is now argv[1...n] // Get rid of the command name. lcmd is now argv[1...n]
lcmd.pop_front(); lcmd.erase(lcmd.begin());
// Substitute %xx inside arguments // Substitute %xx inside arguments
string efftime; string efftime;
@ -1658,7 +1658,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
subs[it->first] = it->second; subs[it->first] = it->second;
} }
string ncmd; string ncmd;
for (list<string>::iterator it = lcmd.begin(); for (vector<string>::iterator it = lcmd.begin();
it != lcmd.end(); it++) { it != lcmd.end(); it++) {
pcSubst(*it, ncmd, subs); pcSubst(*it, ncmd, subs);
LOGDEB(("%s->%s\n", it->c_str(), ncmd.c_str())); LOGDEB(("%s->%s\n", it->c_str(), ncmd.c_str()));

View File

@ -125,7 +125,7 @@ void RTIToolW::accept()
if (nowCB->isChecked()) { if (nowCB->isChecked()) {
ExecCmd cmd; ExecCmd cmd;
list<string> args; vector<string> args;
int status; int status;
args.push_back("-m"); args.push_back("-m");

View File

@ -29,7 +29,7 @@ static bool eCrontabGetLines(vector<string>& lines)
{ {
string crontab; string crontab;
ExecCmd croncmd; ExecCmd croncmd;
list<string> args; vector<string> args;
int status; int status;
// Retrieve current crontab contents. An error here means that no // Retrieve current crontab contents. An error here means that no
@ -51,7 +51,7 @@ static bool eCrontabWriteFile(const vector<string>& lines, string& reason)
{ {
string crontab; string crontab;
ExecCmd croncmd; ExecCmd croncmd;
list<string> args; vector<string> args;
int status; int status;
for (vector<string>::const_iterator it = lines.begin(); for (vector<string>::const_iterator it = lines.begin();

View File

@ -32,7 +32,6 @@
#include <string.h> #include <string.h>
#endif #endif
#include <list>
#include <vector> #include <vector>
#include <string> #include <string>
#include <sstream> #include <sstream>
@ -173,12 +172,12 @@ ExecCmd::~ExecCmd()
ExecCmdRsrc(this); ExecCmdRsrc(this);
} }
int ExecCmd::startExec(const string &cmd, const list<string>& args, int ExecCmd::startExec(const string &cmd, const vector<string>& args,
bool has_input, bool has_output) bool has_input, bool has_output)
{ {
{ // Debug and logging { // Debug and logging
string command = cmd + " "; string command = cmd + " ";
for (list<string>::const_iterator it = args.begin();it != args.end(); for (vector<string>::const_iterator it = args.begin();it != args.end();
it++) { it++) {
command += "{" + *it + "} "; command += "{" + *it + "} ";
} }
@ -314,7 +313,7 @@ private:
}; };
int ExecCmd::doexec(const string &cmd, const list<string>& args, int ExecCmd::doexec(const string &cmd, const vector<string>& args,
const string *input, string *output) const string *input, string *output)
{ {
@ -505,7 +504,7 @@ bool ExecCmd::maybereap(int *status)
// In child process. Set up pipes, environment, and exec command. // In child process. Set up pipes, environment, and exec command.
// This must not return. exit() on error. // This must not return. exit() on error.
void ExecCmd::dochild(const string &cmd, const list<string>& args, void ExecCmd::dochild(const string &cmd, const vector<string>& args,
bool has_input, bool has_output) bool has_input, bool has_output)
{ {
// Start our own process group // Start our own process group
@ -581,7 +580,7 @@ void ExecCmd::dochild(const string &cmd, const list<string>& args,
// Fill up argv // Fill up argv
argv[0] = cmd.c_str(); argv[0] = cmd.c_str();
int i = 1; int i = 1;
list<string>::const_iterator it; vector<string>::const_iterator it;
for (it = args.begin(); it != args.end(); it++) { for (it = args.begin(); it != args.end(); it++) {
argv[i++] = it->c_str(); argv[i++] = it->c_str();
} }
@ -684,7 +683,7 @@ void ReExec::reexec()
#include <stdlib.h> #include <stdlib.h>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <list> #include <vector>
#include "debuglog.h" #include "debuglog.h"
#include "cancelcheck.h" #include "cancelcheck.h"
@ -781,7 +780,7 @@ int main(int argc, char *argv[])
Usage(); Usage();
string cmd = *argv++; argc--; string cmd = *argv++; argc--;
list<string> l; vector<string> l;
while (argc > 0) { while (argc > 0) {
l.push_back(*argv++); argc--; l.push_back(*argv++); argc--;
} }

View File

@ -18,11 +18,9 @@
#define _EXECMD_H_INCLUDED_ #define _EXECMD_H_INCLUDED_
#include <signal.h> #include <signal.h>
#include <string> #include <string>
#include <list>
#include <vector> #include <vector>
#include <stack> #include <stack>
#ifndef NO_NAMESPACES #ifndef NO_NAMESPACES
using std::list;
using std::string; using std::string;
using std::vector; using std::vector;
using std::stack; using std::stack;
@ -119,12 +117,12 @@ class ExecCmd {
* *
* @param cmd the program to execute. This must be an absolute file name * @param cmd the program to execute. This must be an absolute file name
* or exist in the PATH. * or exist in the PATH.
* @param args the argument list (NOT including argv[0]). * @param args the argument vector (NOT including argv[0]).
* @param input Input to send TO the command. * @param input Input to send TO the command.
* @param output Output FROM the command. * @param output Output FROM the command.
* @return the exec ouput status (0 if ok), or -1 * @return the exec ouput status (0 if ok), or -1
*/ */
int doexec(const string &cmd, const list<string>& args, int doexec(const string &cmd, const vector<string>& args,
const string *input = 0, const string *input = 0,
string *output = 0); string *output = 0);
@ -132,7 +130,7 @@ class ExecCmd {
* The next four methods can be used when a Q/A dialog needs to be * The next four methods can be used when a Q/A dialog needs to be
* performed with the command * performed with the command
*/ */
int startExec(const string &cmd, const list<string>& args, int startExec(const string &cmd, const vector<string>& args,
bool has_input, bool has_output); bool has_input, bool has_output);
int send(const string& data); int send(const string& data);
int receive(string& data, int cnt = -1); int receive(string& data, int cnt = -1);
@ -202,7 +200,7 @@ class ExecCmd {
sigemptyset(&m_blkcld); sigemptyset(&m_blkcld);
} }
// Child process code // Child process code
void dochild(const string &cmd, const list<string>& args, void dochild(const string &cmd, const vector<string>& args,
bool has_input, bool has_output); bool has_input, bool has_output);
/* Copyconst and assignment private and forbidden */ /* Copyconst and assignment private and forbidden */
ExecCmd(const ExecCmd &) {} ExecCmd(const ExecCmd &) {}

View File

@ -29,7 +29,7 @@ bool rclionice(const string& clss, const string& cdata)
LOGDEB0(("rclionice: ionice not found\n")); LOGDEB0(("rclionice: ionice not found\n"));
return false; return false;
} }
list<string> args; vector<string> args;
args.push_back("-c"); args.push_back("-c");
args.push_back(clss); args.push_back(clss);

View File

@ -19,7 +19,6 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <list>
#include <vector> #include <vector>