Fix small string / $HOME mess.
This commit is contained in:
parent
0552bae468
commit
95c14596f0
@ -14,10 +14,10 @@
|
|||||||
#include "textinput/StreamReader.h"
|
#include "textinput/StreamReader.h"
|
||||||
#include "textinput/TerminalDisplay.h"
|
#include "textinput/TerminalDisplay.h"
|
||||||
|
|
||||||
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/Path.h"
|
#include "llvm/Support/Path.h"
|
||||||
#include "llvm/Support/SmallString.h"
|
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
|
|
||||||
// Fragment copied from LLVM's raw_ostream.cpp
|
// Fragment copied from LLVM's raw_ostream.cpp
|
||||||
@ -52,11 +52,12 @@ namespace {
|
|||||||
}
|
}
|
||||||
#if defined(LLVM_ON_UNIX)
|
#if defined(LLVM_ON_UNIX)
|
||||||
static void GetUserHomeDirectory(llvm::SmallVectorImpl<char>& str) {
|
static void GetUserHomeDirectory(llvm::SmallVectorImpl<char>& str) {
|
||||||
if (const char* home = getenv("HOME"))
|
str.clear();
|
||||||
str = home;
|
const char* home = getenv("HOME");
|
||||||
} else {
|
if (!home)
|
||||||
str = "/";
|
home = "/";
|
||||||
}
|
llvm::StringRef SRhome(home);
|
||||||
|
str.insert(str.begin(), SRhome.begin(), SRhome.end());
|
||||||
}
|
}
|
||||||
#elif defined(LLVM_ON_WIN32)
|
#elif defined(LLVM_ON_WIN32)
|
||||||
static void GetUserHomeDirectory(llvm::SmallVectorImpl<char>& str) {
|
static void GetUserHomeDirectory(llvm::SmallVectorImpl<char>& str) {
|
||||||
@ -68,7 +69,8 @@ namespace {
|
|||||||
str.data());
|
str.data());
|
||||||
if (res != S_OK) {
|
if (res != S_OK) {
|
||||||
assert(0 && "Failed to get user home directory");
|
assert(0 && "Failed to get user home directory");
|
||||||
str = "/";
|
llvm::StringRef SRhome("\\");
|
||||||
|
str.insert(str.begin(), SRhome.begin(), SRhome.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -98,9 +100,9 @@ namespace cling {
|
|||||||
|
|
||||||
// History file is $HOME/.cling_history
|
// History file is $HOME/.cling_history
|
||||||
static const char* histfile = ".cling_history";
|
static const char* histfile = ".cling_history";
|
||||||
llvm:SmallString<512> histfilePath;
|
llvm::SmallString<512> histfilePath;
|
||||||
GetUserHomeDirectory(histfilePath);
|
GetUserHomeDirectory(histfilePath);
|
||||||
llvm::sys::fs::append(histfilePath, histfile);
|
llvm::sys::path::append(histfilePath, histfile);
|
||||||
|
|
||||||
using namespace textinput;
|
using namespace textinput;
|
||||||
StreamReader* R = StreamReader::Create();
|
StreamReader* R = StreamReader::Create();
|
||||||
|
Loading…
Reference in New Issue
Block a user