mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 09:15:38 +00:00
Fixed windows build and updated tests to reflect changes of escape character from "&" to "\"
This commit is contained in:
parent
4bb07282c9
commit
cd229a965b
3 changed files with 18 additions and 16 deletions
|
@ -52,7 +52,8 @@ private:
|
|||
int wmain(int argc, wchar_t *wargv[]) {
|
||||
utf8argv converter(argc, wargv);
|
||||
char **argv = converter.get();
|
||||
std::filesystem::path::imbue(boost::locale::generator().generate(""));
|
||||
// TODO(Project579): Temporarly disabled until a good solution is found (no solution might actually be needed)
|
||||
//std::filesystem::path::imbue(boost::locale::generator().generate(""));
|
||||
#endif
|
||||
|
||||
try
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace
|
|||
std::vector<std::string> result;
|
||||
(result.emplace_back(makeString(args)) , ...);
|
||||
for (int i = 1; i <= std::numeric_limits<char>::max(); ++i)
|
||||
if (i != '&' && i != '"' && i != ' ' && i != '\n')
|
||||
if (i != '\\' && i != '"' && i != ' ' && i != '\n')
|
||||
result.push_back(std::string(1, i));
|
||||
return result;
|
||||
}
|
||||
|
@ -127,22 +127,22 @@ namespace
|
|||
EXPECT_EQ(variables["load-savegame"].as<Files::MaybeQuotedPath>().string(), R"(save)");
|
||||
}
|
||||
|
||||
TEST(OpenMWOptionsFromArguments, should_support_quoted_load_savegame_path_with_escaped_quote_by_ampersand)
|
||||
TEST(OpenMWOptionsFromArguments, should_support_quoted_load_savegame_path_with_escaped_quote)
|
||||
{
|
||||
bpo::options_description description = makeOptionsDescription();
|
||||
const std::array arguments {"openmw", "--load-savegame", R"("save&".omwsave")"};
|
||||
const std::array arguments {"openmw", "--load-savegame", R"("save\".omwsave")"};
|
||||
bpo::variables_map variables;
|
||||
parseArgs(arguments, variables, description);
|
||||
EXPECT_EQ(variables["load-savegame"].as<Files::MaybeQuotedPath>().string(), R"(save".omwsave)");
|
||||
}
|
||||
|
||||
TEST(OpenMWOptionsFromArguments, should_support_quoted_load_savegame_path_with_escaped_ampersand)
|
||||
TEST(OpenMWOptionsFromArguments, should_support_quoted_load_savegame_path_with_escaped_backslash)
|
||||
{
|
||||
bpo::options_description description = makeOptionsDescription();
|
||||
const std::array arguments {"openmw", "--load-savegame", R"("save.omwsave&&")"};
|
||||
const std::array arguments {"openmw", "--load-savegame", R"("save.omwsave\\")"};
|
||||
bpo::variables_map variables;
|
||||
parseArgs(arguments, variables, description);
|
||||
EXPECT_EQ(variables["load-savegame"].as<Files::MaybeQuotedPath>().string(), "save.omwsave&");
|
||||
EXPECT_EQ(variables["load-savegame"].as<Files::MaybeQuotedPath>().string(), R"(save.omwsave\)");
|
||||
}
|
||||
|
||||
TEST(OpenMWOptionsFromArguments, should_support_load_savegame_path_with_ampersand)
|
||||
|
@ -274,7 +274,7 @@ namespace
|
|||
TEST(OpenMWOptionsFromConfig, should_support_confusing_savegame_path_with_lots_going_on)
|
||||
{
|
||||
bpo::options_description description = makeOptionsDescription();
|
||||
std::istringstream stream(R"(load-savegame="one &"two"three".omwsave")");
|
||||
std::istringstream stream(R"(load-savegame="one \"two"three".omwsave")");
|
||||
bpo::variables_map variables;
|
||||
Files::parseConfig(stream, variables, description);
|
||||
EXPECT_EQ(variables["load-savegame"].as<Files::MaybeQuotedPath>().string(), R"(one "two)");
|
||||
|
@ -283,7 +283,7 @@ namespace
|
|||
TEST(OpenMWOptionsFromConfig, should_support_confusing_savegame_path_with_even_more_going_on)
|
||||
{
|
||||
bpo::options_description description = makeOptionsDescription();
|
||||
std::istringstream stream(R"(load-savegame="one &"two"three ".omwsave")");
|
||||
std::istringstream stream(R"(load-savegame="one \"two"three ".omwsave")");
|
||||
bpo::variables_map variables;
|
||||
Files::parseConfig(stream, variables, description);
|
||||
EXPECT_EQ(variables["load-savegame"].as<Files::MaybeQuotedPath>().string(), R"(one "two)");
|
||||
|
@ -351,22 +351,22 @@ namespace
|
|||
EXPECT_THAT(variables["data"].as<Files::MaybeQuotedPathContainer>(), ElementsAre(IsPath("1"), IsPath("2")));
|
||||
}
|
||||
|
||||
TEST(OpenMWOptionsFromConfig, should_support_quoted_load_savegame_path_with_escaped_quote_by_ampersand)
|
||||
TEST(OpenMWOptionsFromConfig, should_support_quoted_load_savegame_path_with_escaped_quote)
|
||||
{
|
||||
bpo::options_description description = makeOptionsDescription();
|
||||
std::istringstream stream(R"(load-savegame="save&".omwsave")");
|
||||
std::istringstream stream(R"(load-savegame="save\".omwsave")");
|
||||
bpo::variables_map variables;
|
||||
Files::parseConfig(stream, variables, description);
|
||||
EXPECT_EQ(variables["load-savegame"].as<Files::MaybeQuotedPath>().string(), R"(save".omwsave)");
|
||||
}
|
||||
|
||||
TEST(OpenMWOptionsFromConfig, should_support_quoted_load_savegame_path_with_escaped_ampersand)
|
||||
TEST(OpenMWOptionsFromConfig, should_support_quoted_load_savegame_path_with_escaped_backslash)
|
||||
{
|
||||
bpo::options_description description = makeOptionsDescription();
|
||||
std::istringstream stream(R"(load-savegame="save.omwsave&&")");
|
||||
std::istringstream stream(R"(load-savegame="save.omwsave\\")");
|
||||
bpo::variables_map variables;
|
||||
Files::parseConfig(stream, variables, description);
|
||||
EXPECT_EQ(variables["load-savegame"].as<Files::MaybeQuotedPath>().string(), "save.omwsave&");
|
||||
EXPECT_EQ(variables["load-savegame"].as<Files::MaybeQuotedPath>().string(), R"(save.omwsave\)");
|
||||
}
|
||||
|
||||
TEST(OpenMWOptionsFromConfig, should_support_load_savegame_path_with_ampersand)
|
||||
|
|
|
@ -40,7 +40,8 @@ WindowsPath::WindowsPath(const std::string& application_name)
|
|||
|
||||
See std::filesystem and boost::locale reference for details.
|
||||
*/
|
||||
std::filesystem::path::imbue(boost::locale::generator().generate(""));
|
||||
// TODO(Project579): Temporarly disabled until a good solution is found (no solution might actually be needed)
|
||||
//std::filesystem::path::imbue(boost::locale::generator().generate(""));
|
||||
|
||||
std::filesystem::path localPath = getLocalPath();
|
||||
if (!SetCurrentDirectoryA(localPath.string().c_str()))
|
||||
|
@ -91,7 +92,7 @@ std::filesystem::path WindowsPath::getLocalPath() const
|
|||
|
||||
if (GetModuleFileNameW(nullptr, path, MAX_PATH + 1) > 0)
|
||||
{
|
||||
localPath = std::filesystem::path(bconv::utf_to_utf<char>(path)).parent_path() / "/";
|
||||
localPath = std::filesystem::path(bconv::utf_to_utf<char>(path)).parent_path().string() + "/";
|
||||
}
|
||||
|
||||
// lookup exe path
|
||||
|
|
Loading…
Reference in a new issue