Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84145 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2013-05-05 09:44:34


Author: danieljames
Date: 2013-05-05 09:44:33 EDT (Sun, 05 May 2013)
New Revision: 84145
URL: http://svn.boost.org/trac/boost/changeset/84145

Log:
Escape paths in dependency list - I want to make this optional.
Text files modified:
   trunk/tools/quickbook/src/dependency_tracker.cpp | 36 ++++++++++++++++++++++++++++++++++--
   1 files changed, 34 insertions(+), 2 deletions(-)

Modified: trunk/tools/quickbook/src/dependency_tracker.cpp
==============================================================================
--- trunk/tools/quickbook/src/dependency_tracker.cpp (original)
+++ trunk/tools/quickbook/src/dependency_tracker.cpp 2013-05-05 09:44:33 EDT (Sun, 05 May 2013)
@@ -56,6 +56,38 @@
         return fs::canonical(p) / extra;
     }
 
+ static char const* control_escapes[16] = {
+ "\\000", "\\001", "\\002", "\\003",
+ "\\004", "\\005", "\\006", "\\a",
+ "\\b", "\\t", "\\n", "\\v",
+ "\\f", "\\r", "\\016", "\\017"
+ };
+
+ static std::string escaped_path(fs::path const& path)
+ {
+ std::string generic = detail::path_to_generic(path);
+ std::string result;
+ result.reserve(generic.size());
+
+ BOOST_FOREACH(char c, generic)
+ {
+ if (c < 16) {
+ result += control_escapes[c];
+ }
+ else if (c == '\\') {
+ result += "\\\\";
+ }
+ else if (c == 127) {
+ result += "\\177";
+ }
+ else {
+ result += c;
+ }
+ }
+
+ return result;
+ }
+
     bool dependency_tracker::add_dependency(fs::path const& f) {
         bool found = fs::exists(fs::status(f));
         dependencies[normalize_path(f)] |= found;
@@ -67,7 +99,7 @@
         BOOST_FOREACH(dependency_list::value_type const& d, dependencies)
         {
             if (d.second) {
- out << detail::path_to_generic(d.first) << std::endl;
+ out << escaped_path(d.first) << std::endl;
             }
         }
     }
@@ -77,7 +109,7 @@
         BOOST_FOREACH(dependency_list::value_type const& d, dependencies)
         {
             out << (d.second ? "+ " : "- ")
- << detail::path_to_generic(d.first) << std::endl;
+ << escaped_path(d.first) << std::endl;
         }
     }
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk