mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 15:45:08 +00:00
Ensure DEFAULT_RESOURCE_DIRECTORY is a string.
This commit is contained in:
parent
487680e8d1
commit
9f249970b0
@ -5,6 +5,9 @@
|
||||
|
||||
#include <loguru.hpp>
|
||||
|
||||
#define _STRINGIFY(x) #x
|
||||
#define ENSURE_STRING_MACRO_ARGUMENT(x) _STRINGIFY(x)
|
||||
|
||||
namespace {
|
||||
struct Ipc_InitializeRequest : public IpcMessage<Ipc_InitializeRequest> {
|
||||
const static IpcId kIpcId = IpcId::Initialize;
|
||||
@ -86,11 +89,12 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
|
||||
|
||||
// Ensure there is a resource directory.
|
||||
if (config->resourceDirectory.empty()) {
|
||||
std::string defaultResourceDirectory = std::string(DEFAULT_RESOURCE_DIRECTORY);
|
||||
std::string defaultResourceDirectory = std::string(
|
||||
ENSURE_STRING_MACRO_ARGUMENT(DEFAULT_RESOURCE_DIRECTORY));
|
||||
if (defaultResourceDirectory.find("..") != std::string::npos) {
|
||||
std::string executablePath = GetExecutablePath();
|
||||
size_t pos = executablePath.find_last_of('/');
|
||||
config->resourceDirectory = executablePath.substr(0, pos+1);
|
||||
config->resourceDirectory = executablePath.substr(0, pos + 1);
|
||||
config->resourceDirectory += defaultResourceDirectory;
|
||||
} else {
|
||||
config->resourceDirectory = defaultResourceDirectory;
|
||||
|
Loading…
Reference in New Issue
Block a user