summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-04-11 18:19:17 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-04-11 19:20:07 (GMT)
commit857e44c156a1dbefcb49bb5792c4384cebd8762a (patch)
tree11947fb81ad9c502627f1b2bb8f090fb8d53c107 /3rdParty/Boost/src/tools/bcp/copy_path.cpp
parent77d4eb7588e113beaa03f3347523b26adefdeb06 (diff)
downloadswift-contrib-857e44c156a1dbefcb49bb5792c4384cebd8762a.zip
swift-contrib-857e44c156a1dbefcb49bb5792c4384cebd8762a.tar.bz2
Updated Boost to 1.42.
Diffstat (limited to '3rdParty/Boost/src/tools/bcp/copy_path.cpp')
-rw-r--r--3rdParty/Boost/src/tools/bcp/copy_path.cpp142
1 files changed, 141 insertions, 1 deletions
diff --git a/3rdParty/Boost/src/tools/bcp/copy_path.cpp b/3rdParty/Boost/src/tools/bcp/copy_path.cpp
index c976865..af99b62 100644
--- a/3rdParty/Boost/src/tools/bcp/copy_path.cpp
+++ b/3rdParty/Boost/src/tools/bcp/copy_path.cpp
@@ -11,12 +11,36 @@
*/
#include "bcp_imp.hpp"
+#include "fileview.hpp"
#include <boost/filesystem/operations.hpp>
+#include <boost/regex.hpp>
#include <fstream>
#include <iterator>
#include <algorithm>
#include <iostream>
+struct get_new_library_name
+{
+ get_new_library_name(const std::string& n) : m_new_name(n) {}
+ template <class I>
+ std::string operator()(const boost::match_results<I>& what)
+ {
+ std::string s = what[0];
+ std::string::size_type n = s.find("boost");
+ if(n == std::string::npos)
+ {
+ s.insert(0, m_new_name);
+ }
+ else
+ {
+ s.replace(n, 5, m_new_name);
+ }
+ return s;
+ }
+private:
+ std::string m_new_name;
+};
+
void bcp_implementation::copy_path(const fs::path& p)
{
assert(!fs::is_directory(m_boost_path / p));
@@ -34,7 +58,123 @@ void bcp_implementation::copy_path(const fs::path& p)
//
// do text based copy if requested:
//
- if(m_unix_lines && !is_binary_file(p))
+ if(m_namespace_name.size() && m_lib_names.size() && is_jam_file(p))
+ {
+ static std::vector<char> v1, v2;
+ v1.clear();
+ v2.clear();
+ std::ifstream is((m_boost_path / p).native_file_string().c_str());
+ std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1));
+
+ static boost::regex libname_matcher;
+ if(libname_matcher.empty())
+ {
+ std::string re = "\\<";
+ re += *m_lib_names.begin();
+ for(std::set<std::string>::const_iterator i = ++m_lib_names.begin(); i != m_lib_names.end(); ++i)
+ {
+ re += "|" + *i;
+ }
+ re += "\\>";
+ libname_matcher.assign(re);
+ }
+
+ regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), libname_matcher, get_new_library_name(m_namespace_name));
+ std::swap(v1, v2);
+ v2.clear();
+
+ std::ofstream os;
+ if(m_unix_lines)
+ os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::binary | std::ios_base::out);
+ else
+ os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::out);
+ os.write(&*v1.begin(), v1.size());
+ os.close();
+ }
+ else if(m_namespace_name.size() && is_source_file(p))
+ {
+ //
+ // v1 hold the current content, v2 is temp buffer.
+ // Each time we do a search and replace the new content
+ // ends up in v2: we then swap v1 and v2, and clear v2.
+ //
+ static std::vector<char> v1, v2;
+ v1.clear();
+ v2.clear();
+ std::ifstream is((m_boost_path / p).native_file_string().c_str());
+ std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1));
+
+ static const boost::regex namespace_matcher(
+ "(?|"
+ "(namespace\\s+)boost(_\\w+)?"
+ "|"
+ "(namespace\\s+)(adstl|phoenix|rapidxml)\\>"
+ "|"
+ "()boost((?:_\\w+)?\\s*(?:::|,|\\)))"
+ "|"
+ "()((?:adstl|phoenix|rapidxml)\\s*(?:::|,|\\)))"
+ "|"
+ "(namespace\\s+\\w+\\s*=\\s*(?:::\\s*)?)boost(_\\w+)?"
+ "|"
+ "(namespace\\s+\\w+\\s*=\\s*(?:::\\s*)?)(adstl|phoenix|rapidxml)\\>"
+ "|"
+ "(^\\s*#\\s*define[^\\n]+)boost((?:_\\w+)?\\s*)$"
+ "|"
+ "(^\\s*#\\s*define[^\\n]+)((?:adstl|phoenix|rapidxml)\\s*)$"
+ ")"
+ );
+
+ regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), namespace_matcher, "$1" + m_namespace_name + "$2");
+ std::swap(v1, v2);
+ v2.clear();
+
+ if(m_namespace_alias)
+ {
+ static const boost::regex namespace_alias(
+ /*
+ "namespace\\s+" + m_namespace_name +
+ "\\s*"
+ "("
+ "\\{"
+ "(?:"
+ "(?>[^\\{\\}/]+)"
+ "(?>"
+ "(?:"
+ "(?1)"
+ "|//[^\\n]+$"
+ "|/[^/]"
+ "|(?:^\\s*#[^\\n]*"
+ "(?:(?<=\\\\)\\n[^\\n]*)*)"
+ ")"
+ "[^\\{\\}]+"
+ ")*"
+ ")*"
+ "\\}"
+ ")"
+ */
+ /*
+ "(namespace\\s+" + m_namespace_name +
+ "\\s*\\{.*"
+ "\\})([^\\{\\};]*)\\z"
+ */
+ "namespace\\s+" + m_namespace_name +
+ "\\s*\\{"
+ );
+ regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), namespace_alias,
+ "namespace " + m_namespace_name + "{} namespace boost = " + m_namespace_name + "; namespace " + m_namespace_name + "{");
+ std::swap(v1, v2);
+ v2.clear();
+ }
+
+ std::ofstream os;
+ if(m_unix_lines)
+ os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::binary | std::ios_base::out);
+ else
+ os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::out);
+ os.write(&*v1.begin(), v1.size());
+ os.close();
+ }
+ else if(m_unix_lines && !is_binary_file(p))
{
std::ifstream is((m_boost_path / p).native_file_string().c_str());
std::istreambuf_iterator<char> isi(is);