[PATCH xorg-gtest 13/16] xserver: use new Process::Start(vector) call to populate argument list

Peter Hutterer peter.hutterer at who-t.net
Mon Jul 2 23:44:54 PDT 2012


There's probably some better way to do this than strdup()ing everything,
send me a patch if you know how.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/xserver.cpp |   24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/xserver.cpp b/src/xserver.cpp
index 765feb1..cc78d59 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -301,13 +301,25 @@ unsigned int xorg::testing::XServer::Start(void) {
 }
 
 unsigned int xorg::testing::XServer::Start(std::string &program) {
+  std::vector<char*> args;
+  std::map<std::string, std::string>::iterator it;
+
   TestStartup();
-  Process::Start(program, program.c_str(),
-                 GetDisplayString(),
-                 "-logverbose", "10",
-                 "-logfile", d_->options["-logfile"].c_str(),
-                 "-config", d_->options["-config"].c_str(),
-                 NULL);
+
+  args.push_back(strdup(program.c_str()));
+  args.push_back(strdup(GetDisplayString()));
+
+  for (it = d_->options.begin(); it != d_->options.end(); it++) {
+    args.push_back(strdup(it->first.c_str()));
+    if (it->second.length())
+      args.push_back(strdup(it->second.c_str()));
+  }
+
+  Process::Start(program, args);
+
+  std::vector<char*>::iterator vit;
+  for (vit = args.begin(); vit != args.end(); vit++)
+    free(*vit);
 
   /* FIXME: use -displayfd here once the released servers support it */
   return d_->display_number;
-- 
1.7.10.4



More information about the xorg-devel mailing list