1
0
Fork 0

Fix ICU path building, windows codepage correctness (#6679)

This commit is contained in:
Wilfried Goesgens 2018-10-02 12:38:24 +02:00 committed by Jan
parent 8667a8e001
commit 73ee5cb40e
4 changed files with 26 additions and 7 deletions

View File

@ -53,7 +53,8 @@ ServerFeature::ServerFeature(
_vstMaxSize(1024 * 30), _vstMaxSize(1024 * 30),
_result(res), _result(res),
_operationMode(OperationMode::MODE_SERVER), _operationMode(OperationMode::MODE_SERVER),
_codePage(65001) { // default to UTF8 _codePage(65001), // default to UTF8
_originalCodePage(UINT16_MAX) {
setOptional(true); setOptional(true);
startsAfter("AQLPhase"); startsAfter("AQLPhase");
@ -158,7 +159,10 @@ void ServerFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
void ServerFeature::start() { void ServerFeature::start() {
#if _WIN32 #if _WIN32
_originalCodePage = GetConsoleOutputCP();
if (IsValidCodePage(_codePage)) {
SetConsoleOutputCP(_codePage); SetConsoleOutputCP(_codePage);
}
#endif #endif
waitForHeartbeat(); waitForHeartbeat();
@ -189,6 +193,14 @@ void ServerFeature::start() {
} }
void ServerFeature::stop() {
#if _WIN32
if (IsValidCodePage(_originalCodePage)) {
SetConsoleOutputCP(_originalCodePage);
}
#endif
}
void ServerFeature::beginShutdown() { void ServerFeature::beginShutdown() {
std::string msg = std::string msg =
ArangoGlobalContext::CONTEXT->binaryName() + " [shutting down]"; ArangoGlobalContext::CONTEXT->binaryName() + " [shutting down]";

View File

@ -44,6 +44,7 @@ class ServerFeature final : public application_features::ApplicationFeature {
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final; void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final; void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
void start() override final; void start() override final;
void stop() override final;
void beginShutdown() override final; void beginShutdown() override final;
bool isStopping() const { return _isStopping; } bool isStopping() const { return _isStopping; }
@ -71,6 +72,7 @@ class ServerFeature final : public application_features::ApplicationFeature {
OperationMode _operationMode; OperationMode _operationMode;
bool _isStopping = false; bool _isStopping = false;
uint16_t _codePage; uint16_t _codePage;
uint16_t _originalCodePage;
}; };
} }

View File

@ -66,7 +66,7 @@ ClientFeature::ClientFeature(
_warnConnect(true), _warnConnect(true),
_haveServerPassword(false), _haveServerPassword(false),
_codePage(65001), // default to UTF8 _codePage(65001), // default to UTF8
_originalCodePage(-1) { _originalCodePage(UINT16_MAX) {
setOptional(true); setOptional(true);
requiresElevatedPrivileges(false); requiresElevatedPrivileges(false);
startsAfter("GreetingsPhase"); startsAfter("GreetingsPhase");
@ -311,14 +311,17 @@ std::vector<std::string> ClientFeature::httpEndpoints() {
void ClientFeature::start() { void ClientFeature::start() {
#if _WIN32 #if _WIN32
_originalCodePage = GetConsoleOutputCP(); _originalCodePage = GetConsoleOutputCP();
if (IsValidCodePage(_codePage)) {
SetConsoleOutputCP(_codePage); SetConsoleOutputCP(_codePage);
}
#endif #endif
} }
void ClientFeature::stop() { void ClientFeature::stop() {
#if _WIN32 #if _WIN32
if (IsValidCodePage(_originalCodePage)) {
SetConsoleOutputCP(_originalCodePage); SetConsoleOutputCP(_originalCodePage);
}
#endif #endif
} }

View File

@ -71,7 +71,9 @@ void* LanguageFeature::prepareIcu(std::string const& binaryPath,
std::string& path, std::string& path,
std::string const& binaryName) { std::string const& binaryName) {
std::string fn("icudtl.dat"); std::string fn("icudtl.dat");
TRI_GETENV("ICU_DATA", path); if (TRI_GETENV("ICU_DATA", path)) {
path = FileUtils::buildFilename(path, fn);
}
if (path.empty() || !TRI_IsRegularFile(path.c_str())) { if (path.empty() || !TRI_IsRegularFile(path.c_str())) {
if (!path.empty()) { if (!path.empty()) {
LOG_TOPIC(WARN, arangodb::Logger::FIXME) LOG_TOPIC(WARN, arangodb::Logger::FIXME)