mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-09 04:15:58 +03:00
Include config file path in JSON output
Required for dmd-testsuite's compilable/json2.d. Also fixes a bug regarding ConfigFile::path() with a null config file path (e.g., when disabled explicitly via `-conf=`) - the std::string(const char *) ctor segfaults for a null pointer arg, whereas llvm::StringRef handles null pointers gracefully.
This commit is contained in:
parent
426555f354
commit
32b7637528
4 changed files with 14 additions and 8 deletions
|
@ -18,11 +18,14 @@
|
|||
|
||||
namespace opts {
|
||||
|
||||
char *dupPathString(const std::string &src) {
|
||||
char *r = mem.xstrdup(src.c_str());
|
||||
char *dupPathString(llvm::StringRef src) {
|
||||
const auto length = src.size();
|
||||
char *r = static_cast<char *>(mem.xmalloc(length + 1));
|
||||
memcpy(r, src.data(), length);
|
||||
#if _WIN32
|
||||
std::replace(r, r + src.length(), '/', '\\');
|
||||
std::replace(r, r + length, '/', '\\');
|
||||
#endif
|
||||
r[length] = '\0';
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue