summaryrefslogtreecommitdiffstats
path: root/lib/Plugins/RunApp.cpp
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-05 18:17:59 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-05 18:17:59 +0100
commit03bbbf8eff11cf68a7e2325ca310e02bf3757193 (patch)
treee7e4193fdad0fb07025bd5de795206aa5a2b5098 /lib/Plugins/RunApp.cpp
parent1b6f4595b116e60f267e416459b9102f0d1387b9 (diff)
downloadabrt-03bbbf8eff11cf68a7e2325ca310e02bf3757193.tar.gz
abrt-03bbbf8eff11cf68a7e2325ca310e02bf3757193.tar.xz
abrt-03bbbf8eff11cf68a7e2325ca310e02bf3757193.zip
removal of needlessly global functions
text data bss dec hex filename 10855 1304 16 12175 2f8f abrt.t0/abrt-0.0.11/lib/Plugins/.libs/libRunApp.so 10656 1288 16 11960 2eb8 abrt.t1/abrt-0.0.11/lib/Plugins/.libs/libRunApp.so 26855 1944 16 28815 708f abrt.t0/abrt-0.0.11/lib/Plugins/.libs/libSOSreport.so 24250 1904 24 26178 6642 abrt.t1/abrt-0.0.11/lib/Plugins/.libs/libSOSreport.so Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Plugins/RunApp.cpp')
-rw-r--r--lib/Plugins/RunApp.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp
index 5a5c1d4..51d4346 100644
--- a/lib/Plugins/RunApp.cpp
+++ b/lib/Plugins/RunApp.cpp
@@ -29,28 +29,31 @@
#define COMMAND 0
#define FILENAME 1
-void CActionRunApp::ParseArgs(const std::string& psArgs, vector_string_t& pArgs)
+/* TODO: do not duplicate: SOSreport.cpp has same function too */
+static void ParseArgs(const char *psArgs, vector_string_t& pArgs)
{
- unsigned int ii;
+ unsigned ii;
bool is_quote = false;
- std::string item = "";
- for (ii = 0; ii < psArgs.length(); ii++)
+ std::string item;
+
+ for (ii = 0; psArgs[ii]; ii++)
{
- if (psArgs[ii] == '\"')
+ if (psArgs[ii] == '"')
{
- is_quote = is_quote == true ? false : true;
+ is_quote = !is_quote;
}
else if (psArgs[ii] == ',' && !is_quote)
{
pArgs.push_back(item);
- item = "";
+ item.clear();
}
else
{
item += psArgs[ii];
}
}
- if (item != "")
+
+ if (item.size() != 0)
{
pArgs.push_back(item);
}
@@ -61,18 +64,17 @@ void CActionRunApp::Run(const std::string& pActionDir,
{
update_client(_("Executing RunApp plugin..."));
- char line[1024];
- std::string output = "";
-
+ std::string output;
vector_string_t args;
- ParseArgs(pArgs, args);
+ ParseArgs(pArgs.c_str(), args);
FILE *fp = popen(args[COMMAND].c_str(), "r");
if (fp == NULL)
{
- throw CABRTException(EXCEP_PLUGIN, "CActionRunApp::Run(): cannot execute " + args[COMMAND]);
+ throw CABRTException(EXCEP_PLUGIN, "Can't execute " + args[COMMAND]);
}
+ char line[1024];
while (fgets(line, 1024, fp) != NULL)
{
output += line;