mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
fix appveyor
This commit is contained in:
parent
10c55d9534
commit
d9b9e5e227
@ -139,8 +139,9 @@ std::string GetExecutablePath() {
|
||||
return std::string(path);
|
||||
#else
|
||||
char buffer[PATH_MAX] = {0};
|
||||
readlink("/proc/self/exe", buffer, PATH_MAX);
|
||||
return std::string(buffer);
|
||||
if(-1 == readlink("/proc/self/exe", buffer, PATH_MAX))
|
||||
return "";
|
||||
return buffer;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
16
src/utils.cc
16
src/utils.cc
@ -14,6 +14,7 @@
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#if !defined(__APPLE__)
|
||||
@ -490,6 +491,13 @@ std::string GetDefaultResourceDirectory() {
|
||||
|
||||
std::string resource_directory =
|
||||
std::string(ENSURE_STRING_MACRO_ARGUMENT(DEFAULT_RESOURCE_DIRECTORY));
|
||||
// Remove double quoted resource dir if it was passed with quotes
|
||||
// by the build system.
|
||||
if (resource_directory.size() >= 2 && resource_directory[0] == '"' &&
|
||||
resource_directory[resource_directory.size() - 1] == '"') {
|
||||
resource_directory =
|
||||
resource_directory.substr(1, resource_directory.size() - 2);
|
||||
}
|
||||
if (resource_directory.find("..") != std::string::npos) {
|
||||
std::string executable_path = GetExecutablePath();
|
||||
size_t pos = executable_path.find_last_of('/');
|
||||
@ -499,7 +507,11 @@ std::string GetDefaultResourceDirectory() {
|
||||
result = resource_directory;
|
||||
}
|
||||
|
||||
return NormalizePath(result);
|
||||
result = NormalizePath(result);
|
||||
#if defined(_WIN32)
|
||||
std::replace(result.begin(), result.end(), '/', '\\');
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string UpdateToRnNewlines(std::string output) {
|
||||
@ -585,4 +597,4 @@ TEST_SUITE("Update \\n to \\r\\n") {
|
||||
REQUIRE(UpdateToRnNewlines("f1\nfo2\nfoo3") == "f1\r\nfo2\r\nfoo3");
|
||||
REQUIRE(UpdateToRnNewlines("f1\r\nfo2\r\nfoo3") == "f1\r\nfo2\r\nfoo3");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user