diff --git a/.travis.yml b/.travis.yml index 719d9431..d654c2e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,20 +12,18 @@ addons: - libhttp-parser-dev - libssh2-1-dev - libicu-dev + - language-pack-el + - language-pack-tr - gcc-8 - g++-8 cache: - directories: - - $HOME/boost_1_67_0/boost - - $HOME/boost_1_67_0/stage/64/lib cargo: true install: - export CXX="g++-8" CC="gcc-8" - # Build Boost. - - wget https://raw.githubusercontent.com/Ortham/ci-scripts/2.1.2/install_boost.py - - python3 install_boost.py --directory ~ --boost-version 1.67.0 -a 64 -t gcc-8 locale system + # Get Boost. + - curl -fsSL 'https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2' | tar -xj -C "$HOME" # Install packages for generating documentation - pyenv install 3.6.3 - pyenv global 3.6.3 @@ -43,7 +41,7 @@ before_script: - mkdir build - cd build # Link dynamically to the C++ standard library runtime. - - cmake .. -DBOOST_ROOT=~/boost_1_67_0 -DBOOST_LIBRARYDIR=~/boost_1_67_0/stage/64/lib + - cmake .. -DBOOST_ROOT=~/boost_1_67_0 script: - make all diff --git a/CMakeLists.txt b/CMakeLists.txt index 68a8587b..74742c10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ ELSE () set(RUST_TARGET x86_64-unknown-linux-gnu) ENDIF () -find_package(Boost REQUIRED COMPONENTS locale system) +find_package(Boost REQUIRED) if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") find_package(ICU REQUIRED COMPONENTS uc) @@ -396,12 +396,12 @@ ENDIF () # Build tests. add_executable (libloot_internals_tests ${LIBLOOT_SRC} ${LIBLOOT_HEADERS} ${LOOT_TESTS_SRC} ${LOOT_TESTS_HEADERS}) add_dependencies (libloot_internals_tests esplugin libgit2 libloadorder loot-condition-interpreter spdlog yaml-cpp GTest testing-metadata testing-plugins) -target_link_libraries(libloot_internals_tests ${Boost_LIBRARIES} ${LIBGIT2_LIBRARIES} ${ESPLUGIN_LIBRARIES} ${LIBLOADORDER_LIBRARIES} ${LOOT_LIBS} ${LCI_LIBRARIES} ${YAML_CPP_LIBRARIES} ${GTEST_LIBRARIES} ${ICU_LIBRARIES}) +target_link_libraries(libloot_internals_tests ${LIBGIT2_LIBRARIES} ${ESPLUGIN_LIBRARIES} ${LIBLOADORDER_LIBRARIES} ${LOOT_LIBS} ${LCI_LIBRARIES} ${YAML_CPP_LIBRARIES} ${GTEST_LIBRARIES} ${ICU_LIBRARIES}) # Build API. add_library (loot ${LIBLOOT_SRC} ${LIBLOOT_HEADERS}) add_dependencies (loot esplugin libgit2 libloadorder loot-condition-interpreter spdlog yaml-cpp) -target_link_libraries(loot ${Boost_LIBRARIES} ${LIBGIT2_LIBRARIES} ${ESPLUGIN_LIBRARIES} ${LIBLOADORDER_LIBRARIES} ${LOOT_LIBS} ${LCI_LIBRARIES} ${YAML_CPP_LIBRARIES} ${ICU_LIBRARIES}) +target_link_libraries(loot ${LIBGIT2_LIBRARIES} ${ESPLUGIN_LIBRARIES} ${LIBLOADORDER_LIBRARIES} ${LOOT_LIBS} ${LCI_LIBRARIES} ${YAML_CPP_LIBRARIES} ${ICU_LIBRARIES}) # Build API tests. add_executable (libloot_tests ${LIBLOOT_TESTS_SRC} ${LIBLOOT_TESTS_HEADERS}) diff --git a/docs/api/reference.rst b/docs/api/reference.rst index e3a35f60..59256c43 100644 --- a/docs/api/reference.rst +++ b/docs/api/reference.rst @@ -31,8 +31,6 @@ Functions .. doxygenfunction:: loot::IsCompatible -.. doxygenfunction:: loot::InitialiseLocale - .. doxygenfunction:: loot::CreateGameHandle Interfaces diff --git a/include/loot/api.h b/include/loot/api.h index 4750390d..7af5ac3c 100644 --- a/include/loot/api.h +++ b/include/loot/api.h @@ -96,16 +96,6 @@ LOOT_API bool IsCompatible(const unsigned int major, *************************************************************************/ /**@{*/ -/** - * Initialise the current global locale using the given ID. - * - * This sets the global locale up so that the library's UTF-8 support can - * function. - * @param id A locale ID. The default value is a blank string, which will - * use the system default locale. - */ -LOOT_API void InitialiseLocale(const std::string& id = ""); - /** * @brief Initialise a new game handle. * @details Creates a handle for a game, which is then used by all diff --git a/src/api/api.cpp b/src/api/api.cpp index 8644a84d..5aa7d14e 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -26,8 +26,6 @@ #include -#include - #include "api/game/game.h" #include "api/helpers/logging.h" @@ -74,10 +72,6 @@ LOOT_API bool IsCompatible(const unsigned int versionMajor, return versionMinor == loot::LootVersion::minor; } -LOOT_API void InitialiseLocale(const std::string& id) { - std::locale::global(boost::locale::generator().generate(id)); -} - LOOT_API std::shared_ptr CreateGameHandle( const GameType game, const std::filesystem::path& gamePath, diff --git a/src/api/game/game_cache.cpp b/src/api/game/game_cache.cpp index 3e2c402c..8a8f2f2d 100644 --- a/src/api/game/game_cache.cpp +++ b/src/api/game/game_cache.cpp @@ -26,8 +26,6 @@ #include -#include - #include "api/helpers/text.h" using std::lock_guard; diff --git a/src/api/metadata/file.cpp b/src/api/metadata/file.cpp index 667ec639..db906aed 100644 --- a/src/api/metadata/file.cpp +++ b/src/api/metadata/file.cpp @@ -24,8 +24,6 @@ #include "loot/metadata/file.h" -#include - #include "api/metadata/yaml/file.h" #include "api/helpers/text.h" diff --git a/src/api/metadata/plugin_metadata.cpp b/src/api/metadata/plugin_metadata.cpp index 39a41fb8..0419c89e 100644 --- a/src/api/metadata/plugin_metadata.cpp +++ b/src/api/metadata/plugin_metadata.cpp @@ -28,7 +28,6 @@ #include #include -#include #include "api/game/game.h" #include "api/helpers/logging.h" diff --git a/src/api/plugin.cpp b/src/api/plugin.cpp index a205cd98..8ff733fb 100644 --- a/src/api/plugin.cpp +++ b/src/api/plugin.cpp @@ -27,7 +27,6 @@ #include #include -#include #include "api/game/game.h" #include "api/helpers/crc.h" diff --git a/src/api/sorting/plugin_sorter.cpp b/src/api/sorting/plugin_sorter.cpp index 3df2bdb0..50e3bf0a 100644 --- a/src/api/sorting/plugin_sorter.cpp +++ b/src/api/sorting/plugin_sorter.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include "api/game/game.h" #include "api/helpers/logging.h" diff --git a/src/api/sorting/plugin_sorting_data.cpp b/src/api/sorting/plugin_sorting_data.cpp index 3126fc92..671957f0 100644 --- a/src/api/sorting/plugin_sorting_data.cpp +++ b/src/api/sorting/plugin_sorting_data.cpp @@ -25,7 +25,6 @@ #include "plugin_sorting_data.h" #include -#include #include #include "api/helpers/text.h" diff --git a/src/tests/api/interface/main.cpp b/src/tests/api/interface/main.cpp index 2f9eb09e..a685edca 100644 --- a/src/tests/api/interface/main.cpp +++ b/src/tests/api/interface/main.cpp @@ -30,13 +30,7 @@ #include "tests/api/interface/game_interface_test.h" #include "tests/api/interface/is_compatible_test.h" -#include - int main(int argc, char **argv) { - // Set the locale to get encoding conversions working correctly. - std::locale::global(boost::locale::generator().generate("")); - loot::InitialiseLocale(""); - ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/src/tests/api/internals/helpers/text_test.h b/src/tests/api/internals/helpers/text_test.h index 2f93c751..9726c874 100644 --- a/src/tests/api/internals/helpers/text_test.h +++ b/src/tests/api/internals/helpers/text_test.h @@ -203,6 +203,15 @@ TEST(ExtractVersion, shouldExtractSingleDigitAfterVersionColonSpace) { TEST(CompareFilenames, shouldBeCaseInsensitiveAndLocaleInvariant) { // ICU sees all three greek rhos as case-insensitively equal, unlike Windows. // A small enough deviation that it should hopefully be insignificant. +#ifdef _WIN32 + const char * turkishLocale = "tr-TR"; + const char * greekLocale = "el-GR"; + const int expectedRhoSymbolOrder = 1; +#else + const char * turkishLocale = "tr_TR.UTF-8"; + const char * greekLocale = "el_GR.UTF-8"; + const int expectedRhoSymbolOrder = 0; +#endif EXPECT_EQ(0, CompareFilenames("i", "I")); EXPECT_EQ(-1, CompareFilenames("i", u8"\u0130")); @@ -210,17 +219,12 @@ TEST(CompareFilenames, shouldBeCaseInsensitiveAndLocaleInvariant) { EXPECT_EQ(-1, CompareFilenames("I", u8"\u0130")); EXPECT_EQ(-1, CompareFilenames("I", u8"\u0131")); EXPECT_EQ(-1, CompareFilenames(u8"\u0130", u8"\u0131")); -#ifdef _WIN32 - EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03a1")); - EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03c1")); -#else - EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03a1")); - EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03c1")); -#endif + EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03a1")); + EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03c1")); EXPECT_EQ(0, CompareFilenames(u8"\u03a1", u8"\u03c1")); // Set locale to Turkish. - std::locale::global(boost::locale::generator().generate("tr_TR.UTF-8")); + std::locale::global(std::locale(turkishLocale)); EXPECT_EQ(0, CompareFilenames("i", "I")); EXPECT_EQ(-1, CompareFilenames("i", u8"\u0130")); @@ -228,17 +232,12 @@ TEST(CompareFilenames, shouldBeCaseInsensitiveAndLocaleInvariant) { EXPECT_EQ(-1, CompareFilenames("I", u8"\u0130")); EXPECT_EQ(-1, CompareFilenames("I", u8"\u0131")); EXPECT_EQ(-1, CompareFilenames(u8"\u0130", u8"\u0131")); -#ifdef _WIN32 - EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03a1")); - EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03c1")); -#else - EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03a1")); - EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03c1")); -#endif + EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03a1")); + EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03c1")); EXPECT_EQ(0, CompareFilenames(u8"\u03a1", u8"\u03c1")); // Set locale to Greek. - std::locale::global(boost::locale::generator().generate("el_GR.UTF-8")); + std::locale::global(std::locale(greekLocale)); EXPECT_EQ(0, CompareFilenames("i", "I")); EXPECT_EQ(-1, CompareFilenames("i", u8"\u0130")); @@ -246,17 +245,12 @@ TEST(CompareFilenames, shouldBeCaseInsensitiveAndLocaleInvariant) { EXPECT_EQ(-1, CompareFilenames("I", u8"\u0130")); EXPECT_EQ(-1, CompareFilenames("I", u8"\u0131")); EXPECT_EQ(-1, CompareFilenames(u8"\u0130", u8"\u0131")); -#ifdef _WIN32 - EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03a1")); - EXPECT_EQ(1, CompareFilenames(u8"\u03f1", u8"\u03c1")); -#else - EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03a1")); - EXPECT_EQ(0, CompareFilenames(u8"\u03f1", u8"\u03c1")); -#endif + EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03a1")); + EXPECT_EQ(expectedRhoSymbolOrder, CompareFilenames(u8"\u03f1", u8"\u03c1")); EXPECT_EQ(0, CompareFilenames(u8"\u03a1", u8"\u03c1")); // Reset locale. - std::locale::global(boost::locale::generator().generate("")); + std::locale::global(std::locale::classic()); } #ifdef _WIN32 @@ -270,7 +264,7 @@ TEST(NormalizeFilename, shouldUppercaseStringsAndBeLocaleInvariant) { EXPECT_EQ(u8"\u03a1", NormalizeFilename(u8"\u03c1")); // Set locale to Turkish. - std::locale::global(boost::locale::generator().generate("tr_TR.UTF-8")); + std::locale::global(std::locale("tr-TR")); EXPECT_EQ("I", NormalizeFilename("i")); EXPECT_EQ("I", NormalizeFilename("I")); @@ -281,7 +275,7 @@ TEST(NormalizeFilename, shouldUppercaseStringsAndBeLocaleInvariant) { EXPECT_EQ(u8"\u03a1", NormalizeFilename(u8"\u03c1")); // Set locale to Greek. - std::locale::global(boost::locale::generator().generate("el_GR.UTF-8")); + std::locale::global(std::locale("el-GR")); EXPECT_EQ("I", NormalizeFilename("i")); EXPECT_EQ("I", NormalizeFilename("I")); @@ -292,7 +286,7 @@ TEST(NormalizeFilename, shouldUppercaseStringsAndBeLocaleInvariant) { EXPECT_EQ(u8"\u03a1", NormalizeFilename(u8"\u03c1")); // Reset locale. - std::locale::global(boost::locale::generator().generate("")); + std::locale::global(std::locale::classic()); } #else TEST(NormalizeFilename, shouldCaseFoldStringsAndBeLocaleInvariant) { @@ -310,7 +304,7 @@ TEST(NormalizeFilename, shouldCaseFoldStringsAndBeLocaleInvariant) { EXPECT_EQ(u8"\u03c1", NormalizeFilename(u8"\u03c1")); // Set locale to Turkish. - std::locale::global(boost::locale::generator().generate("tr_TR.UTF-8")); + std::locale::global(std::locale("tr_TR.UTF-8")); EXPECT_EQ("i", NormalizeFilename("i")); EXPECT_EQ("i", NormalizeFilename("I")); @@ -321,7 +315,7 @@ TEST(NormalizeFilename, shouldCaseFoldStringsAndBeLocaleInvariant) { EXPECT_EQ(u8"\u03c1", NormalizeFilename(u8"\u03c1")); // Set locale to Greek. - std::locale::global(boost::locale::generator().generate("el_GR.UTF-8")); + std::locale::global(std::locale("el_GR.UTF-8")); EXPECT_EQ("i", NormalizeFilename("i")); EXPECT_EQ("i", NormalizeFilename("I")); @@ -332,7 +326,7 @@ TEST(NormalizeFilename, shouldCaseFoldStringsAndBeLocaleInvariant) { EXPECT_EQ(u8"\u03c1", NormalizeFilename(u8"\u03c1")); // Reset locale. - std::locale::global(boost::locale::generator().generate("")); + std::locale::global(std::locale::classic()); } #endif } diff --git a/src/tests/api/internals/main.cpp b/src/tests/api/internals/main.cpp index 0ff1461f..a26d6cbd 100644 --- a/src/tests/api/internals/main.cpp +++ b/src/tests/api/internals/main.cpp @@ -22,8 +22,6 @@ . */ -#include - #include "tests/api/internals/game/game_cache_test.h" #include "tests/api/internals/game/game_test.h" #include "tests/api/internals/game/load_order_handler_test.h" @@ -276,9 +274,6 @@ TEST(Filesystem, canonicalShouldNotFoldCase) { #endif int main(int argc, char **argv) { - // Set the locale to get encoding conversions working correctly. - std::locale::global(boost::locale::generator().generate("")); - ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }