diff options
author | Remko Tronçon <git@el-tramo.be> | 2013-05-15 19:44:37 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2013-05-17 19:00:55 (GMT) |
commit | de39ce6ec44647cee92853e2928cf5475af992e6 (patch) | |
tree | 1f86dd075900aeeb9b91cdd120d71052458ca6ff /Swiften/Config | |
parent | 927d62cc54c8a5087dba6b61afa9ad30dc528a23 (diff) | |
download | swift-de39ce6ec44647cee92853e2928cf5475af992e6.zip swift-de39ce6ec44647cee92853e2928cf5475af992e6.tar.bz2 |
Fixed unicode path handling.
- Use boost::filesystem::path consistently for referring to files.
- Use boost::filesystem streams for I/O, such that paths are always handled
correctly.
- Use stringToPath and pathToString for conversion between strings and
boost::filesystem::path, to ensure we have consistent unicode handling
across platforms and environments. The default constructor and string
conversion uses platform-dependent encoding, depending on the global
locale set in the application, which causes problems. So, unless you are
in platform dependent code, the default constructor and string() function
should not be used. When constructing paths from other paths (e.g. using
operator/), also use stringToPath (instead of string arguments) if the path
can contain unicode characters.
Change-Id: If286bd9e71c8414afc0b24ba67e26ab7608ef6ea
Diffstat (limited to 'Swiften/Config')
-rw-r--r-- | Swiften/Config/SConscript | 8 | ||||
-rw-r--r-- | Swiften/Config/swiften-config.cpp | 9 |
2 files changed, 12 insertions, 5 deletions
diff --git a/Swiften/Config/SConscript b/Swiften/Config/SConscript index 27dfc2e..837884b 100644 --- a/Swiften/Config/SConscript +++ b/Swiften/Config/SConscript @@ -37,12 +37,18 @@ config_flags += cStringVariable(swiften_env, "LIBFLAGS", libflags) config_env = env.Clone() # Create a local copy of Paths.cpp to avoid a Swiften dependency -config_env.Install(".", "#/Swiften/Base/Paths.cpp") +config_env.Install(".", [ + "#/Swiften/Base/Paths.cpp", + "#/Swiften/Base/Path.cpp", + "#/Swiften/Base/String.cpp", +]) config_env.UseFlags(config_env["BOOST_FLAGS"]) config_env.UseFlags(config_env["PLATFORM_FLAGS"]) config_env.WriteVal("swiften-config.h", config_env.Value(config_flags)) swiften_config = config_env.Program("swiften-config", [ "Paths.cpp", + "Path.cpp", + "String.cpp", "swiften-config.cpp" ]) diff --git a/Swiften/Config/swiften-config.cpp b/Swiften/Config/swiften-config.cpp index 89df9cd..778134d 100644 --- a/Swiften/Config/swiften-config.cpp +++ b/Swiften/Config/swiften-config.cpp @@ -16,6 +16,7 @@ #include <Swiften/Base/Platform.h> #include <Swiften/Base/Paths.h> +#include <Swiften/Base/Path.h> #include <Swiften/Version.h> #include "swiften-config.h" @@ -90,12 +91,12 @@ int main(int argc, char* argv[]) { for(size_t i = 0; i < libs.size(); ++i) { if (inPlace) { std::string lib = libs[i]; - boost::replace_all(lib, "#", topSourcePath.string()); + boost::replace_all(lib, "#", pathToString(topSourcePath)); libs[i] = lib; } else { std::string lib = libs[i]; - boost::replace_all(lib, "#", (topInstallPath / "lib").string()); + boost::replace_all(lib, "#", pathToString(topInstallPath / "lib")); boost::erase_all(lib, "/Swiften"); libs[i] = lib; } @@ -103,12 +104,12 @@ int main(int argc, char* argv[]) { for(size_t i = 0; i < cflags.size(); ++i) { if (inPlace) { std::string cflag = cflags[i]; - boost::replace_all(cflag, "#", topSourcePath.string()); + boost::replace_all(cflag, "#", pathToString(topSourcePath)); cflags[i] = cflag; } else { std::string cflag = cflags[i]; - boost::replace_all(cflag, "#", (topInstallPath / "include").string()); + boost::replace_all(cflag, "#", pathToString(topInstallPath / "include")); cflags[i] = cflag; } } |