|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70526 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-03-24 17:24:27
Author: danieljames
Date: 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
New Revision: 70526
URL: http://svn.boost.org/trac/boost/changeset/70526
Log:
Quickbook: Small cleanups.
Mostly avoiding warnings, and removing unnecessary includes.
Text files modified:
trunk/tools/quickbook/src/Jamfile.v2 | 2
trunk/tools/quickbook/src/actions.cpp | 117 +++++++++++++++++++++------------------
trunk/tools/quickbook/src/actions.hpp | 21 ------
trunk/tools/quickbook/src/actions_class.hpp | 5 +
trunk/tools/quickbook/src/code_snippet.cpp | 9 +-
trunk/tools/quickbook/src/doc_info_actions.cpp | 1
trunk/tools/quickbook/src/doc_info_grammar.cpp | 10 ++-
trunk/tools/quickbook/src/fwd.hpp | 3 +
trunk/tools/quickbook/src/main_grammar.cpp | 1
trunk/tools/quickbook/src/parsers.hpp | 7 +-
trunk/tools/quickbook/src/quickbook.cpp | 9 ++
trunk/tools/quickbook/src/rule_store.hpp | 5 +
trunk/tools/quickbook/src/values.cpp | 2
trunk/tools/quickbook/src/values.hpp | 22 ++++++-
14 files changed, 118 insertions(+), 96 deletions(-)
Modified: trunk/tools/quickbook/src/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/src/Jamfile.v2 (original)
+++ trunk/tools/quickbook/src/Jamfile.v2 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -14,6 +14,8 @@
<toolset>darwin:<c++-template-depth>300
<toolset>gcc:<cflags>-g0
<toolset>darwin:<cflags>-g0
+ <warnings>all
+ <toolset>msvc:<cflags>/wd4709
;
lib shell32 ;
Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp (original)
+++ trunk/tools/quickbook/src/actions.cpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -10,15 +10,15 @@
=============================================================================*/
#include <numeric>
#include <functional>
-#include <algorithm>
#include <vector>
#include <boost/filesystem/v3/convenience.hpp>
#include <boost/filesystem/v3/fstream.hpp>
+#include <boost/range/distance.hpp>
#include <boost/range/algorithm/replace.hpp>
#include <boost/lexical_cast.hpp>
-#include <boost/range/distance.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/next_prior.hpp>
+#include <boost/foreach.hpp>
#include "quickbook.hpp"
#include "actions.hpp"
#include "utils.hpp"
@@ -558,12 +558,12 @@
detail::print_space(*first++, out.get());
}
- void pre_escape_back::operator()(iterator first, iterator last) const
+ void pre_escape_back::operator()(iterator, iterator) const
{
escape_actions.phrase.push(); // save the stream
}
- void post_escape_back::operator()(iterator first, iterator last) const
+ void post_escape_back::operator()(iterator, iterator) const
{
escape_actions.output_pre(escape_actions.phrase);
out << escape_actions.phrase.str();
@@ -897,59 +897,72 @@
namespace
{
- iterator find_bracket_end(iterator begin, iterator const& end)
+ iterator find_first_seperator(iterator begin, iterator end)
{
- unsigned int depth = 1;
-
- while(depth > 0) {
- char const* search_chars = "[]\\";
- begin = std::find_first_of(begin, end, search_chars, search_chars + 3);
- if(begin == end) return begin;
-
- if(*begin == '\\')
- {
- if(++begin == end) return begin;
- ++begin;
- }
- else
+ if(qbk_version_n < 105) {
+ for(;begin != end; ++begin)
{
- depth += (*begin == '[') ? 1 : -1;
- ++begin;
+ switch(*begin)
+ {
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ return begin;
+ default:
+ break;
+ }
}
}
-
- return begin;
- }
-
- iterator find_first_seperator(iterator const& begin, iterator const& end)
- {
- if(qbk_version_n < 105) {
- char const* whitespace = " \t\r\n";
- return std::find_first_of(begin, end, whitespace, whitespace + 4);
- }
else {
- iterator pos = begin;
+ unsigned int depth = 0;
- while(true)
+ for(;begin != end; ++begin)
{
- char const* search_chars = " \t\r\n\\[";
- pos = std::find_first_of(pos, end, search_chars, search_chars + 6);
- if(pos == end) return pos;
-
- switch(*pos)
+ switch(*begin)
{
case '[':
- pos = find_bracket_end(++pos, end);
+ ++depth;
break;
case '\\':
- if(++pos == end) return pos;
- ++pos;
+ if(++begin == end) return begin;
+ break;
+ case ']':
+ if (depth > 0) --depth;
break;
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ if (depth == 0) return begin;
default:
- return pos;
+ break;
}
}
}
+
+ return begin;
+ }
+
+ std::pair<iterator, iterator> find_seperator(iterator begin, iterator end)
+ {
+ iterator first = begin = find_first_seperator(begin, end);
+
+ for(;begin != end; ++begin)
+ {
+ switch(*begin)
+ {
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ break;
+ default:
+ return std::make_pair(first, begin);
+ }
+ }
+
+ return std::make_pair(first, begin);
}
bool break_arguments(
@@ -980,17 +993,15 @@
iterator begin(body.content.begin(), body.position);
iterator end(body.content.end());
- iterator l_pos = find_first_seperator(begin, end);
- if (l_pos == end)
- break;
- char const* whitespace = " \t\r\n";
- char const* whitespace_end = whitespace + 4;
- iterator r_pos = l_pos;
- while(r_pos != end && std::find(whitespace, whitespace_end, *r_pos) != whitespace_end) ++r_pos;
- if (r_pos == end)
- break;
- template_body second(std::string(r_pos, end), body.filename, r_pos.get_position(), false);
- body.content = std::string(begin, l_pos);
+ std::pair<iterator, iterator> pos =
+ find_seperator(begin, end);
+ if (pos.second == end) break;
+ template_body second(
+ std::string(pos.second, end),
+ body.filename,
+ pos.second.get_position(),
+ false);
+ body.content = std::string(begin, pos.first);
args.push_back(second);
}
}
@@ -1834,7 +1845,7 @@
return (*this)(first, last, value::default_tag);
}
- void collector_to_value_action::operator()(iterator first, iterator last) const
+ void collector_to_value_action::operator()(iterator, iterator) const
{
if(!actions.output_pre(output)) return;
Modified: trunk/tools/quickbook/src/actions.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions.hpp (original)
+++ trunk/tools/quickbook/src/actions.hpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -10,32 +10,19 @@
#if !defined(BOOST_SPIRIT_QUICKBOOK_ACTIONS_HPP)
#define BOOST_SPIRIT_QUICKBOOK_ACTIONS_HPP
-#include <map>
#include <string>
#include <vector>
-#include <stack>
-#include <algorithm>
-#include <boost/filesystem/v3/operations.hpp>
#include <boost/spirit/include/phoenix1_functions.hpp>
-#include <boost/foreach.hpp>
-#include <boost/tuple/tuple.hpp>
+#include <boost/spirit/include/classic_symbols_fwd.hpp>
#include "fwd.hpp"
-#include "collector.hpp"
#include "template_stack.hpp"
#include "utils.hpp"
#include "values.hpp"
#include "scoped.hpp"
-#ifdef BOOST_MSVC
-// disable copy/assignment could not be generated, unreferenced formal params
-#pragma warning (push)
-#pragma warning(disable : 4511 4512 4100)
-#endif
-
namespace quickbook
{
namespace cl = boost::spirit::classic;
- namespace fs = boost::filesystem;
extern unsigned qbk_version_n; // qbk_major_version * 100 + qbk_minor_version
@@ -125,7 +112,7 @@
: actions(actions) {}
void operator()() const;
- void operator()(iterator first, iterator last) const { (*this)(); }
+ void operator()(iterator, iterator) const { (*this)(); }
quickbook::actions& actions;
};
@@ -441,8 +428,4 @@
};
}
-#ifdef BOOST_MSVC
-#pragma warning (pop)
-#endif
-
#endif // BOOST_SPIRIT_QUICKBOOK_ACTIONS_HPP
Modified: trunk/tools/quickbook/src/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.hpp (original)
+++ trunk/tools/quickbook/src/actions_class.hpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -10,11 +10,12 @@
#if !defined(BOOST_SPIRIT_ACTIONS_CLASS_HPP)
#define BOOST_SPIRIT_ACTIONS_CLASS_HPP
+#include <boost/tuple/tuple.hpp>
+#include <boost/scoped_ptr.hpp>
#include "actions.hpp"
#include "parsers.hpp"
#include "values_parse.hpp"
-#include <boost/tuple/tuple.hpp>
-#include <boost/scoped_ptr.hpp>
+#include "collector.hpp"
namespace quickbook
{
Modified: trunk/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- trunk/tools/quickbook/src/code_snippet.cpp (original)
+++ trunk/tools/quickbook/src/code_snippet.cpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -7,6 +7,7 @@
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
+#include <stack>
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_actor.hpp>
#include <boost/spirit/include/classic_confix.hpp>
@@ -307,9 +308,7 @@
iterator first(code.begin());
iterator last(code.end());
- size_t fname_len = file.size();
- bool is_python = fname_len >= 3
- && file[--fname_len]=='y' && file[--fname_len]=='p' && file[--fname_len]=='.';
+ bool is_python = extension == ".py";
code_snippet_actions a(storage, file, doc_id, is_python ? "[python]" : "[c++]");
// TODO: Should I check that parse succeeded?
if(is_python) {
@@ -398,14 +397,14 @@
}
}
- void code_snippet_actions::start_snippet(iterator first, iterator last)
+ void code_snippet_actions::start_snippet(iterator, iterator)
{
append_code();
snippet_stack.push(snippet_data(id, callout_id));
id.clear();
}
- void code_snippet_actions::end_snippet(iterator first, iterator last)
+ void code_snippet_actions::end_snippet(iterator first, iterator)
{
// TODO: Error?
if(snippet_stack.empty()) return;
Modified: trunk/tools/quickbook/src/doc_info_actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/doc_info_actions.cpp (original)
+++ trunk/tools/quickbook/src/doc_info_actions.cpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -11,6 +11,7 @@
#include <sstream>
#include <boost/bind.hpp>
#include <boost/algorithm/string/join.hpp>
+#include <boost/foreach.hpp>
#include "quickbook.hpp"
#include "utils.hpp"
#include "input_path.hpp"
Modified: trunk/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ trunk/tools/quickbook/src/doc_info_grammar.cpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -8,10 +8,8 @@
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-#include "grammar_impl.hpp"
-#include "actions_class.hpp"
-#include "doc_info_tags.hpp"
-#include "phrase_tags.hpp"
+#include <map>
+#include <boost/foreach.hpp>
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_actor.hpp>
#include <boost/spirit/include/classic_loops.hpp>
@@ -19,6 +17,10 @@
#include <boost/spirit/include/classic_chset.hpp>
#include <boost/spirit/include/classic_numerics.hpp>
#include <boost/spirit/include/phoenix1_primitives.hpp>
+#include "grammar_impl.hpp"
+#include "actions_class.hpp"
+#include "doc_info_tags.hpp"
+#include "phrase_tags.hpp"
namespace quickbook
{
Modified: trunk/tools/quickbook/src/fwd.hpp
==============================================================================
--- trunk/tools/quickbook/src/fwd.hpp (original)
+++ trunk/tools/quickbook/src/fwd.hpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -17,8 +17,11 @@
{
struct actions;
struct quickbook_grammar;
+ struct collector;
typedef position_iterator<std::string::const_iterator> iterator;
+
+ inline void ignore_variable(void const*) {}
}
#endif
Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp (original)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -186,7 +186,6 @@
)
>> local.process_element()
[ actions.values.list(ph::var(local.info.tag))
-
[ cl::lazy_p(*ph::var(local.info.rule))
>> space
>> ']'
Modified: trunk/tools/quickbook/src/parsers.hpp
==============================================================================
--- trunk/tools/quickbook/src/parsers.hpp (original)
+++ trunk/tools/quickbook/src/parsers.hpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -176,7 +176,7 @@
{
typedef phoenix::tuple<> tuple;
return scoped_parser_gen<Impl, tuple>(impl_, tuple());
- };
+ }
template <typename Arg1>
scoped_parser_gen<Impl, phoenix::tuple<Arg1> >
@@ -184,7 +184,7 @@
{
typedef phoenix::tuple<Arg1> tuple;
return scoped_parser_gen<Impl, tuple>(impl_, tuple(x1));
- };
+ }
template <typename Arg1, typename Arg2>
scoped_parser_gen<Impl, phoenix::tuple<Arg1, Arg2> >
@@ -192,7 +192,7 @@
{
typedef phoenix::tuple<Arg1, Arg2> tuple;
return scoped_parser_gen<Impl, tuple>(impl_, tuple(x1, x2));
- };
+ }
Impl impl_;
};
@@ -252,4 +252,5 @@
lookback_gen const lookback = lookback_gen();
}
+
#endif // BOOST_QUICKBOOK_SCOPED_BLOCK_HPP
Modified: trunk/tools/quickbook/src/quickbook.cpp
==============================================================================
--- trunk/tools/quickbook/src/quickbook.cpp (original)
+++ trunk/tools/quickbook/src/quickbook.cpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -110,8 +110,10 @@
}
static int
- parse_document(fs::path const& filein_, fs::path const& xinclude_base,
- string_stream& out, bool ignore_docinfo = false)
+ parse_document(
+ fs::path const& filein_,
+ fs::path const& xinclude_base,
+ string_stream& out)
{
actions actor(filein_, xinclude_base, out);
@@ -248,6 +250,9 @@
bool pretty_print = true;
#if QUICKBOOK_WIDE_PATHS
+ quickbook::ignore_variable(&argc);
+ quickbook::ignore_variable(&argv);
+
int wide_argc;
LPWSTR* wide_argv = CommandLineToArgvW(GetCommandLineW(), &wide_argc);
if (!wide_argv)
Modified: trunk/tools/quickbook/src/rule_store.hpp
==============================================================================
--- trunk/tools/quickbook/src/rule_store.hpp (original)
+++ trunk/tools/quickbook/src/rule_store.hpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -15,7 +15,7 @@
#define BOOST_SPIRIT_QUICKBOOK_RULE_STORE_HPP
#include <deque>
-#include <boost/assert.hpp>
+#include <cassert>
#include <utility>
namespace quickbook
@@ -34,7 +34,8 @@
scoped_void() : ptr_(0), del_(0) {}
scoped_void(scoped_void const& src) : ptr_(0), del_(0) {
- BOOST_ASSERT(!src.ptr_);
+ ignore_variable(&src);
+ assert(!src.ptr_);
}
~scoped_void() {
if(ptr_) del_(ptr_);
Modified: trunk/tools/quickbook/src/values.cpp
==============================================================================
--- trunk/tools/quickbook/src/values.cpp (original)
+++ trunk/tools/quickbook/src/values.cpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -693,7 +693,7 @@
value_node* pos = head_;
boost::intrusive_ptr<value_node> new_node;
- while(true) {
+ for(;;) {
if(pos == &value_nil_impl::instance)
return this;
new_node = pos->store();
Modified: trunk/tools/quickbook/src/values.hpp
==============================================================================
--- trunk/tools/quickbook/src/values.hpp (original)
+++ trunk/tools/quickbook/src/values.hpp 2011-03-24 17:24:24 EDT (Thu, 24 Mar 2011)
@@ -305,7 +305,6 @@
value::iterator* ptr_;
};
-
typedef iterator const_iterator;
typedef iterator::reference reference;
@@ -323,13 +322,13 @@
reference consume()
{
- assert(check());
+ assert_check();
return *pos_++;
}
reference consume(value::tag_type t)
{
- assert(check(t));
+ assert_check(t);
return *pos_++;
}
@@ -365,12 +364,27 @@
void finish() const
{
- assert(pos_ == end_);
+ if (pos_ != end_)
+ throw value_error("Not all values handled.");
}
iterator begin() { return iterator(&pos_); }
iterator end() { return iterator(&end_); }
private:
+
+ void assert_check() const
+ {
+ if (pos_ == end_)
+ throw value_error("Attempt to read past end of value list.");
+ }
+
+ void assert_check(value::tag_type t) const
+ {
+ assert_check();
+ if (t != pos_->get_tag())
+ throw value_error("Incorrect value tag.");
+ }
+
value list_;
value::iterator pos_, end_;
};
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