Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86702 - in trunk/tools/quickbook: src test/include
From: dnljms_at_[hidden]
Date: 2013-11-14 14:21:37


Author: danieljames
Date: 2013-11-14 14:21:37 EST (Thu, 14 Nov 2013)
New Revision: 86702
URL: http://svn.boost.org/trac/boost/changeset/86702

Log:
Fix the platform independent paths for globs.

Added:
   trunk/tools/quickbook/test/include/filename-1_7.gold (contents, props changed)
   trunk/tools/quickbook/test/include/filename-1_7.quickbook (contents, props changed)
   trunk/tools/quickbook/test/include/filename_path-1_7.gold (contents, props changed)
   trunk/tools/quickbook/test/include/filename_path-1_7.quickbook (contents, props changed)
Text files modified:
   trunk/tools/quickbook/src/include_paths.cpp | 51 +++++++++++++++++++++++++++------------
   trunk/tools/quickbook/src/include_paths.hpp | 2 +
   trunk/tools/quickbook/test/include/Jamfile.v2 | 2 +
   trunk/tools/quickbook/test/include/filename-1_7.gold | 18 ++++++++++++++
   trunk/tools/quickbook/test/include/filename-1_7.quickbook | 9 +++++++
   trunk/tools/quickbook/test/include/filename_path-1_7.gold | 18 ++++++++++++++
   trunk/tools/quickbook/test/include/filename_path-1_7.quickbook | 7 +++++
   7 files changed, 91 insertions(+), 16 deletions(-)

Modified: trunk/tools/quickbook/src/include_paths.cpp
==============================================================================
--- trunk/tools/quickbook/src/include_paths.cpp Thu Nov 14 14:21:04 2013 (r86701)
+++ trunk/tools/quickbook/src/include_paths.cpp 2013-11-14 14:21:37 EST (Thu, 14 Nov 2013) (r86702)
@@ -69,7 +69,8 @@
     //
 
     void include_search_glob(std::set<quickbook_path> & result,
- fs::path dir, std::string path, quickbook::state& state)
+ quickbook_path const& location,
+ std::string path, quickbook::state& state)
     {
         // Search for the first part of the path that contains glob
         // characters. (TODO: Account for escapes?)
@@ -78,11 +79,11 @@
 
         if (glob_pos == std::string::npos)
         {
- if (state.dependencies.add_dependency(dir / path))
+ quickbook_path complete_path = location / path;
+
+ if (state.dependencies.add_dependency(complete_path.file_path))
             {
- result.insert(quickbook_path(
- dir / path,
- state.abstract_file_path.parent_path() / path));
+ result.insert(complete_path);
             }
             return;
         }
@@ -93,8 +94,11 @@
         std::size_t glob_begin = prev == std::string::npos ? 0 : prev + 1;
         std::size_t glob_end = next == std::string::npos ? path.size() : next;
 
- if (prev != std::string::npos)
- dir /= fs::path(path.substr(0, prev));
+ quickbook_path new_location = location;
+
+ if (prev != std::string::npos) {
+ new_location /= path.substr(0, prev);
+ }
 
         if (next != std::string::npos) ++next;
 
@@ -102,7 +106,8 @@
                 path.data() + glob_begin,
                 glob_end - glob_begin);
 
- fs::path base_dir = dir.empty() ? fs::path(".") : dir;
+ fs::path base_dir = new_location.file_path.empty() ?
+ fs::path(".") : new_location.file_path;
         if (!fs::is_directory(base_dir)) return;
 
         // Walk through the dir for matches.
@@ -110,19 +115,17 @@
                 dir_i != dir_e; ++dir_i)
         {
             fs::path f = dir_i->path().filename();
+ std::string generic_path = detail::path_to_generic(f);
 
             // Skip if the dir item doesn't match.
- if (!quickbook::glob(glob, detail::path_to_generic(f))) continue;
+ if (!quickbook::glob(glob, generic_path)) continue;
 
             // If it's a file we add it to the results.
             if (next == std::string::npos)
             {
                 if (fs::is_regular_file(dir_i->status()))
                 {
- result.insert(quickbook_path(
- dir/f,
- state.abstract_file_path.parent_path()/dir/f
- ));
+ result.insert(new_location / generic_path);
                 }
             }
             // If it's a matching dir, we recurse looking for more files.
@@ -130,7 +133,7 @@
             {
                 if (!fs::is_regular_file(dir_i->status()))
                 {
- include_search_glob(result, dir/f,
+ include_search_glob(result, new_location / generic_path,
                             path.substr(next), state);
                 }
             }
@@ -149,12 +152,16 @@
             fs::path current = state.current_file->path.parent_path();
 
             // Search for the current dir accumulating to the result.
- include_search_glob(result, current, parameter.value, state);
+ include_search_glob(result,
+ quickbook_path(current,
+ state.abstract_file_path.parent_path()),
+ parameter.value, state);
 
             // Search the include path dirs accumulating to the result.
             BOOST_FOREACH(fs::path dir, include_path)
             {
- include_search_glob(result, dir, parameter.value, state);
+ include_search_glob(result, quickbook_path(dir, fs::path()),
+ parameter.value, state);
             }
 
             // Done.
@@ -219,4 +226,16 @@
         else if (other.abstract_file_path < abstract_file_path) return false;
         else return file_path < other.file_path;
     }
+
+ quickbook_path quickbook_path::operator/(boost::string_ref x) const
+ {
+ return quickbook_path(*this) /= x;
+ }
+
+ quickbook_path& quickbook_path::operator/=(boost::string_ref x)
+ {
+ file_path.append(x.begin(), x.end());
+ abstract_file_path.append(x.begin(), x.end());
+ return *this;
+ }
 }

Modified: trunk/tools/quickbook/src/include_paths.hpp
==============================================================================
--- trunk/tools/quickbook/src/include_paths.hpp Thu Nov 14 14:21:04 2013 (r86701)
+++ trunk/tools/quickbook/src/include_paths.hpp 2013-11-14 14:21:37 EST (Thu, 14 Nov 2013) (r86702)
@@ -49,6 +49,8 @@
         fs::path abstract_file_path;
 
         bool operator<(quickbook_path const& other) const;
+ quickbook_path operator/(boost::string_ref) const;
+ quickbook_path& operator/=(boost::string_ref);
     };
 
     std::set<quickbook_path> include_search(path_parameter const&,

Modified: trunk/tools/quickbook/test/include/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/include/Jamfile.v2 Thu Nov 14 14:21:04 2013 (r86701)
+++ trunk/tools/quickbook/test/include/Jamfile.v2 2013-11-14 14:21:37 EST (Thu, 14 Nov 2013) (r86702)
@@ -16,7 +16,9 @@
 test-suite quickbook.test :
     [ quickbook-test import-basic-1.6 ]
     [ quickbook-test filename ]
+ [ quickbook-test filename-1_7 ]
     [ quickbook-test filename-path : : : <quickbook-test-include>sub ]
+ [ quickbook-test filename_path-1_7 : : : <quickbook-test-include>sub ]
     [ quickbook-test doc-title1-1.5 ]
     [ quickbook-test doc-title1a-1.5 ]
     [ quickbook-test section ]

Added: trunk/tools/quickbook/test/include/filename-1_7.gold
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/tools/quickbook/test/include/filename-1_7.gold 2013-11-14 14:21:37 EST (Thu, 14 Nov 2013) (r86702)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="filename_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Filename Test</title>
+ <para>
+ filename-1_7.quickbook
+ </para>
+ <para>
+ sub/filename_include1.quickbook
+ </para>
+ <para>
+ sub/../filename_include2.quickbook
+ </para>
+ <para>
+ filename_include2.quickbook
+ </para>
+</article>

Added: trunk/tools/quickbook/test/include/filename-1_7.quickbook
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/tools/quickbook/test/include/filename-1_7.quickbook 2013-11-14 14:21:37 EST (Thu, 14 Nov 2013) (r86702)
@@ -0,0 +1,9 @@
+[article Filename Test
+[quickbook 1.7]
+]
+
+__FILENAME__
+
+[include sub/*.quickbook]
+
+[include filename_include?.quickbook]

Added: trunk/tools/quickbook/test/include/filename_path-1_7.gold
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/tools/quickbook/test/include/filename_path-1_7.gold 2013-11-14 14:21:37 EST (Thu, 14 Nov 2013) (r86702)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="filename_test_with_include_path" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Filename test with include path</title>
+ <para>
+ filename_path-1_7.quickbook
+ </para>
+ <para>
+ filename_include1.quickbook
+ </para>
+ <para>
+ ../filename_include2.quickbook
+ </para>
+ <para>
+ filename_include2.quickbook
+ </para>
+</article>

Added: trunk/tools/quickbook/test/include/filename_path-1_7.quickbook
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/tools/quickbook/test/include/filename_path-1_7.quickbook 2013-11-14 14:21:37 EST (Thu, 14 Nov 2013) (r86702)
@@ -0,0 +1,7 @@
+[article Filename test with include path
+[quickbook 1.7]
+]
+
+__FILENAME__
+
+[include filename_include?.quickbook]


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