Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68392 - branches/quickbook-filenames/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-01-23 11:43:00


Author: danieljames
Date: 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
New Revision: 68392
URL: http://svn.boost.org/trac/boost/changeset/68392

Log:
Change the way the filename is stored.

No longer stored in the iterator which means there's less messing around
with pointers and strings. Always stored as a fs::path which will help
with support for unicode. Also passed to outwarn and outerr as fs::path
so they can handle writing unicode filenames to the output.
Added:
   branches/quickbook-filenames/tools/quickbook/src/iterator.hpp (contents, props changed)
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 109 +++++++++++++++++++++------------------
   branches/quickbook-filenames/tools/quickbook/src/actions.hpp | 28 ++++++---
   branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp | 5 +
   branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp | 13 ++-
   branches/quickbook-filenames/tools/quickbook/src/fwd.hpp | 8 --
   branches/quickbook-filenames/tools/quickbook/src/post_process.cpp | 4
   branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp | 22 ++++----
   branches/quickbook-filenames/tools/quickbook/src/syntax_highlight.hpp | 4
   branches/quickbook-filenames/tools/quickbook/src/template_stack.hpp | 42 +++-----------
   branches/quickbook-filenames/tools/quickbook/src/utils.cpp | 21 ++++--
   branches/quickbook-filenames/tools/quickbook/src/utils.hpp | 6 +
   11 files changed, 131 insertions(+), 131 deletions(-)

Modified: branches/quickbook-filenames/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.cpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -49,18 +49,19 @@
     {
         if(!actions.output_pre(phrase)) return;
 
- position const pos = first.get_position();
- detail::outwarn(pos.file,pos.line) << "in column:" << pos.column << ", "
+ file_position const pos = first.get_position();
+ detail::outwarn(actions.filename, pos.line)
+ << "in column:" << pos.column << ", "
             << "[br] and \\n are deprecated" << ".\n";
         phrase << break_mark;
     }
 
     void error_action::operator()(iterator first, iterator /*last*/) const
     {
- position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
+ file_position const pos = first.get_position();
+ detail::outerr(actions.filename, pos.line)
             << "Syntax Error near column " << pos.column << ".\n";
- ++error_count;
+ ++actions.error_count;
     }
 
     void tagged_action::operator()(std::string const& str) const
@@ -308,10 +309,10 @@
 
         if (mark != list_marks.top().first) // new_indent == list_indent
         {
- position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
+ file_position const pos = first.get_position();
+ detail::outerr(actions.filename, pos.line)
                 << "Illegal change of list style near column " << pos.column << ".\n";
- detail::outwarn(pos.file,pos.line)
+ detail::outwarn(actions.filename, pos.line)
                 << "Ignoring change of list style" << std::endl;
             ++error_count;
         }
@@ -329,9 +330,9 @@
 
     void unexpected_char::operator()(iterator first, iterator last) const
     {
- position const pos = first.get_position();
+ file_position const pos = first.get_position();
 
- detail::outwarn(pos.file, pos.line)
+ detail::outwarn(actions.filename, pos.line)
             << "in column:" << pos.column
             << ", unexpected character: " << std::string(first, last)
             << "\n";
@@ -404,9 +405,8 @@
         if (program.size() == 0)
             return; // Nothing left to do here. The program is empty.
 
- iterator first_(program.begin(), program.end());
- iterator last_(program.end(), program.end());
- first_.set_position(first.get_position());
+ iterator first_(program.begin(), first.get_position());
+ iterator last_(program.end());
 
         // TODO: Shouldn't phrase be empty here? Why would it be output
         // after the code block?
@@ -491,13 +491,13 @@
 
     void attribute_action::operator()(iterator first, iterator last) const
     {
- position const pos = first.get_position();
+ file_position const pos = first.get_position();
 
         if (!attributes.insert(
                 attribute_map::value_type(attribute_name, std::string(first, last))
             ).second)
         {
- detail::outwarn(pos.file,pos.line)
+ detail::outwarn(actions.filename, pos.line)
                 << "Repeated attribute: " << attribute_name << ".\n";
         }
     }
@@ -632,12 +632,17 @@
     {
         if(actions.suppress) return;
         if (!actions.templates.add(
- template_symbol(actions.template_identifier, actions.template_info,
- std::string(first, last), first.get_position(),
- actions.template_block, &actions.templates.top_scope())))
+ template_symbol(
+ actions.template_identifier,
+ actions.template_info,
+ std::string(first, last),
+ actions.filename,
+ first.get_position(),
+ actions.template_block,
+ &actions.templates.top_scope())))
         {
- position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
+ file_position const pos = first.get_position();
+ detail::outerr(actions.filename, pos.line)
                 << "Template Redefinition: " << actions.template_identifier << std::endl;
             ++actions.error_count;
         }
@@ -706,7 +711,8 @@
         bool break_arguments(
             std::vector<template_body>& args
           , std::vector<std::string> const& params
- , position const& pos
+ , fs::path const& filename
+ , file_position const& pos
         )
         {
             // Quickbook 1.4-: If there aren't enough parameters seperated by
@@ -727,9 +733,8 @@
                     // arguments, or if there are no more spaces left.
 
                     template_body& body = args.back();
- iterator begin(body.content.begin(), body.content.end(),
- position(body.position.file.c_str(), body.position.line, body.position.column));
- iterator end(body.content.end(), body.content.end());
+ iterator begin(body.content.begin(), body.position);
+ iterator end(body.content.end());
                     
                     iterator l_pos = find_first_seperator(begin, end);
                     if (l_pos == end)
@@ -740,7 +745,7 @@
                     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), r_pos.get_position(), false);
+ template_body second(std::string(r_pos, end), body.filename, r_pos.get_position(), false);
                     body.content = std::string(begin, l_pos);
                     args.push_back(second);
                 }
@@ -748,7 +753,7 @@
 
             if (args.size() != params.size())
             {
- detail::outerr(pos.file, pos.line)
+ detail::outerr(filename, pos.line)
                     << "Invalid number of arguments passed. Expecting: "
                     << params.size()
                     << " argument(s), got: "
@@ -765,7 +770,7 @@
             std::vector<template_body>& args
           , std::vector<std::string> const& params
           , template_scope const& scope
- , position const& pos
+ , file_position const& pos
           , quickbook::actions& actions
         )
         {
@@ -779,9 +784,9 @@
             {
                 if (!actions.templates.add(
                         template_symbol(*tpl, empty_params, arg->content,
- arg->position, arg->is_block, &scope)))
+ arg->filename, arg->position, arg->is_block, &scope)))
                 {
- detail::outerr(pos.file,pos.line)
+ detail::outerr(actions.filename, pos.line)
                         << "Duplicate Symbol Found" << std::endl;
                     ++actions.error_count;
                     return std::make_pair(false, tpl);
@@ -816,9 +821,10 @@
                 if (!body.is_block)
                 {
                     // do a phrase level parse
- iterator first(body.content.begin(), body.content.end(),
- position(body.position.file.c_str(), body.position.line, body.position.column));
- iterator last(body.content.end(), body.content.end());
+ actions.filename = body.filename;
+ iterator first(body.content.begin(), body.position);
+ iterator last(body.content.end());
+
                     return cl::parse(first, last, actions.grammar().simple_phrase).full;
                 }
                 else
@@ -827,10 +833,11 @@
                     // ensure that we have enough trailing newlines to eliminate
                     // the need to check for end of file in the grammar.
                     
+ actions.filename = body.filename;
                     std::string content = body.content + "\n\n";
- iterator first(content.begin(), content.end(),
- position(body.position.file.c_str(), body.position.line, body.position.column));
- iterator last(content.end(), content.end());
+ iterator first(content.begin(), body.position);
+ iterator last(content.end());
+
                     return cl::parse(first, last, actions.grammar().block).full;
                 }
             }
@@ -849,6 +856,7 @@
         actions.template_args.push_back(
             template_body(
                 std::string(first, last),
+ actions.filename,
                 first.get_position(),
                 actions.template_block));
     }
@@ -863,12 +871,12 @@
         std::string identifier;
         std::swap(args, actions.template_args);
         std::swap(identifier, actions.template_identifier);
- position const pos = first.get_position();
+ file_position const pos = first.get_position();
 
         ++actions.template_depth;
         if (actions.template_depth > actions.max_template_depth)
         {
- detail::outerr(pos.file,pos.line)
+ detail::outerr(actions.filename, pos.line)
                 << "Infinite loop detected" << std::endl;
             --actions.template_depth;
             ++actions.error_count;
@@ -908,7 +916,7 @@
             {
                 // Break the arguments for a template
             
- if (!break_arguments(args, symbol->params, pos))
+ if (!break_arguments(args, symbol->params, actions.filename, pos))
                 {
                     actions.pop(); // restore the actions' states
                     --actions.template_depth;
@@ -920,7 +928,7 @@
             {
                 if (!args.empty())
                 {
- detail::outerr(pos.file, pos.line)
+ detail::outerr(actions.filename, pos.line)
                         << "Arguments for code snippet."
                         <<std::endl;
                     ++actions.error_count;
@@ -941,7 +949,7 @@
                     code += "linkends=\"" + callout_id + "\" />";
                     code += "'''";
 
- args.push_back(template_body(code, first.get_position(), false));
+ args.push_back(template_body(code, actions.filename, pos, false));
                 }
             }
 
@@ -965,8 +973,8 @@
 
             if (!parse_template(symbol->body, actions.template_escape, actions))
             {
- position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
+ file_position const pos = first.get_position();
+ detail::outerr(actions.filename, pos.line)
                     << "Expanding "
                     << (symbol->body.is_block ? "block" : "phrase")
                     << " template: " << symbol->identifier << std::endl
@@ -983,8 +991,8 @@
 
             if (actions.section_level != actions.min_section_level)
             {
- position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
+ file_position const pos = first.get_position();
+ detail::outerr(actions.filename, pos.line)
                     << "Mismatched sections in template " << identifier << std::endl;
                 actions.pop(); // restore the actions' states
                 --actions.template_depth;
@@ -1014,7 +1022,7 @@
 
                 if(!r)
                 {
- detail::outerr(c.position.file, c.position.line)
+ detail::outerr(c.filename, c.position.line)
                         << "Expanding callout." << std::endl
                         << "------------------begin------------------" << std::endl
                         << c.content
@@ -1241,8 +1249,8 @@
 
         if (section_level <= min_section_level)
         {
- position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
+ file_position const pos = first.get_position();
+ detail::outerr(actions.filename, pos.line)
                 << "Mismatched [endsect] near column " << pos.column << ".\n";
             ++error_count;
             
@@ -1266,8 +1274,8 @@
     
     void element_id_warning_action::operator()(iterator first, iterator) const
     {
- position const pos = first.get_position();
- detail::outwarn(pos.file,pos.line) << "Empty id.\n";
+ file_position const pos = first.get_position();
+ detail::outwarn(actions.filename, pos.line) << "Empty id.\n";
     }
 
     fs::path path_difference(fs::path const& outdir, fs::path const& path)
@@ -1361,8 +1369,7 @@
             ts.parent = &actions.templates.top_scope();
             if (!actions.templates.add(ts))
             {
- cl::file_position const pos = ts.body.position;
- detail::outerr(pos.file, pos.line)
+ detail::outerr(ts.body.filename, ts.body.position.line)
                     << "Template Redefinition: " << tname << std::endl;
                 ++actions.error_count;
             }

Modified: branches/quickbook-filenames/tools/quickbook/src/actions.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.hpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -117,13 +117,12 @@
     {
         // Prints an error message to std::cerr
 
- error_action(
- int& error_count)
- : error_count(error_count) {}
+ error_action(quickbook::actions& actions)
+ : actions(actions) {}
 
         void operator()(iterator first, iterator /*last*/) const;
 
- int& error_count;
+ quickbook::actions& actions;
     };
 
     struct tagged_action
@@ -392,12 +391,16 @@
     {
         // Handles unexpected chars in c++ syntax
 
- unexpected_char(collector& out)
- : out(out) {}
+ unexpected_char(
+ collector& out
+ , quickbook::actions& actions)
+ : out(out)
+ , actions(actions) {}
 
         void operator()(iterator first, iterator last) const;
 
         collector& out;
+ quickbook::actions& actions;
     };
 
     struct anchor_action
@@ -518,16 +521,16 @@
         attribute_action(
             attribute_map& attributes
           , std::string& attribute_name
- , int& error_count)
+ , quickbook::actions& actions)
         : attributes(attributes)
         , attribute_name(attribute_name)
- , error_count(error_count) {}
+ , actions(actions) {}
 
         void operator()(iterator first, iterator last) const;
 
         attribute_map& attributes;
         std::string& attribute_name;
- int& error_count;
+ quickbook::actions& actions;
     };
 
     struct image_action
@@ -821,7 +824,12 @@
    
    struct element_id_warning_action
    {
- void operator()(iterator first, iterator last) const;
+ element_id_warning_action(quickbook::actions& actions_)
+ : actions(actions_) {}
+
+ void operator()(iterator first, iterator last) const;
+
+ quickbook::actions& actions;
    };
 
     struct xinclude_action

Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -77,7 +77,7 @@
         , suppress(false)
 
     // actions
- , error(error_count)
+ , error(*this)
         , extract_doc_title(doc_title, phrase, *this)
         , extract_doc_license(doc_license, phrase, *this)
         , extract_doc_purpose(doc_purpose, phrase, *this)
@@ -117,7 +117,7 @@
         , plain_char(phrase, *this)
         , raw_char(phrase, *this)
         , escape_unicode(phrase, *this)
- , attribute(attributes, attribute_name, error_count)
+ , attribute(attributes, attribute_name, *this)
         , image(phrase, attributes, image_fileref, *this)
         , cond_phrase_pre(condition, macro)
         , scoped_cond_phrase(*this)
@@ -192,6 +192,7 @@
 
         , begin_section(out, phrase, doc_id, section_id, section_level, qualified_section_id, element_id, *this)
         , end_section(out, section_level, min_section_level, qualified_section_id, error_count, *this)
+ , element_id_warning(*this)
         , xinclude(out, *this)
         , include(*this)
         , import(out, *this)

Modified: branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -22,10 +22,12 @@
     struct code_snippet_actions
     {
         code_snippet_actions(std::vector<template_symbol>& storage,
+ std::string const& filename,
                                  std::string const& doc_id,
                                  char const* source_type)
             : callout_id(0)
             , storage(storage)
+ , filename(filename)
             , doc_id(doc_id)
             , source_type(source_type)
         {}
@@ -63,6 +65,7 @@
         std::string code;
         std::string id;
         std::vector<template_symbol>& storage;
+ boost::filesystem::path filename;
         std::string const doc_id;
         char const* const source_type;
     };
@@ -271,13 +274,13 @@
         if (err != 0)
             return err; // return early on error
 
- iterator first(code.begin(), code.end(), file.c_str());
- iterator last(code.end(), code.end());
+ 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]=='.';
- code_snippet_actions a(storage, doc_id, is_python ? "[python]" : "[c++]");
+ code_snippet_actions a(storage, file, doc_id, is_python ? "[python]" : "[c++]");
         // TODO: Should I check that parse succeeded?
         if(is_python) {
             boost::spirit::classic::parse(first, last, python_code_snippet_grammar(a));
@@ -346,7 +349,7 @@
         code += "``[[callout" + boost::lexical_cast<std::string>(callout_id) + "]]``";
     
         snippet_stack.top().callouts.push_back(
- template_body(std::string(first, last), first.get_position(), true));
+ template_body(std::string(first, last), filename, first.get_position(), true));
         ++callout_id;
     }
 
@@ -400,7 +403,7 @@
         }
         
         // TODO: Save position in start_snippet
- template_symbol symbol(snippet.id, params, body, first.get_position(), true);
+ template_symbol symbol(snippet.id, params, body, filename, first.get_position(), true);
         symbol.callout = true;
         symbol.callouts = snippet.callouts;
         storage.push_back(symbol);

Modified: branches/quickbook-filenames/tools/quickbook/src/fwd.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/fwd.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/fwd.hpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -11,18 +11,14 @@
 #if !defined(BOOST_SPIRIT_FWD_HPP)
 #define BOOST_SPIRIT_FWD_HPP
 
-#include <boost/spirit/include/classic_iterator.hpp>
-#include <boost/range.hpp>
-#include <boost/shared_ptr.hpp>
+#include "iterator.hpp"
 
 namespace quickbook
 {
     struct actions;
     struct quickbook_grammar;
 
- typedef boost::spirit::classic::file_position_base<char const*> position;
- typedef boost::spirit::classic::position_iterator<
- std::string::const_iterator, position> iterator;
+ typedef position_iterator<std::string::const_iterator> iterator;
 }
 
 #endif

Added: branches/quickbook-filenames/tools/quickbook/src/iterator.hpp
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/src/iterator.hpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -0,0 +1,93 @@
+/*=============================================================================
+ Copyright (c) 2010 Daniel James
+
+ Use, modification and distribution is subject to 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)
+=============================================================================*/
+
+#if !defined(BOOST_SPIRIT_QUICKBOOK_ITERATOR_HPP)
+#define BOOST_SPIRIT_QUICKBOOK_ITERATOR_HPP
+
+#include <boost/operators.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+
+namespace quickbook
+{
+ struct file_position
+ {
+ file_position() : line(0), column(0) {}
+ file_position(int l, int c) : line(l), column(c) {}
+
+ int line;
+ int column;
+ };
+
+ template <typename Iterator>
+ struct position_iterator
+ : boost::forward_iterator_helper<
+ position_iterator<Iterator>,
+ typename boost::iterator_value<Iterator>::type,
+ typename boost::iterator_difference<Iterator>::type,
+ typename boost::iterator_pointer<Iterator>::type,
+ typename boost::iterator_reference<Iterator>::type
+ >
+ {
+ position_iterator() {}
+ explicit position_iterator(Iterator base)
+ : base_(base), previous_('\0'), position_() {}
+ explicit position_iterator(Iterator base, file_position const& position)
+ : base_(base), previous_('\0'), position_(position) {}
+
+ friend bool operator==(
+ position_iterator const& x,
+ position_iterator const& y)
+ {
+ return x.base_ == y.base_;
+ }
+
+ position_iterator& operator++()
+ {
+ char val = *base_;
+
+ if (val == '\r') {
+ ++position_.line;
+ position_.column = 0;
+ }
+ else if (val == '\n') {
+ if (previous_ != '\r') {
+ ++position_.line;
+ position_.column = 0;
+ }
+ }
+ else {
+ ++position_.column;
+ }
+
+ previous_ = val;
+ ++base_;
+
+ return *this;
+ }
+
+ typename boost::iterator_reference<Iterator>::type operator*() const
+ {
+ return *base_;
+ }
+
+ file_position const& get_position() const {
+ return position_;
+ }
+
+ Iterator base() const {
+ return base_;
+ }
+
+ private:
+ Iterator base_;
+ char previous_;
+ file_position position_;
+ };
+}
+
+#endif

Modified: branches/quickbook-filenames/tools/quickbook/src/post_process.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/post_process.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/post_process.cpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -444,7 +444,7 @@
             else
             {
                 // fallback!
- ::quickbook::detail::outerr("")
+ ::quickbook::detail::outerr()
                     << "Warning: Post Processing Failed."
                     << std::endl;
                 out << in;
@@ -455,7 +455,7 @@
         catch(...)
         {
             // fallback!
- ::quickbook::detail::outerr("")
+ ::quickbook::detail::outerr()
                 << "Post Processing Failed."
                 << std::endl;
             out << in;

Modified: branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -13,7 +13,6 @@
 #include "post_process.hpp"
 #include "utils.hpp"
 #include "input_path.hpp"
-#include <boost/spirit/include/classic_iterator.hpp>
 #include <boost/program_options.hpp>
 #include <boost/filesystem/v3/path.hpp>
 #include <boost/filesystem/v3/operations.hpp>
@@ -49,8 +48,9 @@
                 end = preset_defines.end();
                 it != end; ++it)
         {
- iterator first(it->begin(), it->end(), "command line parameter");
- iterator last(it->end(), it->end());
+ // TODO: Set filename in actor???
+ iterator first(it->begin());
+ iterator last(it->end());
 
             cl::parse(first, last, actor.grammar().command_line_macro);
             // TODO: Check result?
@@ -76,8 +76,8 @@
             return err;
         }
 
- iterator first(storage.begin(), storage.end(), filein_);
- iterator last(storage.end(), storage.end());
+ iterator first(storage.begin());
+ iterator last(storage.end());
 
         cl::parse_info<iterator> info = cl::parse(first, last, actor.grammar().doc_info);
 
@@ -94,8 +94,8 @@
 
         if (!info.full)
         {
- position const pos = info.stop.get_position();
- detail::outerr(pos.file,pos.line)
+ file_position const& pos = info.stop.get_position();
+ detail::outerr(actor.filename, pos.line)
                 << "Syntax Error near column " << pos.column << ".\n";
             ++actor.error_count;
         }
@@ -117,7 +117,7 @@
 
         if(actor.error_count)
         {
- detail::outerr(filein_)
+ detail::outerr()
                 << "Error count: " << actor.error_count << ".\n";
         }
 
@@ -291,7 +291,7 @@
         }
         else
         {
- quickbook::detail::outerr("") << "Error: No filename given\n\n"
+ quickbook::detail::outerr() << "No filename given\n\n"
                 << desc << std::endl;
             return 1;
         }
@@ -299,13 +299,13 @@
 
     catch(std::exception& e)
     {
- quickbook::detail::outerr("") << "Error: " << e.what() << "\n";
+ quickbook::detail::outerr() << e.what() << "\n";
         return 1;
     }
 
     catch(...)
     {
- quickbook::detail::outerr("") << "Error: Exception of unknown type caught\n";
+ quickbook::detail::outerr() << "Exception of unknown type caught\n";
         return 1;
     }
 

Modified: branches/quickbook-filenames/tools/quickbook/src/syntax_highlight.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/syntax_highlight.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/syntax_highlight.hpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -57,7 +57,7 @@
                     | char_ [Process("char", self.out)]
                     | number [Process("number", self.out)]
                     | cl::repeat_p(1)[cl::anychar_p]
- [Unexpected(self.out)]
+ [Unexpected(self.out, self.escape_actions)]
                     )
                     ;
 
@@ -206,7 +206,7 @@
                     | string_ [Process("string", self.out)]
                     | number [Process("number", self.out)]
                     | cl::repeat_p(1)[cl::anychar_p]
- [Unexpected(self.out)]
+ [Unexpected(self.out, self.escape_actions)]
                     )
                     ;
 

Modified: branches/quickbook-filenames/tools/quickbook/src/template_stack.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/template_stack.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/template_stack.hpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -14,10 +14,11 @@
 #include <vector>
 #include <boost/tuple/tuple.hpp>
 #include <boost/assert.hpp>
-#include <boost/spirit/include/classic_position_iterator.hpp>
 #include <boost/spirit/include/classic_functor_parser.hpp>
 #include <boost/spirit/include/classic_symbols.hpp>
 #include <boost/next_prior.hpp>
+#include <boost/filesystem/path.hpp>
+#include "fwd.hpp"
 
 namespace quickbook
 {
@@ -25,30 +26,20 @@
     {
         template_body(
                 std::string const& content,
- boost::spirit::classic::file_position const& position,
+ boost::filesystem::path const& filename,
+ file_position const& position,
                 bool is_block
             )
             : content(content)
+ , filename(filename)
             , position(position)
             , is_block(is_block)
         {
         }
 
- template_body(
- std::string const& content,
- boost::spirit::classic::file_position_base<char const*> const& position,
- bool is_block
- )
- : content(content)
- , position(position.file, position.line, position.column)
- , is_block(is_block)
- {
- }
-
         std::string content;
- // Note: Using file_position to store the filename after the file
- // has been closed.
- boost::spirit::classic::file_position position;
+ boost::filesystem::path filename;
+ file_position position;
         bool is_block;
     };
 
@@ -60,26 +51,13 @@
                 std::string const& identifier,
                 std::vector<std::string> const& params,
                 std::string const& body,
- boost::spirit::classic::file_position const& position,
- bool is_block,
- template_scope const* parent = 0)
- : identifier(identifier)
- , params(params)
- , body(body, position, is_block)
- , parent(parent)
- , callout(false)
- , callouts() {}
-
- template_symbol(
- std::string const& identifier,
- std::vector<std::string> const& params,
- std::string const& body,
- boost::spirit::classic::file_position_base<char const*> const& position,
+ boost::filesystem::path const& filename,
+ file_position const& position,
                 bool is_block,
                 template_scope const* parent = 0)
            : identifier(identifier)
            , params(params)
- , body(body, position, is_block)
+ , body(body, filename, position, is_block)
            , parent(parent)
            , callout(false)
            , callouts() {}

Modified: branches/quickbook-filenames/tools/quickbook/src/utils.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/utils.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/utils.cpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -151,33 +151,38 @@
         return uri;
     }
 
- std::ostream& outerr(std::string const& file, int line)
+ std::ostream& outerr()
+ {
+ return std::clog << "Error: ";
+ }
+
+ std::ostream& outerr(boost::filesystem::path const& file, int line)
     {
         if (line >= 0)
         {
             if (ms_errors)
- return std::clog << file << "(" << line << "): error: ";
+ return std::clog << file.string() << "(" << line << "): error: ";
             else
- return std::clog << file << ":" << line << ": error: ";
+ return std::clog << file.string() << ":" << line << ": error: ";
         }
         else
         {
- return std::clog << file << ": error: ";
+ return std::clog << file.string() << ": error: ";
         }
     }
 
- std::ostream& outwarn(std::string const& file, int line)
+ std::ostream& outwarn(boost::filesystem::path const& file, int line)
     {
         if (line >= 0)
         {
             if (ms_errors)
- return std::clog << file << "(" << line << "): warning: ";
+ return std::clog << file.string() << "(" << line << "): warning: ";
             else
- return std::clog << file << ":" << line << ": warning: ";
+ return std::clog << file.string() << ":" << line << ": warning: ";
         }
         else
         {
- return std::clog << file << ": warning: ";
+ return std::clog << file.string() << ": warning: ";
         }
     }
 

Modified: branches/quickbook-filenames/tools/quickbook/src/utils.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/utils.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/utils.hpp 2011-01-23 11:42:51 EST (Sun, 23 Jan 2011)
@@ -15,6 +15,7 @@
 #include <cctype>
 #include <boost/ref.hpp>
 #include <boost/assert.hpp>
+#include <boost/filesystem/v3/path.hpp>
 
 namespace quickbook { namespace detail
 {
@@ -63,8 +64,9 @@
     // common IDEs. Uses the ms_errors global to determine if VS format
     // or GCC format. Returns the stream to continue ouput of the verbose
     // error message.
- std::ostream & outerr(std::string const& file, int line = -1);
- std::ostream & outwarn(std::string const& file, int line = -1);
+ std::ostream & outerr();
+ std::ostream & outerr(boost::filesystem::path const& file, int line = -1);
+ std::ostream & outwarn(boost::filesystem::path const& file, int line = -1);
 
     // load file into memory with extra trailing newlines to eliminate
     // the need to check for end of file in the grammar.


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