Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84146 - in trunk/tools/quickbook: doc src
From: dnljms_at_[hidden]
Date: 2013-05-05 09:44:59


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

Log:
Make escaping dependent file names optional.
Text files modified:
   trunk/tools/quickbook/doc/change_log.qbk | 2 +
   trunk/tools/quickbook/src/dependency_tracker.cpp | 41 ++++++++++++++++++------------
   trunk/tools/quickbook/src/dependency_tracker.hpp | 9 +++++-
   trunk/tools/quickbook/src/quickbook.cpp | 53 ++++++++++++++++++++++++++++++++++++---
   4 files changed, 83 insertions(+), 22 deletions(-)

Modified: trunk/tools/quickbook/doc/change_log.qbk
==============================================================================
--- trunk/tools/quickbook/doc/change_log.qbk (original)
+++ trunk/tools/quickbook/doc/change_log.qbk 2013-05-05 09:44:59 EDT (Sun, 05 May 2013)
@@ -281,6 +281,8 @@
   convert indentation to spaces.
 * Support the token pasting operator (`##`) in C++ code blocks
   ([@https://svn.boost.org/trac/boost/ticket/8510 #8510]).
+* Hidden options for formatting of `--output-deps`. Not really for public use
+* yet.
 * 1.6 changes:
   * Better template argument parsing, so that it understands things
     like escaped markup.

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:59 EDT (Sun, 05 May 2013)
@@ -63,16 +63,15 @@
         "\\f", "\\r", "\\016", "\\017"
     };
 
- static std::string escaped_path(fs::path const& path)
+ static std::string escaped_path(std::string const& generic)
     {
- 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];
+ if (c >= 0 && c < 16) {
+ result += control_escapes[(unsigned int) c];
             }
             else if (c == '\\') {
                 result += "\\\\";
@@ -88,28 +87,38 @@
         return result;
     }
 
+ static std::string get_path(fs::path const& path,
+ dependency_tracker::flags f)
+ {
+ std::string generic = detail::path_to_generic(path);
+
+ if (f & dependency_tracker::escaped) {
+ generic = escaped_path(generic);
+ }
+
+ return generic;
+ }
+
     bool dependency_tracker::add_dependency(fs::path const& f) {
         bool found = fs::exists(fs::status(f));
         dependencies[normalize_path(f)] |= found;
         return found;
     }
 
- void dependency_tracker::write_dependencies(std::ostream& out)
+ void dependency_tracker::write_dependencies(std::ostream& out,
+ flags f)
     {
         BOOST_FOREACH(dependency_list::value_type const& d, dependencies)
         {
- if (d.second) {
- out << escaped_path(d.first) << std::endl;
+ if (f & checked) {
+ out << (d.second ? "+ " : "- ")
+ << get_path(d.first, f) << std::endl;
+ }
+ else {
+ if (d.second) {
+ out << get_path(d.first, f) << std::endl;
+ }
             }
- }
- }
-
- void dependency_tracker::write_checked_locations(std::ostream& out)
- {
- BOOST_FOREACH(dependency_list::value_type const& d, dependencies)
- {
- out << (d.second ? "+ " : "- ")
- << escaped_path(d.first) << std::endl;
         }
     }
 }

Modified: trunk/tools/quickbook/src/dependency_tracker.hpp
==============================================================================
--- trunk/tools/quickbook/src/dependency_tracker.hpp (original)
+++ trunk/tools/quickbook/src/dependency_tracker.hpp 2013-05-05 09:44:59 EDT (Sun, 05 May 2013)
@@ -25,12 +25,17 @@
 
     public:
 
+ enum flags {
+ default_ = 0,
+ checked = 1,
+ escaped = 2
+ };
+
         // Call this before loading any file so that it will be included in the
         // list of dependencies. Returns true if file exists.
         bool add_dependency(fs::path const&);
 
- void write_dependencies(std::ostream&);
- void write_checked_locations(std::ostream&);
+ void write_dependencies(std::ostream&, flags = default_);
     };
 }
 

Modified: trunk/tools/quickbook/src/quickbook.cpp
==============================================================================
--- trunk/tools/quickbook/src/quickbook.cpp (original)
+++ trunk/tools/quickbook/src/quickbook.cpp 2013-05-05 09:44:59 EDT (Sun, 05 May 2013)
@@ -24,6 +24,8 @@
 #include <boost/ref.hpp>
 #include <boost/version.hpp>
 #include <boost/foreach.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
 
 #include <stdexcept>
 #include <vector>
@@ -116,13 +118,15 @@
         parse_document_options() :
             indent(-1),
             linewidth(-1),
- pretty_print(true)
+ pretty_print(true),
+ deps_out_flags(quickbook::dependency_tracker::default_)
         {}
 
         int indent;
         int linewidth;
         bool pretty_print;
         fs::path deps_out;
+ quickbook::dependency_tracker::flags deps_out_flags;
         fs::path locations_out;
         fs::path xinclude_base;
     };
@@ -159,13 +163,15 @@
             if (!options_.deps_out.empty())
             {
                 fs::ofstream out(options_.deps_out);
- state.dependencies.write_dependencies(out);
+ state.dependencies.write_dependencies(out,
+ options_.deps_out_flags);
             }
 
             if (!options_.locations_out.empty())
             {
                 fs::ofstream out(options_.locations_out);
- state.dependencies.write_checked_locations(out);
+ state.dependencies.write_dependencies(out,
+ dependency_tracker::checked);
             }
         }
         catch (load_error& e) {
@@ -291,10 +297,15 @@
             ("xinclude-base", PO_VALUE<input_string>(),
                 "Generate xincludes as if generating for this target "
                 "directory.")
+ ("output-deps-format", PO_VALUE<input_string>(),
+ "Comma separated list of formatting options for output-deps, "
+ "options are: escaped, checked")
             ("output-checked-locations", PO_VALUE<input_string>(),
              "Writes a file listing all the file locations that were "
              "checked, starting with '+' if they were found, or '-' "
- "if they weren't.")
+ "if they weren't.\n"
+ "This is deprecated, use 'output-deps-format=checked' to "
+ "write the deps file in this format.")
         ;
 
         all.add(desc).add(hidden);
@@ -437,6 +448,40 @@
                 default_output = false;
             }
 
+ if (vm.count("output-deps-format"))
+ {
+ std::string format_flags =
+ quickbook::detail::input_to_utf8(
+ vm["output-deps-format"].as<input_string>());
+
+ std::vector<std::string> flag_names;
+ boost::algorithm::split(flag_names, format_flags,
+ boost::algorithm::is_any_of(", "),
+ boost::algorithm::token_compress_on);
+
+ unsigned flags = 0;
+
+ BOOST_FOREACH(std::string const& flag, flag_names) {
+ if (flag == "checked") {
+ flags |= quickbook::dependency_tracker::checked;
+ }
+ else if (flag == "escaped") {
+ flags |= quickbook::dependency_tracker::escaped;
+ }
+ else if (!flag.empty()) {
+ quickbook::detail::outerr()
+ << "Unknown dependency format flag: "
+ << flag
+ <<std::endl;
+
+ ++error_count;
+ }
+ }
+
+ parse_document_options.deps_out_flags =
+ quickbook::dependency_tracker::flags(flags);
+ }
+
             if (vm.count("output-checked-locations"))
             {
                 parse_document_options.locations_out =


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