summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-08-26 16:03:15 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-08-26 16:03:15 +0200
commit5a4dc02ee0297c6b0f0fa690b8fc5d2d40e2c6d6 (patch)
tree2cff321dde93a36a357886fd75e820c8a122dacb /lib
parent0b5f2179ae0998ea370cef0328f1cabd2338d249 (diff)
downloadabrt-5a4dc02ee0297c6b0f0fa690b8fc5d2d40e2c6d6.tar.gz
abrt-5a4dc02ee0297c6b0f0fa690b8fc5d2d40e2c6d6.tar.xz
abrt-5a4dc02ee0297c6b0f0fa690b8fc5d2d40e2c6d6.zip
spawn.cpp -> spawn.c
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/Makefile.am2
-rw-r--r--lib/utils/spawn.c (renamed from lib/utils/spawn.cpp)32
2 files changed, 24 insertions, 10 deletions
diff --git a/lib/utils/Makefile.am b/lib/utils/Makefile.am
index 92250811..5bacd991 100644
--- a/lib/utils/Makefile.am
+++ b/lib/utils/Makefile.am
@@ -20,7 +20,7 @@ libABRTUtils_la_SOURCES = \
daemon.c \
skip_whitespace.c \
xatonum.c numtoa.cpp \
- spawn.cpp \
+ spawn.c \
stringops.cpp \
dirsize.cpp \
DebugDump.cpp \
diff --git a/lib/utils/spawn.cpp b/lib/utils/spawn.c
index dace7d4b..068f4ac7 100644
--- a/lib/utils/spawn.cpp
+++ b/lib/utils/spawn.c
@@ -5,16 +5,26 @@
*/
#include "abrtlib.h"
-using namespace std;
-
-static string concat_str_vector(char **strings)
+static char *concat_str_vector(char **strings)
{
- string result;
- while (*strings) {
- result += *strings++;
- if (*strings)
- result += ' ';
+ if (!strings[0])
+ return xzalloc(1); // returns ""
+
+ unsigned len = 0;
+ char **spp = strings;
+ while (*spp)
+ len += strlen(*spp++) + 1;
+
+ char *result = xmalloc(len);
+
+ char *r = result;
+ spp = strings;
+ while (*spp) {
+ r = stpcpy(r, *spp++);
+ *r++ = ' ';
}
+ *--r = '\0';
+
return result;
}
@@ -79,7 +89,11 @@ pid_t fork_execv_on_steroids(int flags,
}
/* This should be done BEFORE stderr redirect */
- VERB1 log("Executing: %s", concat_str_vector(argv).c_str());
+ VERB1 {
+ char *r = concat_str_vector(argv);
+ log("Executing: %s", r);
+ free(r);
+ }
if (flags & EXECFLG_ERR2OUT) {
/* Want parent to see errors in the same stream */