Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77383 - in trunk/tools/quickbook: doc src
From: dnljms_at_[hidden]
Date: 2012-03-18 15:50:19


Author: danieljames
Date: 2012-03-18 15:50:18 EDT (Sun, 18 Mar 2012)
New Revision: 77383
URL: http://svn.boost.org/trac/boost/changeset/77383

Log:
Quickbook: Remove glob support for now. It isn't ready for release.
Removed:
   trunk/tools/quickbook/src/glob.hpp
Text files modified:
   trunk/tools/quickbook/doc/1_6.qbk | 20 -----
   trunk/tools/quickbook/src/actions.cpp | 143 ++++++---------------------------------
   2 files changed, 24 insertions(+), 139 deletions(-)

Modified: trunk/tools/quickbook/doc/1_6.qbk
==============================================================================
--- trunk/tools/quickbook/doc/1_6.qbk (original)
+++ trunk/tools/quickbook/doc/1_6.qbk 2012-03-18 15:50:18 EDT (Sun, 18 Mar 2012)
@@ -282,26 +282,6 @@
 
 [section:1_7 Quickbook 1.7]
 
-[section:glob Including multiple files with Globs]
-
-One can now include multiple files at once using a glob pattern for the
-file reference:
-
- [include sub/*/*.qbk]
- [include include/*.h]
-
-All the matching files, and intermediate irectories, will match and be
-included. The glob pattern can be "\*" for matching zero or more characters,
-"?" for matching a single character, "\[<c>-<c>\]" to match a character class,
-"\[\^<char>-<char>\]" to exclusive match a character class, "\\\\" to escape
-a glob special character which is then matched, and anything else is matched
-to the character.
-
-[note Because of the escaping in file references the "\\\\" glob escape is
-a double "\\"; i.e. and escaped back-slash.]
-
-[endsect]
-
 [section:source_mode Source mode for single entities]
 
 1.7 introduces a new `!` element type for setting the source mode of a single

Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp (original)
+++ trunk/tools/quickbook/src/actions.cpp 2012-03-18 15:50:18 EDT (Sun, 18 Mar 2012)
@@ -33,7 +33,6 @@
 #include "block_tags.hpp"
 #include "phrase_tags.hpp"
 #include "id_manager.hpp"
-#include "glob.hpp"
 
 namespace quickbook
 {
@@ -1762,8 +1761,8 @@
     }
 
     struct path_details {
- // Will possibly add 'url' to this list later:
- enum path_type { path, glob };
+ // Will possibly add 'url' and 'glob' to this list later:
+ enum path_type { path };
 
         std::string value;
         path_type type;
@@ -1785,10 +1784,7 @@
         std::string path_text = qbk_version_n >= 106u || path.is_encoded() ?
                 path.get_encoded() : path.get_quickbook();
 
- bool is_glob = qbk_version_n >= 107u &&
- path_text.find_first_of("[]?*") != std::string::npos;
-
- if(!is_glob && path_text.find('\\') != std::string::npos)
+ if(path_text.find('\\') != std::string::npos)
         {
             quickbook::detail::ostream* err;
 
@@ -1808,24 +1804,13 @@
             boost::replace(path_text, '\\', '/');
         }
 
- return path_details(path_text,
- is_glob ? path_details::glob : path_details::path);
+ return path_details(path_text, path_details::path);
     }
 
     xinclude_path calculate_xinclude_path(value const& p, quickbook::state& state)
     {
         path_details details = check_path(p, state);
 
- if (details.type == path_details::glob) {
- // TODO: Should know if this is an xinclude or an xmlbase.
- // Would also help with implementation of 'check_path'.
- detail::outerr(p.get_file(), p.get_position())
- << "Glob used in xinclude/xmlbase."
- << std::endl;
- ++state.error_count;
- return xinclude_path(state.current_file->path.parent_path(), "");
- }
-
         fs::path path = detail::generic_to_path(details.value);
         fs::path full_path = path;
 
@@ -1873,121 +1858,41 @@
             }
         };
 
- #if QUICKBOOK_WIDE_PATHS
- typedef std::wstring path_string_t;
- inline path_string_t path_to_string(fs::path const & p)
- {
- return p.generic_wstring();
- }
- static const path_string_t::value_type* glob_chars = L"[]?*";
- #else
- typedef std::string path_string_t;
- inline path_string_t path_to_string(fs::path const & p)
- {
- return p.generic_string();
- }
- static const path_string_t::value_type* glob_chars = "[]?*";
- #endif
-
- void include_search_glob(std::set<include_search_return> & result,
- fs::path dir, fs::path path, quickbook::state const & state)
- {
- // Split the glob into the current dir/glob/rest to search.
- fs::path glob;
- fs::path rest;
- fs::path::iterator i = path.begin();
- fs::path::iterator e = path.end();
- for (; i != e; ++i)
- {
- if (path_to_string(*i).find_first_of(glob_chars) != path_string_t::npos)
- {
- glob = *i;
- for (++i; i != e; ++i) rest /= *i;
- break;
- }
- else
- {
- dir /= *i;
- }
- }
- // Walk through the dir for matches.
- fs::directory_iterator dir_i(dir.empty() ? fs::path(".") : dir);
- fs::directory_iterator dir_e;
- for (; dir_i != dir_e; ++dir_i)
- {
- fs::path f = dir_i->path().filename();
- // Skip if the dir item doesn't match.
- if (!quickbook::glob(path_to_string(glob).c_str(),path_to_string(f).c_str())) continue;
- // If it's a file we add it to the results.
- if (fs::is_regular_file(dir_i->status()))
- {
- result.insert(include_search_return(
- dir/f,
- state.filename_relative.parent_path()/dir/f
- ));
- }
- // If it's a matching dir, we recurse looking for more files.
- else
- {
- include_search_glob(result,dir,f/rest,state);
- }
- }
- }
-
         std::set<include_search_return> include_search(path_details const& details,
                 quickbook::state const& state)
         {
             std::set<include_search_return> result;
             fs::path current = state.current_file->path.parent_path();
 
- // If the path has some glob match characters
- // we do a discovery of all the matches..
- if (details.type == path_details::glob)
- {
- fs::path path(details.value);
-
- // Search for the current dir accumulating to the result.
- include_search_glob(result,current,path,state);
- // Search the include path dirs accumulating to the result.
- BOOST_FOREACH(fs::path dir, include_path)
+ fs::path path(details.value);
+
+ // If the path is relative, try and resolve it.
+ if (!path.has_root_directory() && !path.has_root_name())
+ {
+ // See if it can be found locally first.
+ if (fs::exists(current / path))
                 {
- include_search_glob(result,dir,path,state);
+ result.insert(include_search_return(
+ current / path,
+ state.filename_relative.parent_path() / path));
+ return result;
                 }
- // Done.
- return result;
- }
- else
- {
- fs::path path(details.value);
 
- // If the path is relative, try and resolve it.
- if (!path.has_root_directory() && !path.has_root_name())
+ // Search in each of the include path locations.
+ BOOST_FOREACH(fs::path full, include_path)
                 {
- // See if it can be found locally first.
- if (fs::exists(current / path))
+ full /= path;
+ if (fs::exists(full))
                     {
- result.insert(include_search_return(
- current / path,
- state.filename_relative.parent_path() / path));
+ result.insert(include_search_return(full, path));
                         return result;
                     }
-
- // Search in each of the include path locations.
- BOOST_FOREACH(fs::path full, include_path)
- {
- full /= path;
- if (fs::exists(full))
- {
- result.insert(include_search_return(full, path));
- return result;
- }
- }
                 }
-
- result.insert(include_search_return(path,
- state.filename_relative.parent_path() / path));
- return result;
             }
+
+ result.insert(include_search_return(path,
+ state.filename_relative.parent_path() / path));
+ return result;
         }
     }
     

Deleted: trunk/tools/quickbook/src/glob.hpp
==============================================================================
--- trunk/tools/quickbook/src/glob.hpp 2012-03-18 15:50:18 EDT (Sun, 18 Mar 2012)
+++ (empty file)
@@ -1,227 +0,0 @@
-#ifndef BOOST_QUICKBOOK_GLOB_HPP
-#define BOOST_QUICKBOOK_GLOB_HPP
-/*
- Copyright Redshift Software Inc 2011
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
- */
-
-/*
- * Copyright 1994 Christopher Seiwald. All rights reserved.
- *
- * This file is part of Jam - see jam.c for Copyright information.
- */
-
-/*
- * glob.c - match a string against a simple pattern
- *
- * Understands the following patterns:
- *
- * * any number of characters
- * ? any single character
- * [a-z] any single character in the range a-z
- * [^a-z] any single character not in the range a-z
- * \x match x
- *
- * External functions:
- *
- * glob() - match a string against a simple pattern
- *
- * Internal functions:
- *
- * globchars() - build a bitlist to check for character group match
- */
-
-#include <boost/cstdint.hpp>
-
-namespace quickbook
-{
- namespace glob_detail
- {
- template < typename Char >
- struct bit_list
- {
- /* bytes used for [chars] in compiled expr */
- enum bit_list_size_t
- {
- bit_list_size = sizeof(Char)/8
- };
-
- boost::uint8_t tab[bit_list_size];
-
- bit_list()
- {
- for (unsigned i = 0; i<bit_list_size; ++i)
- tab[i] = 0;
- }
-
- bool operator[](unsigned bit)
- {
- return (tab[bit/8]&(1<<(bit%8)));
- }
-
- void set(unsigned bit)
- {
- /* `bit != 0` :: Do not include \0 in either $[chars] or $[^chars]. */
- if (bit!=0)
- tab[bit/8] |= (1<<(bit%8) );
- }
-
- void negate()
- {
- for (unsigned i = 0; i<bit_list_size; ++i)
- tab[i] ^= 255;
- }
- };
-
- /*
- * globchars() - build a bitlist to check for character group match.
- */
- template < typename Char >
- bit_list<Char> globchars(const Char * s, const Char * e)
- {
- bit_list<Char> result;
-
- bool neg = false;
-
- if (*s==Char('^'))
- {
- neg = true;
- ++s;
- }
-
- while (s<e)
- {
- Char c;
-
- if ((s+2<e)&&(s[1]==Char('-')))
- {
- for (c = s[0]; c<=s[2]; ++c)
- result.set(c);
- s += 3;
- }
- else
- {
- c = *s++;
- result.set(c);
- }
- }
-
- if (neg)
- result.negate();
-
- return result;
- }
-
- /*
- * glob() - match a string against a simple pattern.
- */
- template < typename Char >
- bool glob(const Char * c, const Char * s, bool & fail)
- {
- const Char eos = Char('\0');
-
- fail = false;
-
- while (true)
- {
- if (eos==*c)
- {
- fail = eos!=*s;
- return !fail;
- }
- else if (Char('?')==*c)
- {
- ++c;
- if (eos==*s++)
- return false;
- }
- else if (Char('[')==*c)
- {
- ++c;
- /* Scan for matching ]. */
-
- const Char * here = c;
- do
- {
- if (eos==*c++)
- return false;
- }
- while ((here==c)||(*c!=Char(']')));
- ++c;
-
- /* Build character class bitlist. */
-
- glob_detail::bit_list<Char> bitlist =
- glob_detail::globchars(here, c);
-
- if (!bitlist[*s])
- return false;
- ++s;
- }
- else if (Char('*')==*c)
- {
- ++c;
- const Char * here = s;
-
- while (eos!=*s)
- ++s;
-
- /* Try to match the rest of the pattern in a recursive */
- /* call. If the match fails we'll back up chars, retrying. */
-
- while (s!=here)
- {
- bool r = false;
-
- /* A fast path for the last token in a pattern. */
- if (eos!=*c)
- r = glob(c, s, fail);
- else if (eos!=*s)
- {
- fail = true;
- r = false;
- }
- else
- r = true;
-
- if (r)
- return true;
- if (fail)
- return false;
- --s;
- }
- }
- else if (Char('\\')==*c)
- {
- ++c;
- /* Force literal match of next char. */
- if (eos==*c||(*s++!=*c++))
- return false;
- }
- else
- {
- ++c;
- if (*s++!=c[-1])
- return false;
- }
- }
-
- return false;
- }
- }
-
- /*
- * glob() - match a string against a simple pattern.
- */
- template < typename Char >
- bool glob(const Char * pattern, const Char * s)
- {
- bool fail = false;
- bool result = glob_detail::glob(pattern, s, fail);
- return result;
- }
-}
-
-#endif


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