Mercurial > projects > ldc
diff gen/configfile.cpp @ 1340:206329112670
Fix the ldcbinarypath config file rewriting.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 10 May 2009 18:14:36 +0200 |
parents | 2e98ddd72fa7 |
children | 8309ebaa23d5 |
line wrap: on
line diff
--- a/gen/configfile.cpp Sun May 10 18:03:32 2009 +0200 +++ b/gen/configfile.cpp Sun May 10 18:14:36 2009 +0200 @@ -1,7 +1,7 @@ #include <iostream> #include <string> #include <cassert> -#include <string.h> +#include <cstring> #include "llvm/System/Path.h" @@ -85,6 +85,9 @@ // handle switches if (root.exists("switches")) { + std::string binpathkey = "%%ldcbinarypath%%"; + std::string binpath = sys::Path::GetMainExecutable(argv0, mainAddr).getDirname(); + libconfig::Setting& arr = cfg->lookup("default.switches"); int len = arr.getLength(); for (int i=0; i<len; i++) @@ -92,13 +95,10 @@ std::string v = arr[i]; // replace binpathkey with binpath - std::string binpathkey = "%%ldcbinarypath%%"; - sys::Path binpathgetter = sys::Path::GetMainExecutable(argv0, mainAddr); - binpathgetter.eraseComponent(); - std::string binpath = binpathgetter.toString(); size_t p; while (std::string::npos != (p = v.find(binpathkey))) v.replace(p, binpathkey.size(), binpath); + switches.push_back(strdup(v.c_str())); } }