|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78554 - in trunk: boost/wave/util libs/wave/test/testwave libs/wave/test/testwave/testfiles
From: hartmut.kaiser_at_[hidden]
Date: 2012-05-23 10:38:14
Author: hkaiser
Date: 2012-05-23 10:38:10 EDT (Wed, 23 May 2012)
New Revision: 78554
URL: http://svn.boost.org/trac/boost/changeset/78554
Log:
Wave: Fixed #6838: Adding include file with force_include makes Wave fail to emit #line directive
Added support for test of --forceinclude option to testwave executable, added test case verifying #6838 is fixed.
Added:
trunk/libs/wave/test/testwave/testfiles/t_2_022.cpp (contents, props changed)
trunk/libs/wave/test/testwave/testfiles/t_2_022.hpp (contents, props changed)
Text files modified:
trunk/boost/wave/util/cpp_iterator.hpp | 624 ++++++++++++++++++++--------------------
trunk/libs/wave/test/testwave/testfiles/test.cfg | 1
trunk/libs/wave/test/testwave/testwave_app.cpp | 445 +++++++++++++++-------------
trunk/libs/wave/test/testwave/testwave_app.hpp | 63 ++-
4 files changed, 580 insertions(+), 553 deletions(-)
Modified: trunk/boost/wave/util/cpp_iterator.hpp
==============================================================================
--- trunk/boost/wave/util/cpp_iterator.hpp (original)
+++ trunk/boost/wave/util/cpp_iterator.hpp 2012-05-23 10:38:10 EDT (Wed, 23 May 2012)
@@ -5,7 +5,7 @@
http://www.boost.org/
- Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost
+ Copyright (c) 2001-2012 Hartmut Kaiser. 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)
=============================================================================*/
@@ -61,32 +61,32 @@
///////////////////////////////////////////////////////////////////////////////
// retrieve the macro name from the parse tree
template <
- typename ContextT, typename ParseNodeT, typename TokenT,
+ typename ContextT, typename ParseNodeT, typename TokenT,
typename PositionT
>
-inline bool
-retrieve_macroname(ContextT& ctx, ParseNodeT const &node,
+inline bool
+retrieve_macroname(ContextT& ctx, ParseNodeT const &node,
boost::spirit::classic::parser_id id, TokenT ¯oname, PositionT& act_pos,
bool update_position)
{
ParseNodeT const *name_node = 0;
using boost::spirit::classic::find_node;
- if (!find_node(node, id, &name_node))
+ if (!find_node(node, id, &name_node))
{
// ill formed define statement (unexpected, should not happen)
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_define_statement,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_define_statement,
"bad parse tree (unexpected)", act_pos);
return false;
}
typename ParseNodeT::children_t const &children = name_node->children;
- if (0 == children.size() ||
- children.front().value.begin() == children.front().value.end())
+ if (0 == children.size() ||
+ children.front().value.begin() == children.front().value.end())
{
// ill formed define statement (unexpected, should not happen)
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_define_statement,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_define_statement,
"bad parse tree (unexpected)", act_pos);
return false;
}
@@ -103,9 +103,9 @@
///////////////////////////////////////////////////////////////////////////////
// retrieve the macro parameters or the macro definition from the parse tree
template <typename ParseNodeT, typename ContainerT, typename PositionT>
-inline bool
+inline bool
retrieve_macrodefinition(
- ParseNodeT const &node, boost::spirit::classic::parser_id id,
+ ParseNodeT const &node, boost::spirit::classic::parser_id id,
ContainerT ¯odefinition, PositionT& act_pos, bool update_position)
{
using namespace boost::wave;
@@ -163,7 +163,7 @@
typedef typename ContextT::token_type token_type;
typedef typename ContextT::lexer_type lexer_type;
typedef typename token_type::position_type position_type;
- typedef boost::wave::grammars::predefined_macros_grammar_gen<lexer_type>
+ typedef boost::wave::grammars::predefined_macros_grammar_gen<lexer_type>
predef_macros_type;
using namespace boost::wave;
@@ -178,12 +178,12 @@
// parse the macro definition
position_type act_pos("<command line>");
-boost::spirit::classic::tree_parse_info<lexer_type> hit =
+boost::spirit::classic::tree_parse_info<lexer_type> hit =
predef_macros_type::parse_predefined_macro(
lexer_type(begin, end, position_type(), language), lexer_type());
if (!hit.match || (!hit.full && T_EOF != token_id(*hit.stop))) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_macro_definition,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_macro_definition,
macrostring.c_str(), act_pos);
return false;
}
@@ -194,24 +194,24 @@
typename ContextT::token_sequence_type macrodefinition;
bool has_parameters = false;
- if (!boost::wave::util::retrieve_macroname(ctx, *hit.trees.begin(),
+ if (!boost::wave::util::retrieve_macroname(ctx, *hit.trees.begin(),
BOOST_WAVE_PLAIN_DEFINE_ID, macroname, act_pos, true))
return false;
- has_parameters = boost::wave::util::retrieve_macrodefinition(*hit.trees.begin(),
+ has_parameters = boost::wave::util::retrieve_macrodefinition(*hit.trees.begin(),
BOOST_WAVE_MACRO_PARAMETERS_ID, macroparameters, act_pos, true);
- boost::wave::util::retrieve_macrodefinition(*hit.trees.begin(),
+ boost::wave::util::retrieve_macrodefinition(*hit.trees.begin(),
BOOST_WAVE_MACRO_DEFINITION_ID, macrodefinition, act_pos, true);
-// If no macrodefinition is given, and the macro string does not end with a
+// If no macrodefinition is given, and the macro string does not end with a
// '=', then the macro should be defined with the value '1'
- if (0 == macrodefinition.size() &&
+ if (0 == macrodefinition.size() &&
'=' != macrostring[macrostring.size()-1])
{
macrodefinition.push_back(token_type(T_INTLIT, "1", act_pos));
}
// add the new macro to the macromap
- return ctx.add_macro_definition(macroname, has_parameters, macroparameters,
+ return ctx.add_macro_definition(macroname, has_parameters, macroparameters,
macrodefinition, is_predefined);
}
#endif // BOOST_WAVE_ENABLE_COMMANDLINE_MACROS != 0
@@ -226,11 +226,11 @@
namespace impl {
///////////////////////////////////////////////////////////////////////////////
-//
+//
// pp_iterator_functor
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
+template <typename ContextT>
class pp_iterator_functor {
public:
@@ -247,7 +247,7 @@
typedef typename ContextT::lexer_type lexer_type;
typedef typename result_type::string_type string_type;
typedef typename result_type::position_type position_type;
- typedef boost::wave::grammars::cpp_grammar_gen<lexer_type, token_sequence_type>
+ typedef boost::wave::grammars::cpp_grammar_gen<lexer_type, token_sequence_type>
cpp_grammar_type;
// iteration context related types (an iteration context represents a current
@@ -258,9 +258,9 @@
// parse tree related types
typedef typename cpp_grammar_type::node_factory_type node_factory_type;
- typedef boost::spirit::classic::tree_parse_info<lexer_type, node_factory_type>
+ typedef boost::spirit::classic::tree_parse_info<lexer_type, node_factory_type>
tree_parse_info_type;
- typedef boost::spirit::classic::tree_match<lexer_type, node_factory_type>
+ typedef boost::spirit::classic::tree_match<lexer_type, node_factory_type>
parse_tree_match_type;
typedef typename parse_tree_match_type::node_t parse_node_type; // tree_node<node_val_data<> >
typedef typename parse_tree_match_type::parse_node_t parse_node_value_type; // node_val_data<>
@@ -268,16 +268,16 @@
public:
template <typename IteratorT>
- pp_iterator_functor(ContextT &ctx_, IteratorT const &first_,
+ pp_iterator_functor(ContextT &ctx_, IteratorT const &first_,
IteratorT const &last_, typename ContextT::position_type const &pos_)
- : ctx(ctx_),
+ : ctx(ctx_),
iter_ctx(new base_iteration_context_type(ctx,
- lexer_type(first_, last_, pos_,
- boost::wave::enable_prefer_pp_numbers(ctx.get_language())),
- lexer_type(),
+ lexer_type(first_, last_, pos_,
+ boost::wave::enable_prefer_pp_numbers(ctx.get_language())),
+ lexer_type(),
pos_.get_file().c_str()
- )),
- seen_newline(true), skipped_newline(false),
+ )),
+ seen_newline(true), skipped_newline(false),
must_emit_line_directive(false), act_pos(ctx_.get_main_pos()),
whitespace(boost::wave::need_insert_whitespace(ctx.get_language()))
{
@@ -296,7 +296,7 @@
protected:
friend class pp_iterator<ContextT>;
- bool on_include_helper(char const *t, char const *s, bool is_system,
+ bool on_include_helper(char const *t, char const *s, bool is_system,
bool include_next);
protected:
@@ -369,10 +369,10 @@
token_sequence_type unput_queue; // tokens to be preprocessed again
token_sequence_type pending_queue; // tokens already preprocessed
- // detect whether to insert additional whitespace in between two adjacent
- // tokens, which otherwise would form a different token type, if
+ // detect whether to insert additional whitespace in between two adjacent
+ // tokens, which otherwise would form a different token type, if
// re-tokenized
- boost::wave::util::insert_whitespace_detection whitespace;
+ boost::wave::util::insert_whitespace_detection whitespace;
};
///////////////////////////////////////////////////////////////////////////////
@@ -384,14 +384,14 @@
///////////////////////////////////////////////////////////////////////////////
//
// returned_from_include()
-//
+//
// Tests if it is necessary to pop the include file context (eof inside
// a file was reached). If yes, it pops this context. Preprocessing will
// continue with the next outer file scope.
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline bool
+template <typename ContextT>
+inline bool
pp_iterator_functor<ContextT>::returned_from_include()
{
if (iter_ctx->first == iter_ctx->last && ctx.get_iteration_depth() > 0) {
@@ -402,7 +402,7 @@
ctx.get_hooks().returning_from_include_file(ctx.derived());
#endif
- // restore the previous iteration context after finishing the preprocessing
+ // restore the previous iteration context after finishing the preprocessing
// of the included file
BOOST_WAVE_STRINGTYPE oldfile = iter_ctx->real_filename;
position_type old_pos (act_pos);
@@ -414,7 +414,7 @@
if (iter_ctx->first.has_include_guards(guard_name))
ctx.add_pragma_once_header(ctx.get_current_filename(), guard_name);
}
-#endif
+#endif
iter_ctx = ctx.pop_iteration_context();
must_emit_line_directive = true;
@@ -426,13 +426,13 @@
act_pos.set_line(iter_ctx->line);
act_pos.set_column(0);
- // restore the actual current file and directory
+ // restore the actual current file and directory
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
namespace fs = boost::filesystem;
fs::path rfp(wave::util::create_path(iter_ctx->real_filename.c_str()));
std::string real_filename(rfp.string());
ctx.set_current_filename(real_filename.c_str());
-#endif
+#endif
ctx.set_current_directory(iter_ctx->real_filename.c_str());
ctx.set_current_relative_filename(iter_ctx->real_relative_filename.c_str());
@@ -441,7 +441,7 @@
if (iter_ctx->if_block_depth != ctx.get_if_block_depth()) {
using boost::wave::util::impl::escape_lit;
BOOST_WAVE_STRINGTYPE msg(escape_lit(oldfile));
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, unbalanced_if_endif,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, unbalanced_if_endif,
msg.c_str(), old_pos);
}
return true;
@@ -458,12 +458,12 @@
///////////////////////////////////////////////////////////////////////////////
namespace impl {
- // It may be necessary to emit a #line directive either
- // - when comments need to be preserved: if the current token is not a
+ // It may be necessary to emit a #line directive either
+ // - when comments need to be preserved: if the current token is not a
// whitespace, except comments
- // - when comments are to be skipped: if the current token is not a
+ // - when comments are to be skipped: if the current token is not a
// whitespace token.
- template <typename ContextT>
+ template <typename ContextT>
bool consider_emitting_line_directive(ContextT const& ctx, token_id id)
{
if (need_preserve_comments(ctx.get_language())) {
@@ -472,7 +472,7 @@
return true;
}
}
- if (!IS_CATEGORY(id, WhiteSpaceTokenType) &&
+ if (!IS_CATEGORY(id, WhiteSpaceTokenType) &&
!IS_CATEGORY(id, EOLTokenType) && !IS_CATEGORY(id, EOFTokenType))
{
return true;
@@ -481,7 +481,7 @@
}
}
-template <typename ContextT>
+template <typename ContextT>
inline typename pp_iterator_functor<ContextT>::result_type const &
pp_iterator_functor<ContextT>::operator()()
{
@@ -519,11 +519,11 @@
}
// if there were skipped any newlines, we must emit a #line directive
- if ((must_emit_line_directive || (was_seen_newline && skipped_newline)) &&
- impl::consider_emitting_line_directive(ctx, id))
+ if ((must_emit_line_directive || (was_seen_newline && skipped_newline)) &&
+ impl::consider_emitting_line_directive(ctx, id))
{
// must emit a #line directive
- if (need_emit_line_directives(ctx.get_language()) && emit_line_directive())
+ if (need_emit_line_directives(ctx.get_language()) && emit_line_directive())
{
skipped_newline = false;
ctx.get_hooks().may_skip_whitespace(ctx.derived(), act_token, skipped_newline); // feed ws eater FSM
@@ -552,13 +552,13 @@
#if BOOST_WAVE_SUPPORT_CPP0X != 0
case T_RAWSTRINGLIT:
- iter_ctx->emitted_lines +=
+ iter_ctx->emitted_lines +=
context_policies::util::rawstring_count_newlines(act_token);
break;
#endif
case T_CCOMMENT: // will come here only if whitespace is preserved
- iter_ctx->emitted_lines +=
+ iter_ctx->emitted_lines +=
context_policies::util::ccomment_count_newlines(act_token);
break;
@@ -569,12 +569,12 @@
std::string pp_number(
util::to_string<std::string>(act_token.get_value()));
- lexer_type it = lexer_type(pp_number.begin(),
- pp_number.end(), act_token.get_position(),
+ lexer_type it = lexer_type(pp_number.begin(),
+ pp_number.end(), act_token.get_position(),
ctx.get_language());
lexer_type end = lexer_type();
- for (/**/; it != end && T_EOF != token_id(*it); ++it)
+ for (/**/; it != end && T_EOF != token_id(*it); ++it)
rescanned.push_back(*it);
pending_queue.splice(pending_queue.begin(), rescanned);
@@ -599,8 +599,8 @@
// tokens, which would form different (and wrong) tokens
whitespace.shift_tokens(T_SPACE);
pending_queue.push_front(act_token); // push this token back
- return act_token = result_type(T_SPACE,
- typename result_type::string_type(" "),
+ return act_token = result_type(T_SPACE,
+ typename result_type::string_type(" "),
act_token.get_position());
}
whitespace.shift_tokens(id);
@@ -608,7 +608,7 @@
}
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
+template <typename ContextT>
inline typename pp_iterator_functor<ContextT>::result_type const &
pp_iterator_functor<ContextT>::get_next_token()
{
@@ -616,21 +616,21 @@
// if there is something in the unput_queue, then return the next token from
// there (all tokens in the queue are preprocessed already)
- if (!pending_queue.empty() || !unput_queue.empty())
+ if (!pending_queue.empty() || !unput_queue.empty())
return pp_token(); // return next token
// test for EOF, if there is a pending input context, pop it back and continue
// parsing with it
bool returned_from_include_file = returned_from_include();
-// try to generate the next token
+// try to generate the next token
if (iter_ctx->first != iter_ctx->last) {
do {
- // If there are pending tokens in the queue, we'll have to return
+ // If there are pending tokens in the queue, we'll have to return
// these. This may happen from a #pragma directive, which got replaced
// by some token sequence.
if (!pending_queue.empty()) {
- util::on_exit::pop_front<token_sequence_type>
+ util::on_exit::pop_front<token_sequence_type>
pop_front_token(pending_queue);
return act_token = pending_queue.front();
@@ -652,16 +652,16 @@
++iter_ctx->first;
// now make sure this line has a newline
- if ((!seen_newline || act_pos.get_column() > 1) &&
- !need_single_line(ctx.get_language()))
+ if ((!seen_newline || act_pos.get_column() > 1) &&
+ !need_single_line(ctx.get_language()))
{
// warn, if this file does not end with a newline
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
last_line_not_terminated, "", act_pos);
}
continue; // if this is the main file, the while loop breaks
}
- else if (T_NEWLINE == id || T_CPPCOMMENT == id) {
+ else if (T_NEWLINE == id || T_CPPCOMMENT == id) {
// a newline is to be returned ASAP, a C++ comment too
// (the C++ comment token includes the trailing newline)
seen_newline = true;
@@ -673,7 +673,7 @@
util::impl::call_skipped_token_hook(ctx, act_token);
continue;
}
- return act_token;
+ return act_token;
}
seen_newline = false;
@@ -684,17 +684,17 @@
// must_emit_line_directive = true;
// loop to the next token to analyze
- // simply fall through, since the iterator was already adjusted
+ // simply fall through, since the iterator was already adjusted
// correctly
}
else if (ctx.get_if_block_status()) {
- // preprocess this token, eat up more, if appropriate, return
+ // preprocess this token, eat up more, if appropriate, return
// the next preprocessed token
return pp_token();
}
else {
- // compilation condition is false: if the current token is a
- // newline, account for it, otherwise discard the actual token and
+ // compilation condition is false: if the current token is a
+ // newline, account for it, otherwise discard the actual token and
// try the next one
if (T_NEWLINE == token_id(act_token)) {
seen_newline = true;
@@ -706,14 +706,14 @@
++iter_ctx->first;
}
- } while ((iter_ctx->first != iter_ctx->last) ||
+ } while ((iter_ctx->first != iter_ctx->last) ||
(returned_from_include_file = returned_from_include()));
// overall eof reached
- if (ctx.get_if_block_depth() > 0 && !need_single_line(ctx.get_language()))
+ if (ctx.get_if_block_depth() > 0 && !need_single_line(ctx.get_language()))
{
// missing endif directive(s)
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
missing_matching_endif, "", act_pos);
}
}
@@ -730,7 +730,7 @@
// emit_line_directive(): emits a line directive from the act_token data
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
+template <typename ContextT>
inline bool
pp_iterator_functor<ContextT>::emit_line_directive()
{
@@ -738,7 +738,7 @@
typename ContextT::position_type pos = act_token.get_position();
-// if (must_emit_line_directive &&
+// if (must_emit_line_directive &&
// iter_ctx->emitted_lines+1 == act_pos.get_line() &&
// iter_ctx->filename == act_pos.get_file())
// {
@@ -746,14 +746,14 @@
// return false;
// }
- if (must_emit_line_directive ||
- iter_ctx->emitted_lines+1 != act_pos.get_line())
+ if (must_emit_line_directive ||
+ iter_ctx->emitted_lines+1 != act_pos.get_line())
{
// unput the current token
pending_queue.push_front(act_token);
pos.set_line(act_pos.get_line());
- if (iter_ctx->emitted_lines+2 == act_pos.get_line()) {
+ if (iter_ctx->emitted_lines+2 == act_pos.get_line() && act_pos.get_line() != 1) {
// prefer to output a single newline instead of the #line directive
// whitespace.shift_tokens(T_NEWLINE);
act_token = result_type(T_NEWLINE, "\n", pos);
@@ -776,7 +776,7 @@
pos.set_column(column); // account for '#line'
pending.push_back(result_type(T_SPACE, " ", pos));
- // 21 is the max required size for a 64 bit integer represented as a
+ // 21 is the max required size for a 64 bit integer represented as a
// string
char buffer[22];
@@ -822,7 +822,7 @@
// pptoken(): return the next preprocessed token
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
+template <typename ContextT>
inline typename pp_iterator_functor<ContextT>::result_type const &
pp_iterator_functor<ContextT>::pp_token()
{
@@ -832,7 +832,7 @@
// eat all T_PLACEHOLDER tokens, eventually slipped through out of the
// macro engine
- do {
+ do {
if (!pending_queue.empty()) {
// if there are pending tokens in the queue, return the first one
act_token = pending_queue.front();
@@ -840,14 +840,14 @@
act_pos = act_token.get_position();
}
else if (!unput_queue.empty()
- || T_IDENTIFIER == id
+ || T_IDENTIFIER == id
|| IS_CATEGORY(id, KeywordTokenType)
|| IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType)
|| IS_CATEGORY(id, BoolLiteralTokenType))
{
// call the lexer, preprocess the required number of tokens, put them
// into the unput queue
- act_token = ctx.expand_tokensequence(iter_ctx->first,
+ act_token = ctx.expand_tokensequence(iter_ctx->first,
iter_ctx->last, pending_queue, unput_queue, skipped_newline);
}
else {
@@ -870,11 +870,11 @@
// call 'found_directive' preprocessing hook
template <typename ContextT>
- bool call_found_directive_hook(ContextT& ctx,
+ bool call_found_directive_hook(ContextT& ctx,
typename ContextT::token_type const& found_directive)
{
#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
- ctx.get_hooks().found_directive(found_directive);
+ ctx.get_hooks().found_directive(found_directive);
#else
if (ctx.get_hooks().found_directive(ctx.derived(), found_directive))
return true; // skip this directive and return newline only
@@ -884,11 +884,11 @@
// // call 'skipped_token' preprocessing hook
// template <typename ContextT>
-// void call_skipped_token_hook(ContextT& ctx,
+// void call_skipped_token_hook(ContextT& ctx,
// typename ContextT::token_type const& skipped)
// {
// #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
-// ctx.get_hooks().skipped_token(skipped);
+// ctx.get_hooks().skipped_token(skipped);
// #else
// ctx.get_hooks().skipped_token(ctx.derived(), skipped);
// #endif
@@ -907,7 +907,7 @@
if (IS_CATEGORY(id, EOLTokenType) || IS_CATEGORY(id, EOFTokenType))
break; // do not enter a new line
if (T_CPPCOMMENT == id ||
- context_policies::util::ccomment_has_newline(*it))
+ context_policies::util::ccomment_has_newline(*it))
{
break;
}
@@ -934,7 +934,7 @@
token_id id = token_id(*it);
if (T_CPPCOMMENT == id || T_NEWLINE == id ||
- context_policies::util::ccomment_has_newline(*it))
+ context_policies::util::ccomment_has_newline(*it))
{
if (call_hook)
util::impl::call_skipped_token_hook(ctx, *it);
@@ -954,7 +954,7 @@
///////////////////////////////////////////////////////////////////////////
template <typename ContextT, typename IteratorT>
- bool skip_to_eol(ContextT &ctx, IteratorT &it, IteratorT const &end,
+ bool skip_to_eol(ContextT &ctx, IteratorT &it, IteratorT const &end,
bool call_hook = true)
{
using namespace boost::wave;
@@ -963,9 +963,9 @@
token_id id = token_id(*it);
if (T_CPPCOMMENT == id || T_NEWLINE == id ||
- context_policies::util::ccomment_has_newline(*it))
+ context_policies::util::ccomment_has_newline(*it))
{
- // always call hook for eol
+ // always call hook for eol
util::impl::call_skipped_token_hook(ctx, *it);
++it; // skip eol/C/C++ comment
return true; // found eol
@@ -995,12 +995,12 @@
///////////////////////////////////////////////////////////////////////////////
template <typename ContextT>
template <typename IteratorT>
-inline bool
+inline bool
pp_iterator_functor<ContextT>::extract_identifier(IteratorT &it)
{
token_id id = util::impl::skip_whitespace(it, iter_ctx->last);
- if (T_IDENTIFIER == id || IS_CATEGORY(id, KeywordTokenType) ||
- IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) ||
+ if (T_IDENTIFIER == id || IS_CATEGORY(id, KeywordTokenType) ||
+ IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) ||
IS_CATEGORY(id, BoolLiteralTokenType))
{
IteratorT save = it;
@@ -1022,10 +1022,10 @@
///////////////////////////////////////////////////////////////////////////////
template <typename ContextT>
template <typename IteratorT>
-inline bool
+inline bool
pp_iterator_functor<ContextT>::ensure_is_last_on_line(IteratorT& it, bool call_hook)
{
- if (!impl::pp_is_last_on_line(ctx, it, iter_ctx->last, call_hook))
+ if (!impl::pp_is_last_on_line(ctx, it, iter_ctx->last, call_hook))
{
// enable error recovery (start over with the next line)
impl::skip_to_eol(ctx, it, iter_ctx->last);
@@ -1041,15 +1041,15 @@
return false;
}
- if (it == iter_ctx->last && !need_single_line(ctx.get_language()))
+ if (it == iter_ctx->last && !need_single_line(ctx.get_language()))
{
// The line doesn't end with an eol but eof token.
seen_newline = true; // allow to resume after warning
iter_ctx->first = it;
- // Trigger a warning that the last line was not terminated with a
+ // Trigger a warning that the last line was not terminated with a
// newline.
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
last_line_not_terminated, "", act_pos);
return false;
@@ -1059,20 +1059,20 @@
template <typename ContextT>
template <typename IteratorT>
-inline bool
+inline bool
pp_iterator_functor<ContextT>::skip_to_eol_with_check(IteratorT &it, bool call_hook)
{
typename ContextT::string_type value ((*it).get_value());
if (!impl::skip_to_eol(ctx, it, iter_ctx->last, call_hook) &&
- !need_single_line(ctx.get_language()))
+ !need_single_line(ctx.get_language()))
{
// The line doesn't end with an eol but eof token.
seen_newline = true; // allow to resume after warning
iter_ctx->first = it;
- // Trigger a warning, that the last line was not terminated with a
+ // Trigger a warning, that the last line was not terminated with a
// newline.
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
last_line_not_terminated, "", act_pos);
return false;
}
@@ -1084,8 +1084,8 @@
}
///////////////////////////////////////////////////////////////////////////////
-// handle_pp_directive: handle certain pp_directives
-template <typename ContextT>
+// handle_pp_directive: handle certain pp_directives
+template <typename ContextT>
template <typename IteratorT>
inline bool
pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it)
@@ -1105,9 +1105,9 @@
case T_PP_ELIF: // #elif
if (!ctx.get_enclosing_if_block_status()) {
- if (!ctx.enter_elif_block(false)) {
+ if (!ctx.enter_elif_block(false)) {
// #else without matching #if
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
missing_matching_if, "#elif", act_pos);
return true; // do not analyze this directive any further
}
@@ -1126,7 +1126,7 @@
else
on_endif();
- // make sure, there are no (non-whitespace) tokens left on
+ // make sure, there are no (non-whitespace) tokens left on
// this line
ensure_is_last_on_line(it);
@@ -1156,11 +1156,11 @@
case T_PP_QHEADER_NEXT:
#endif
include_next = (T_PP_QHEADER_NEXT == id) ? true : false;
- if (!impl::call_found_directive_hook(ctx, *it))
+ if (!impl::call_found_directive_hook(ctx, *it))
{
string_type dir((*it).get_value());
- // make sure, there are no (non-whitespace) tokens left on
+ // make sure, there are no (non-whitespace) tokens left on
// this line
if (ensure_is_last_on_line(it))
{
@@ -1177,11 +1177,11 @@
case T_PP_HHEADER_NEXT:
#endif
include_next = (T_PP_HHEADER_NEXT == id) ? true : false;
- if (!impl::call_found_directive_hook(ctx, *it))
+ if (!impl::call_found_directive_hook(ctx, *it))
{
string_type dir((*it).get_value());
- // make sure, there are no (non-whitespace) tokens left on
+ // make sure, there are no (non-whitespace) tokens left on
// this line
if (ensure_is_last_on_line(it))
{
@@ -1203,7 +1203,7 @@
else
on_endif();
- // make sure, there are no (non-whitespace) tokens left on
+ // make sure, there are no (non-whitespace) tokens left on
// this line
ensure_is_last_on_line(it);
@@ -1225,8 +1225,8 @@
// extract first non-whitespace token as argument
case T_PP_UNDEF: // #undef
- if (!impl::call_found_directive_hook(ctx, *it) &&
- extract_identifier(it))
+ if (!impl::call_found_directive_hook(ctx, *it) &&
+ extract_identifier(it))
{
on_undefine(it);
}
@@ -1234,8 +1234,8 @@
break;
case T_PP_IFDEF: // #ifdef
- if (!impl::call_found_directive_hook(ctx, *it) &&
- extract_identifier(it))
+ if (!impl::call_found_directive_hook(ctx, *it) &&
+ extract_identifier(it))
{
on_ifdef(directive, it);
}
@@ -1243,8 +1243,8 @@
break;
case T_PP_IFNDEF: // #ifndef
- if (!impl::call_found_directive_hook(ctx, *it) &&
- extract_identifier(it))
+ if (!impl::call_found_directive_hook(ctx, *it) &&
+ extract_identifier(it))
{
on_ifndef(directive, it);
}
@@ -1254,8 +1254,8 @@
#if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
// case T_MSEXT_PP_REGION: // #region ...
// break;
-//
-// case T_MSEXT_PP_ENDREGION: // #endregion
+//
+// case T_MSEXT_PP_ENDREGION: // #endregion
// break;
#endif
@@ -1275,7 +1275,7 @@
///////////////////////////////////////////////////////////////////////////////
// pp_directive(): recognize a preprocessor directive
-template <typename ContextT>
+template <typename ContextT>
inline bool
pp_iterator_functor<ContextT>::pp_directive()
{
@@ -1331,7 +1331,7 @@
// ignore/handle all pp directives not related to conditional compilation while
// if block status is false
if (handle_pp_directive(it)) {
- // we may skip pp directives only if the current if block status is
+ // we may skip pp directives only if the current if block status is
// false or if it was a #include directive we could handle directly
return true; // the pp directive has been handled/skipped
}
@@ -1345,21 +1345,21 @@
it, iter_ctx->last, act_pos, found_eof, found_directive, found_eoltokens);
if (hit.match) {
- // position the iterator past the matched sequence to allow
+ // position the iterator past the matched sequence to allow
// resynchronization, if an error occurs
iter_ctx->first = hit.stop;
seen_newline = true;
must_emit_line_directive = true;
- // found a valid pp directive, dispatch to the correct function to handle
+ // found a valid pp directive, dispatch to the correct function to handle
// the found pp directive
bool result = dispatch_directive (hit, found_directive, found_eoltokens);
if (found_eof && !need_single_line(ctx.get_language())) {
// The line was terminated with an end of file token.
- // So trigger a warning, that the last line was not terminated with a
+ // So trigger a warning, that the last line was not terminated with a
// newline.
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
last_line_not_terminated, "", act_pos);
}
return result;
@@ -1384,7 +1384,7 @@
// dispatch_directive(): dispatch a recognized preprocessor directive
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
+template <typename ContextT>
inline bool
pp_iterator_functor<ContextT>::dispatch_directive(
tree_parse_info_type const &hit, result_type const& found_directive,
@@ -1408,30 +1408,30 @@
token_id id = token_id(found_directive);
// call preprocessing hook
- if (impl::call_found_directive_hook(ctx, found_directive))
+ if (impl::call_found_directive_hook(ctx, found_directive))
return true; // skip this directive and return newline only
switch (static_cast<unsigned int>(id)) {
// case T_PP_QHEADER: // #include "..."
// #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
// case T_PP_QHEADER_NEXT: // #include_next "..."
-// #endif
-// on_include ((*nodeval.begin()).get_value(), false,
+// #endif
+// on_include ((*nodeval.begin()).get_value(), false,
// T_PP_QHEADER_NEXT == id);
// break;
// case T_PP_HHEADER: // #include <...>
// #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
// case T_PP_HHEADER_NEXT: // #include_next <...>
-// #endif
-// on_include ((*nodeval.begin()).get_value(), true,
+// #endif
+// on_include ((*nodeval.begin()).get_value(), true,
// T_PP_HHEADER_NEXT == id);
// break;
-
+
case T_PP_INCLUDE: // #include ...
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
case T_PP_INCLUDE_NEXT: // #include_next ...
-#endif
+#endif
on_include (begin_child_it, end_child_it, T_PP_INCLUDE_NEXT == id);
break;
@@ -1442,11 +1442,11 @@
// case T_PP_UNDEF: // #undef
// on_undefine(*nodeval.begin());
// break;
-//
+//
// case T_PP_IFDEF: // #ifdef
// on_ifdef(found_directive, begin_child_it, end_child_it);
// break;
-//
+//
// case T_PP_IFNDEF: // #ifndef
// on_ifndef(found_directive, begin_child_it, end_child_it);
// break;
@@ -1479,7 +1479,7 @@
case T_PP_WARNING: // #warning
on_warning(begin_child_it, end_child_it);
break;
-#endif
+#endif
case T_PP_PRAGMA: // #pragma
return on_pragma(begin_child_it, end_child_it);
@@ -1492,14 +1492,14 @@
default: // #something else
on_illformed((*nodeval.begin()).get_value());
-
- // if we end up here, we have been instructed to ignore the error, so
+
+ // if we end up here, we have been instructed to ignore the error, so
// we simply copy the whole construct to the output
{
token_sequence_type expanded;
get_token_value<result_type, parse_node_type> get_value;
- std::copy(make_ref_transform_iterator(begin_child_it, get_value),
+ std::copy(make_ref_transform_iterator(begin_child_it, get_value),
make_ref_transform_iterator(end_child_it, get_value),
std::inserter(expanded, expanded.end()));
pending_queue.splice(pending_queue.begin(), expanded);
@@ -1514,14 +1514,14 @@
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_include: handle #include <...> or #include "..." directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
-pp_iterator_functor<ContextT>::on_include (string_type const &s,
- bool is_system, bool include_next)
+template <typename ContextT>
+inline void
+pp_iterator_functor<ContextT>::on_include (string_type const &s,
+ bool is_system, bool include_next)
{
BOOST_ASSERT(ctx.get_if_block_status());
@@ -1529,16 +1529,16 @@
typename string_type::size_type pos_end = s.find_last_of(is_system ? '>' : '\"');
if (string_type::npos == pos_end) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement,
s.c_str(), act_pos);
return;
}
-typename string_type::size_type pos_begin =
+typename string_type::size_type pos_begin =
s.find_last_of(is_system ? '<' : '\"', pos_end-1);
if (string_type::npos == pos_begin) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement,
s.c_str(), act_pos);
return;
}
@@ -1547,14 +1547,14 @@
std::string file_path(s.substr(pos_begin+1, pos_end-pos_begin-1).c_str());
// finally include the file
- on_include_helper(file_token.c_str(), file_path.c_str(), is_system,
+ on_include_helper(file_token.c_str(), file_path.c_str(), is_system,
include_next);
}
-template <typename ContextT>
-inline bool
-pp_iterator_functor<ContextT>::on_include_helper (char const *f, char const *s,
- bool is_system, bool include_next)
+template <typename ContextT>
+inline bool
+pp_iterator_functor<ContextT>::on_include_helper (char const *f, char const *s,
+ bool is_system, bool include_next)
{
namespace fs = boost::filesystem;
@@ -1572,31 +1572,31 @@
ctx.get_hooks().found_include_directive(f, include_next);
#else
if (ctx.get_hooks().found_include_directive(ctx.derived(), f, include_next))
- return true; // client returned false: skip file to include
+ return true; // client returned false: skip file to include
#endif
file_path = util::impl::unescape_lit(file_path);
std::string native_path_str;
- if (!ctx.get_hooks().locate_include_file(ctx, file_path, is_system,
- current_name, dir_path, native_path_str))
+ if (!ctx.get_hooks().locate_include_file(ctx, file_path, is_system,
+ current_name, dir_path, native_path_str))
{
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_file,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_file,
file_path.c_str(), act_pos);
return false;
}
// test, if this file is known through a #pragma once directive
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
- if (!ctx.has_pragma_once(native_path_str))
-#endif
+ if (!ctx.has_pragma_once(native_path_str))
+#endif
{
// the new include file determines the actual current directory
ctx.set_current_directory(native_path_str.c_str());
// preprocess the opened file
boost::shared_ptr<base_iteration_context_type> new_iter_ctx (
- new iteration_context_type(ctx, native_path_str.c_str(), act_pos,
+ new iteration_context_type(ctx, native_path_str.c_str(), act_pos,
boost::wave::enable_prefer_pp_numbers(ctx.get_language()),
is_system ? base_iteration_context_type::system_header :
base_iteration_context_type::user_header));
@@ -1628,7 +1628,7 @@
fs::path rfp(wave::util::create_path(iter_ctx->real_filename.c_str()));
std::string real_filename(rfp.string());
ctx.set_current_filename(real_filename.c_str());
-#endif
+#endif
ctx.set_current_relative_filename(dir_path.c_str());
iter_ctx->real_relative_filename = dir_path.c_str();
@@ -1640,7 +1640,7 @@
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_include(): handle #include ... directives
//
///////////////////////////////////////////////////////////////////////////////
@@ -1649,7 +1649,7 @@
// trim all whitespace from the beginning and the end of the given string
template <typename StringT>
- inline StringT
+ inline StringT
trim_whitespace(StringT const &s)
{
typedef typename StringT::size_type size_type;
@@ -1662,8 +1662,8 @@
}
}
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_include(
typename parse_tree_type::const_iterator const &begin,
typename parse_tree_type::const_iterator const &end, bool include_next)
@@ -1675,12 +1675,12 @@
token_sequence_type expanded;
token_sequence_type toexpand;
- std::copy(make_ref_transform_iterator(begin, get_value),
+ std::copy(make_ref_transform_iterator(begin, get_value),
make_ref_transform_iterator(end, get_value),
std::inserter(toexpand, toexpand.end()));
typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded,
+ ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded,
false);
// now, include the file
@@ -1689,7 +1689,7 @@
if (!is_system && !('\"' == s[0] && '\"' == s[s.size()-1])) {
// should resolve into something like <...> or "..."
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement,
s.c_str(), act_pos);
return;
}
@@ -1697,14 +1697,14 @@
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_define(): handle #define directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
-pp_iterator_functor<ContextT>::on_define (parse_node_type const &node)
+template <typename ContextT>
+inline void
+pp_iterator_functor<ContextT>::on_define (parse_node_type const &node)
{
BOOST_ASSERT(ctx.get_if_block_status());
@@ -1715,12 +1715,12 @@
bool has_parameters = false;
position_type pos(act_token.get_position());
- if (!boost::wave::util::retrieve_macroname(ctx, node,
+ if (!boost::wave::util::retrieve_macroname(ctx, node,
BOOST_WAVE_PLAIN_DEFINE_ID, macroname, pos, false))
return;
- has_parameters = boost::wave::util::retrieve_macrodefinition(node,
+ has_parameters = boost::wave::util::retrieve_macrodefinition(node,
BOOST_WAVE_MACRO_PARAMETERS_ID, macroparameters, pos, false);
- boost::wave::util::retrieve_macrodefinition(node,
+ boost::wave::util::retrieve_macrodefinition(node,
BOOST_WAVE_MACRO_DEFINITION_ID, macrodefinition, pos, false);
if (has_parameters) {
@@ -1729,44 +1729,44 @@
// test whether ellipsis are given, and if yes, if these are placed as the
// last argument, test if __VA_ARGS__ is used as a macro parameter name
using namespace cpplexer;
- typedef typename std::vector<result_type>::iterator
+ typedef typename std::vector<result_type>::iterator
parameter_iterator_t;
bool seen_ellipses = false;
parameter_iterator_t end = macroparameters.end();
- for (parameter_iterator_t pit = macroparameters.begin();
- pit != end; ++pit)
+ for (parameter_iterator_t pit = macroparameters.begin();
+ pit != end; ++pit)
{
if (seen_ellipses) {
// ellipses are not the last given formal argument
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- bad_define_statement, macroname.get_value().c_str(),
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ bad_define_statement, macroname.get_value().c_str(),
(*pit).get_position());
return;
}
- if (T_ELLIPSIS == token_id(*pit))
+ if (T_ELLIPSIS == token_id(*pit))
seen_ellipses = true;
// can't use __VA_ARGS__ as a argument name
if ("__VA_ARGS__" == (*pit).get_value()) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- bad_define_statement_va_args,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ bad_define_statement_va_args,
macroname.get_value().c_str(), (*pit).get_position());
return;
}
}
- // if there wasn't an ellipsis, then there shouldn't be a __VA_ARGS__
+ // if there wasn't an ellipsis, then there shouldn't be a __VA_ARGS__
// placeholder in the definition too [C99 Standard 6.10.3.5]
if (!seen_ellipses) {
typedef typename token_sequence_type::iterator definition_iterator_t;
bool seen_va_args = false;
definition_iterator_t pend = macrodefinition.end();
- for (definition_iterator_t dit = macrodefinition.begin();
- dit != pend; ++dit)
+ for (definition_iterator_t dit = macrodefinition.begin();
+ dit != pend; ++dit)
{
- if (T_IDENTIFIER == token_id(*dit) &&
+ if (T_IDENTIFIER == token_id(*dit) &&
"__VA_ARGS__" == (*dit).get_value())
{
seen_va_args = true;
@@ -1774,8 +1774,8 @@
}
if (seen_va_args) {
// must not have seen __VA_ARGS__ placeholder
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- bad_define_statement_va_args,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ bad_define_statement_va_args,
macroname.get_value().c_str(), act_token.get_position());
return;
}
@@ -1786,17 +1786,17 @@
{
// test, that there is no T_ELLIPSES given
using namespace cpplexer;
- typedef typename std::vector<result_type>::iterator
+ typedef typename std::vector<result_type>::iterator
parameter_iterator_t;
parameter_iterator_t end = macroparameters.end();
- for (parameter_iterator_t pit = macroparameters.begin();
- pit != end; ++pit)
+ for (parameter_iterator_t pit = macroparameters.begin();
+ pit != end; ++pit)
{
if (T_ELLIPSIS == token_id(*pit)) {
// if variadics are disabled, no ellipses should be given
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- bad_define_statement, macroname.get_value().c_str(),
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ bad_define_statement, macroname.get_value().c_str(),
(*pit).get_position());
return;
}
@@ -1805,17 +1805,17 @@
}
// add the new macro to the macromap
- ctx.add_macro_definition(macroname, has_parameters, macroparameters,
+ ctx.add_macro_definition(macroname, has_parameters, macroparameters,
macrodefinition);
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_undefine(): handle #undef directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_undefine (lexer_type const &it)
{
BOOST_ASSERT(ctx.get_if_block_status());
@@ -1825,12 +1825,12 @@
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_ifdef(): handle #ifdef directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_ifdef(
result_type const& found_directive, lexer_type const &it)
// typename parse_tree_type::const_iterator const &it)
@@ -1838,8 +1838,8 @@
{
// get_token_value<result_type, parse_node_type> get_value;
// token_sequence_type toexpand;
-//
-// std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value),
+//
+// std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value),
// make_ref_transform_iterator((*begin).children.end(), get_value),
// std::inserter(toexpand, toexpand.end()));
@@ -1854,19 +1854,19 @@
#else
do {
is_defined = ctx.is_defined_macro((*it).get_value()); // toexpand.begin(), toexpand.end());
- } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
+ } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
found_directive, directive, is_defined));
#endif
ctx.enter_if_block(is_defined);
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_ifndef(): handle #ifndef directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_ifndef(
result_type const& found_directive, lexer_type const &it)
// typename parse_tree_type::const_iterator const &it)
@@ -1874,8 +1874,8 @@
{
// get_token_value<result_type, parse_node_type> get_value;
// token_sequence_type toexpand;
-//
-// std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value),
+//
+// std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value),
// make_ref_transform_iterator((*begin).children.end(), get_value),
// std::inserter(toexpand, toexpand.end()));
@@ -1890,48 +1890,48 @@
#else
do {
is_defined = ctx.is_defined_macro((*it).get_value()); // toexpand.begin(), toexpand.end());
- } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
+ } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
found_directive, directive, is_defined));
#endif
ctx.enter_if_block(!is_defined);
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_else(): handle #else directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_else()
{
if (!ctx.enter_else_block()) {
// #else without matching #if
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if,
"#else", act_pos);
}
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_endif(): handle #endif directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_endif()
{
if (!ctx.exit_if_block()) {
// #endif without matching #if
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if,
"#endif", act_pos);
}
}
///////////////////////////////////////////////////////////////////////////////
// replace all remaining (== undefined) identifiers with an integer literal '0'
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::replace_undefined_identifiers(
token_sequence_type &expanded)
{
@@ -1940,7 +1940,7 @@
exp_it != exp_end; ++exp_it)
{
using namespace boost::wave;
-
+
token_id id = token_id(*exp_it);
if (IS_CATEGORY(id, IdentifierTokenType) ||
IS_CATEGORY(id, KeywordTokenType))
@@ -1952,12 +1952,12 @@
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_if(): handle #if directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_if(
result_type const& found_directive,
typename parse_tree_type::const_iterator const &begin,
@@ -1967,7 +1967,7 @@
get_token_value<result_type, parse_node_type> get_value;
token_sequence_type toexpand;
- std::copy(make_ref_transform_iterator(begin, get_value),
+ std::copy(make_ref_transform_iterator(begin, get_value),
make_ref_transform_iterator(end, get_value),
std::inserter(toexpand, toexpand.end()));
@@ -1990,7 +1990,7 @@
{
string_type outstr(boost::wave::util::impl::as_string(toexpand));
outstr += "(" + boost::wave::util::impl::as_string(expanded) + ")";
- BOOST_WAVE_DUMP_CONDITIONAL_EXPRESSIONS_OUT << "#if " << outstr
+ BOOST_WAVE_DUMP_CONDITIONAL_EXPRESSIONS_OUT << "#if " << outstr
<< std::endl;
}
#endif
@@ -2010,8 +2010,8 @@
ctx.get_hooks().evaluated_conditional_expression(toexpand, if_status);
} while (false);
#else
- } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
- found_directive, toexpand, if_status)
+ } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
+ found_directive, toexpand, if_status)
&& status == grammars::error_noerror);
#endif
@@ -2019,31 +2019,31 @@
if (grammars::error_noerror != status) {
// division or other error by zero occurred
string_type expression = util::impl::as_string(expanded);
- if (0 == expression.size())
+ if (0 == expression.size())
expression = "<empty expression>";
if (grammars::error_division_by_zero & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, division_by_zero,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, division_by_zero,
expression.c_str(), act_pos);
}
else if (grammars::error_integer_overflow & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, integer_overflow,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, integer_overflow,
expression.c_str(), act_pos);
}
else if (grammars::error_character_overflow & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
character_literal_out_of_range, expression.c_str(), act_pos);
}
}
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_elif(): handle #elif directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_elif(
result_type const& found_directive,
typename parse_tree_type::const_iterator const &begin,
@@ -2053,7 +2053,7 @@
get_token_value<result_type, parse_node_type> get_value;
token_sequence_type toexpand;
- std::copy(make_ref_transform_iterator(begin, get_value),
+ std::copy(make_ref_transform_iterator(begin, get_value),
make_ref_transform_iterator(end, get_value),
std::inserter(toexpand, toexpand.end()));
@@ -2063,7 +2063,7 @@
if (ctx.get_if_block_some_part_status()) {
if (!ctx.enter_elif_block(false)) {
// #else without matching #if
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
missing_matching_if, "#elif", act_pos);
// fall through...
}
@@ -2072,7 +2072,7 @@
typename token_sequence_type::iterator begin2 = toexpand.begin();
impl::skip_to_eol(ctx, begin2, toexpand.end());
- return; // one of previous #if/#elif was true, so don't enter this #elif
+ return; // one of previous #if/#elif was true, so don't enter this #elif
}
// preprocess the given sequence into the provided list
@@ -2082,7 +2082,7 @@
do {
expanded.clear();
-
+
typename token_sequence_type::iterator begin2 = toexpand.begin();
ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded);
@@ -2112,14 +2112,14 @@
ctx.get_hooks().evaluated_conditional_expression(toexpand, if_status);
} while (false);
#else
- } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
- found_directive, toexpand, if_status)
+ } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
+ found_directive, toexpand, if_status)
&& status == grammars::error_noerror);
#endif
- if (!ctx.enter_elif_block(if_status)) {
+ if (!ctx.enter_elif_block(if_status)) {
// #elif without matching #if
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if,
"#elif", act_pos);
return;
}
@@ -2127,48 +2127,48 @@
if (grammars::error_noerror != status) {
// division or other error by zero occurred
string_type expression = util::impl::as_string(expanded);
- if (0 == expression.size())
+ if (0 == expression.size())
expression = "<empty expression>";
-
+
if (grammars::error_division_by_zero & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, division_by_zero,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, division_by_zero,
expression.c_str(), act_pos);
}
else if (grammars::error_integer_overflow & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
integer_overflow, expression.c_str(), act_pos);
}
else if (grammars::error_character_overflow & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
character_literal_out_of_range, expression.c_str(), act_pos);
}
}
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_illformed(): handles the illegal directive
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_illformed(
typename result_type::string_type s)
{
BOOST_ASSERT(ctx.get_if_block_status());
-
+
// some messages have more than one newline at the end
typename string_type::size_type p = s.find_last_not_of('\n');
if (string_type::npos != p)
s = s.substr(0, p+1);
// throw the exception
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_directive,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_directive,
s.c_str(), act_pos);
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_line(): handle #line directives
//
///////////////////////////////////////////////////////////////////////////////
@@ -2177,7 +2177,7 @@
template <typename IteratorT, typename StringT>
bool retrieve_line_info (IteratorT first, IteratorT const &last,
- unsigned int &line, StringT &file,
+ unsigned int &line, StringT &file,
boost::wave::preprocess_exception::error_code& error)
{
using namespace boost::wave;
@@ -2195,7 +2195,7 @@
error = preprocess_exception::bad_line_number;
// extract file name (if it is given)
- while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType))
+ while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType))
/**/; // skip whitespace
if (first != last) {
@@ -2208,13 +2208,13 @@
if ('L' == file_lit[0]) {
error = preprocess_exception::bad_line_filename;
- return false; // shouldn't be a wide character string
+ return false; // shouldn't be a wide character string
}
file = file_lit.substr(1, file_lit.size()-2);
// test if there is other junk on this line
- while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType))
+ while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType))
/**/; // skip whitespace
}
return first == last;
@@ -2224,8 +2224,8 @@
}
}
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_line(
typename parse_tree_type::const_iterator const &begin,
typename parse_tree_type::const_iterator const &end)
@@ -2233,13 +2233,13 @@
BOOST_ASSERT(ctx.get_if_block_status());
// Try to extract the line number and file name from the given token list
-// directly. If that fails, preprocess the whole token sequence and try again
+// directly. If that fails, preprocess the whole token sequence and try again
// to extract this information.
token_sequence_type expanded;
get_token_value<result_type, parse_node_type> get_value;
typedef typename ref_transform_iterator_generator<
- get_token_value<result_type, parse_node_type>,
+ get_token_value<result_type, parse_node_type>,
typename parse_tree_type::const_iterator
>::type const_tree_iterator_t;
@@ -2257,27 +2257,27 @@
if (!impl::retrieve_line_info(first, last, line, file_name, error)) {
// preprocess the body of this #line message
typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(),
+ ctx.expand_whole_tokensequence(begin2, toexpand.end(),
expanded, false);
error = preprocess_exception::no_error;
- if (!impl::retrieve_line_info(expanded.begin(), expanded.end(),
+ if (!impl::retrieve_line_info(expanded.begin(), expanded.end(),
line, file_name, error))
{
typename ContextT::string_type msg(
boost::wave::util::impl::as_string(expanded));
- BOOST_WAVE_THROW_VAR_CTX(ctx, preprocess_exception, error,
+ BOOST_WAVE_THROW_VAR_CTX(ctx, preprocess_exception, error,
msg.c_str(), act_pos);
return;
}
// call the corresponding pp hook function
- ctx.get_hooks().found_line_directive(ctx.derived(), expanded, line,
+ ctx.get_hooks().found_line_directive(ctx.derived(), expanded, line,
file_name.c_str());
}
else {
// call the corresponding pp hook function
- ctx.get_hooks().found_line_directive(ctx.derived(), toexpand, line,
+ ctx.get_hooks().found_line_directive(ctx.derived(), toexpand, line,
file_name.c_str());
}
@@ -2292,13 +2292,13 @@
if (error != preprocess_exception::no_error) {
typename ContextT::string_type msg(
boost::wave::util::impl::as_string(expanded));
- BOOST_WAVE_THROW_VAR_CTX(ctx, preprocess_exception, error,
+ BOOST_WAVE_THROW_VAR_CTX(ctx, preprocess_exception, error,
msg.c_str(), act_pos);
return;
}
// set new line number/filename only if ok
- if (!file_name.empty()) { // reuse current file name
+ if (!file_name.empty()) { // reuse current file name
using boost::wave::util::impl::unescape_lit;
act_pos.set_file(unescape_lit(file_name).c_str());
}
@@ -2307,12 +2307,12 @@
}
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_error(): handle #error directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_error(
typename parse_tree_type::const_iterator const &begin,
typename parse_tree_type::const_iterator const &end)
@@ -2324,7 +2324,7 @@
get_token_value<result_type, parse_node_type> get_value;
typename ref_transform_iterator_generator<
- get_token_value<result_type, parse_node_type>,
+ get_token_value<result_type, parse_node_type>,
typename parse_tree_type::const_iterator
>::type first = make_ref_transform_iterator(begin, get_value);
@@ -2336,32 +2336,32 @@
std::inserter(toexpand, toexpand.end()));
typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded,
+ ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded,
false);
if (!ctx.get_hooks().found_error_directive(ctx.derived(), toexpand))
#else
// simply copy the body of this #error message to the issued diagnostic
// message
- std::copy(first, make_ref_transform_iterator(end, get_value),
+ std::copy(first, make_ref_transform_iterator(end, get_value),
std::inserter(expanded, expanded.end()));
if (!ctx.get_hooks().found_error_directive(ctx.derived(), expanded))
-#endif
+#endif
{
// report the corresponding error
BOOST_WAVE_STRINGTYPE msg(boost::wave::util::impl::as_string(expanded));
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, error_directive,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, error_directive,
msg.c_str(), act_pos);
}
}
#if BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE != 0
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_warning(): handle #warning directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
-inline void
+template <typename ContextT>
+inline void
pp_iterator_functor<ContextT>::on_warning(
typename parse_tree_type::const_iterator const &begin,
typename parse_tree_type::const_iterator const &end)
@@ -2373,7 +2373,7 @@
get_token_value<result_type, parse_node_type> get_value;
typename ref_transform_iterator_generator<
- get_token_value<result_type, parse_node_type>,
+ get_token_value<result_type, parse_node_type>,
typename parse_tree_type::const_iterator
>::type first = make_ref_transform_iterator(begin, get_value);
@@ -2385,31 +2385,31 @@
std::inserter(toexpand, toexpand.end()));
typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded,
+ ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded,
false);
if (!ctx.get_hooks().found_warning_directive(ctx.derived(), toexpand))
#else
// simply copy the body of this #warning message to the issued diagnostic
// message
- std::copy(first, make_ref_transform_iterator(end, get_value),
+ std::copy(first, make_ref_transform_iterator(end, get_value),
std::inserter(expanded, expanded.end()));
if (!ctx.get_hooks().found_warning_directive(ctx.derived(), expanded))
-#endif
+#endif
{
// report the corresponding error
BOOST_WAVE_STRINGTYPE msg(boost::wave::util::impl::as_string(expanded));
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, warning_directive,
+ BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, warning_directive,
msg.c_str(), act_pos);
}
}
#endif // BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE != 0
///////////////////////////////////////////////////////////////////////////////
-//
+//
// on_pragma(): handle #pragma directives
//
///////////////////////////////////////////////////////////////////////////////
-template <typename ContextT>
+template <typename ContextT>
inline bool
pp_iterator_functor<ContextT>::on_pragma(
typename parse_tree_type::const_iterator const &begin,
@@ -2426,7 +2426,7 @@
get_token_value<result_type, parse_node_type> get_value;
typedef typename ref_transform_iterator_generator<
- get_token_value<result_type, parse_node_type>,
+ get_token_value<result_type, parse_node_type>,
typename parse_tree_type::const_iterator
>::type const_tree_iterator_t;
@@ -2436,13 +2436,13 @@
expanded.push_back(result_type(T_PP_PRAGMA, "#pragma", act_token.get_position()));
expanded.push_back(result_type(T_SPACE, " ", act_token.get_position()));
- while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType))
+ while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType))
expanded.push_back(*first); // skip whitespace
if (first != last) {
- if (T_IDENTIFIER == token_id(*first) &&
- boost::wave::need_c99(ctx.get_language()) &&
- (*first).get_value() == "STDC")
+ if (T_IDENTIFIER == token_id(*first) &&
+ boost::wave::need_c99(ctx.get_language()) &&
+ (*first).get_value() == "STDC")
{
// do _not_ preprocess the token sequence
std::copy(first, last, std::inserter(expanded, expanded.end()));
@@ -2455,7 +2455,7 @@
std::copy(first, last, std::inserter(toexpand, toexpand.end()));
typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(),
+ ctx.expand_whole_tokensequence(begin2, toexpand.end(),
expanded, false);
#else
// do _not_ preprocess the token sequence
@@ -2469,7 +2469,7 @@
BOOST_ASSERT(unput_queue.empty());
BOOST_ASSERT(pending_queue.empty());
-// try to interpret the expanded #pragma body
+// try to interpret the expanded #pragma body
token_sequence_type pending;
if (interpret_pragma(expanded, pending)) {
// if there is some replacement text, insert it into the pending queue
@@ -2479,17 +2479,17 @@
}
#if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0
-// Move the resulting token sequence into the pending_queue, so it will be
+// Move the resulting token sequence into the pending_queue, so it will be
// returned to the caller.
if (boost::wave::need_emit_pragma_directives(ctx.get_language())) {
pending_queue.splice(pending_queue.begin(), expanded);
return false; // return the whole #pragma directive
}
-#endif
+#endif
return true; // skip the #pragma at all
}
-template <typename ContextT>
+template <typename ContextT>
inline bool
pp_iterator_functor<ContextT>::interpret_pragma(
token_sequence_type const &pragma_body, token_sequence_type &result)
@@ -2498,7 +2498,7 @@
typename token_sequence_type::const_iterator end = pragma_body.end();
typename token_sequence_type::const_iterator it = pragma_body.begin();
- for (++it; it != end && IS_CATEGORY(*it, WhiteSpaceTokenType); ++it)
+ for (++it; it != end && IS_CATEGORY(*it, WhiteSpaceTokenType); ++it)
/**/; // skip whitespace
if (it == end) // eof reached
@@ -2512,16 +2512,16 @@
} // namespace impl
///////////////////////////////////////////////////////////////////////////////
-//
+//
// pp_iterator
//
// The boost::wave::pp_iterator template is the iterator, through which
// the resulting preprocessed input stream is accessible.
-//
+//
///////////////////////////////////////////////////////////////////////////////
template <typename ContextT>
-class pp_iterator
+class pp_iterator
: public boost::spirit::classic::multi_pass<
boost::wave::impl::pp_iterator_functor<ContextT>,
boost::wave::util::functor_input
@@ -2531,14 +2531,14 @@
typedef boost::wave::impl::pp_iterator_functor<ContextT> input_policy_type;
private:
- typedef
+ typedef
boost::spirit::classic::multi_pass<input_policy_type, boost::wave::util::functor_input>
base_type;
typedef pp_iterator<ContextT> self_type;
typedef boost::wave::util::functor_input functor_input_type;
public:
- pp_iterator()
+ pp_iterator()
{}
template <typename IteratorT>
@@ -2548,9 +2548,9 @@
{}
bool force_include(char const *path_, bool is_last)
- {
- bool result = this->get_functor().on_include_helper(path_, path_,
- false, false);
+ {
+ bool result = this->get_functor().on_include_helper(path_, path_,
+ false, false);
if (is_last) {
this->functor_input_type::
template inner<input_policy_type>::advance_input();
Added: trunk/libs/wave/test/testwave/testfiles/t_2_022.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/wave/test/testwave/testfiles/t_2_022.cpp 2012-05-23 10:38:10 EDT (Wed, 23 May 2012)
@@ -0,0 +1,23 @@
+/*=============================================================================
+ Boost.Wave: A Standard compliant C++ preprocessor library
+ http://www.boost.org/
+
+ Copyright (c) 2001-2012 Hartmut Kaiser. 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)
+=============================================================================*/
+
+// Verify fix of regression #6838: Adding include file with force_include makes
+// Wave fail to emit #line directive
+
+//O --forceinclude=t_2_022.hpp
+
+//R #line 12 "t_2_022.hpp"
+//R int func() { return 42; }
+//R #line 19 "t_2_022.cpp"
+//R int main() { return func(); }
+int main() { return func(); }
+
+//H 04: t_2_022.hpp
+//H 05: $B(t_2_022.hpp) ($B(t_2_022.hpp))
+//H 06:
Added: trunk/libs/wave/test/testwave/testfiles/t_2_022.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/wave/test/testwave/testfiles/t_2_022.hpp 2012-05-23 10:38:10 EDT (Wed, 23 May 2012)
@@ -0,0 +1,12 @@
+/*=============================================================================
+ Boost.Wave: A Standard compliant C++ preprocessor library
+ http://www.boost.org/
+
+ Copyright (c) 2001-2012 Hartmut Kaiser. 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)
+=============================================================================*/
+
+// Verify fix of regression #6838: Adding include file with force_include makes
+// Wave fail to emit #line directive
+int func() { return 42; }
Modified: trunk/libs/wave/test/testwave/testfiles/test.cfg
==============================================================================
--- trunk/libs/wave/test/testwave/testfiles/test.cfg (original)
+++ trunk/libs/wave/test/testwave/testfiles/test.cfg 2012-05-23 10:38:10 EDT (Wed, 23 May 2012)
@@ -74,6 +74,7 @@
t_2_019.cpp
t_2_020.cpp
t_2_021.cpp
+t_2_022.cpp
#
# t_3: Predefined macros
Modified: trunk/libs/wave/test/testwave/testwave_app.cpp
==============================================================================
--- trunk/libs/wave/test/testwave/testwave_app.cpp (original)
+++ trunk/libs/wave/test/testwave/testwave_app.cpp 2012-05-23 10:38:10 EDT (Wed, 23 May 2012)
@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
- Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost
+ Copyright (c) 2001-2012 Hartmut Kaiser. 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)
=============================================================================*/
@@ -24,7 +24,7 @@
#include <boost/filesystem/operations.hpp>
#include <boost/detail/workaround.hpp>
-// include Wave
+// include Wave
// always use new hooks
#define BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS 0
@@ -41,10 +41,10 @@
#include "collect_hooks_information.hpp"
# ifdef BOOST_NO_STDC_NAMESPACE
-namespace std
-{
+namespace std
+{
using ::asctime; using ::gmtime; using ::localtime;
- using ::difftime; using ::time; using ::tm; using ::mktime; using ::system;
+ using ::difftime; using ::time; using ::tm; using ::mktime; using ::system;
}
# endif
@@ -61,8 +61,8 @@
///////////////////////////////////////////////////////////////////////////
template <typename Iterator>
- inline bool
- handle_next_token(Iterator &it, Iterator const& end,
+ inline bool
+ handle_next_token(Iterator &it, Iterator const& end,
std::string &result)
{
typedef typename Iterator::value_type token_type;
@@ -87,7 +87,7 @@
///////////////////////////////////////////////////////////////////////////
template <typename Iterator>
- bool handle_line_directive(Iterator &it, Iterator const& end,
+ bool handle_line_directive(Iterator &it, Iterator const& end,
std::string &result)
{
typedef typename Iterator::value_type token_type;
@@ -102,7 +102,7 @@
}
using boost::wave::util::impl::unescape_lit;
-
+
token_type filename = *it;
string_type name = filename.get_value();
@@ -132,17 +132,17 @@
///////////////////////////////////////////////////////////////////////////
//
-// This function compares the real result and the expected one but first
-// replaces all occurrences in the expected result of
+// This function compares the real result and the expected one but first
+// replaces all occurrences in the expected result of
// $E: to the result of preprocessing the given expression
-// $F: to the passed full filepath
+// $F: to the passed full filepath
// $P: to the full path
// $B: to the full path (same as $P, but using forward slash '/' on Windows)
// $V: to the current Boost version number
//
///////////////////////////////////////////////////////////////////////////
-bool
-testwave_app::got_expected_result(std::string const& filename,
+bool
+testwave_app::got_expected_result(std::string const& filename,
std::string const& result, std::string& expected)
{
using boost::wave::util::impl::escape_lit;
@@ -159,31 +159,31 @@
if ('(' == expected[pos1+2]) {
std::size_t p = expected.find_first_of(")", pos1+1);
if (std::string::npos == p) {
- std::cerr
+ std::cerr
<< "testwave: unmatched parenthesis in $E"
" directive" << std::endl;
return false;
}
std::string source = expected.substr(pos1+3, p-pos1-3);
std::string result, error, hooks;
- bool pp_result = preprocess_file(filename, source,
+ bool pp_result = preprocess_file(filename, source,
result, error, hooks, true);
if (!pp_result) {
- std::cerr
- << "testwave: preprocessing error in $E directive: "
+ std::cerr
+ << "testwave: preprocessing error in $E directive: "
<< error << std::endl;
return false;
}
- full_result = full_result +
+ full_result = full_result +
expected.substr(pos, pos1-pos) + result;
- pos1 = expected.find_first_of ("$",
+ pos1 = expected.find_first_of ("$",
pos = pos1 + 4 + source.size());
}
}
break;
case 'F': // insert base file name
- full_result = full_result +
+ full_result = full_result +
expected.substr(pos, pos1-pos) + escape_lit(filename);
pos1 = expected.find_first_of ("$", pos = pos1 + 2);
break;
@@ -193,7 +193,7 @@
{
fs::path fullpath (
boost::wave::util::complete_path(
- boost::wave::util::create_path(filename),
+ boost::wave::util::create_path(filename),
boost::wave::util::current_path())
);
@@ -201,13 +201,13 @@
// the $P(basename) syntax is used
std::size_t p = expected.find_first_of(")", pos1+1);
if (std::string::npos == p) {
- std::cerr
+ std::cerr
<< "testwave: unmatched parenthesis in $P"
" directive" << std::endl;
return false;
}
std::string base = expected.substr(pos1+3, p-pos1-3);
- fullpath = boost::wave::util::branch_path(fullpath) /
+ fullpath = boost::wave::util::branch_path(fullpath) /
boost::wave::util::create_path(base);
full_result += expected.substr(pos, pos1-pos);
if ('P' == expected[pos1+1]) {
@@ -233,7 +233,7 @@
#endif
full_result += escape_lit(p);
}
- pos1 = expected.find_first_of ("$",
+ pos1 = expected.find_first_of ("$",
pos = pos1 + 4 + base.size());
}
else {
@@ -257,11 +257,11 @@
break;
case 'R': // insert relative file name
- case 'S': // same as 'R', but forward slashes on Windows
+ case 'S': // same as 'R', but forward slashes on Windows
{
fs::path relpath;
boost::wave::util::as_relative_to(
- boost::wave::util::create_path(filename),
+ boost::wave::util::create_path(filename),
boost::wave::util::current_path(),
relpath);
@@ -269,13 +269,13 @@
// the $R(basename) syntax is used
std::size_t p = expected.find_first_of(")", pos1+1);
if (std::string::npos == p) {
- std::cerr
+ std::cerr
<< "testwave: unmatched parenthesis in $R"
" directive" << std::endl;
return false;
}
std::string base = expected.substr(pos1+3, p-pos1-3);
- relpath = boost::wave::util::branch_path(relpath) /
+ relpath = boost::wave::util::branch_path(relpath) /
boost::wave::util::create_path(base);
full_result += expected.substr(pos, pos1-pos);
if ('R' == expected[pos1+1]) {
@@ -293,7 +293,7 @@
#endif
full_result += escape_lit(p);
}
- pos1 = expected.find_first_of ("$",
+ pos1 = expected.find_first_of ("$",
pos = pos1 + 4 + base.size());
}
else {
@@ -317,11 +317,11 @@
break;
case 'V': // insert Boost version
- full_result = full_result +
+ full_result = full_result +
expected.substr(pos, pos1-pos) + BOOST_LIB_VERSION;
pos1 = expected.find_first_of ("$", pos = pos1 + 2);
break;
-
+
default:
full_result = full_result +
expected.substr(pos, pos1-pos);
@@ -342,28 +342,30 @@
///////////////////////////////////////////////////////////////////////////////
testwave_app::testwave_app(po::variables_map const& vm)
-: debuglevel(1), desc_options("Preprocessor configuration options"),
+: debuglevel(1), desc_options("Preprocessor configuration options"),
global_vm(vm)
{
desc_options.add_options()
- ("include,I", po::value<cmd_line_utils::include_paths>()->composing(),
+ ("include,I", po::value<cmd_line_utils::include_paths>()->composing(),
"specify an additional include directory")
- ("sysinclude,S", po::value<std::vector<std::string> >()->composing(),
+ ("sysinclude,S", po::value<std::vector<std::string> >()->composing(),
"specify an additional system include directory")
- ("define,D", po::value<std::vector<std::string> >()->composing(),
+ ("forceinclude,F", po::value<std::vector<std::string> >()->composing(),
+ "force inclusion of the given file")
+ ("define,D", po::value<std::vector<std::string> >()->composing(),
"specify a macro to define (as macro[=[value]])")
- ("predefine,P", po::value<std::vector<std::string> >()->composing(),
+ ("predefine,P", po::value<std::vector<std::string> >()->composing(),
"specify a macro to predefine (as macro[=[value]])")
- ("undefine,U", po::value<std::vector<std::string> >()->composing(),
+ ("undefine,U", po::value<std::vector<std::string> >()->composing(),
"specify a macro to undefine")
- ("nesting,n", po::value<int>(),
+ ("nesting,n", po::value<int>(),
"specify a new maximal include nesting depth")
("long_long", "enable long long support in C++ mode")
("preserve", "preserve comments")
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
("variadics", "enable certain C99 extensions in C++ mode")
("c99", "enable C99 mode (implies --variadics)")
-#endif
+#endif
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
("noguard,G", "disable include guard detection")
#endif
@@ -376,24 +378,24 @@
///////////////////////////////////////////////////////////////////////////////
//
-// Test the given file (i.e. preprocess the file and compare the result
+// Test the given file (i.e. preprocess the file and compare the result
// against the embedded 'R' comments, if an error occurs compare the error
// message against the given 'E' comments, if no error occurred, compare the
// generated hooks result against the given 'H' comments).
//
///////////////////////////////////////////////////////////////////////////////
-bool
+bool
testwave_app::test_a_file(std::string filename)
{
// read the input file into a string
std::string instr;
- if (!read_file(filename, instr))
+ if (!read_file(filename, instr))
return false; // error was reported already
bool test_hooks = true;
if (global_vm.count("hooks"))
test_hooks = variables_map_as(global_vm["hooks"], (bool *)NULL);
-
+
// extract expected output, preprocess the data and compare results
std::string expected, expected_hooks;
if (extract_expected_output(filename, instr, expected, expected_hooks)) {
@@ -407,21 +409,21 @@
if (!extract_special_information(filename, instr, 'E', expected_error))
return false;
- if (!expected_error.empty() &&
+ if (!expected_error.empty() &&
!got_expected_result(filename, error, expected_error))
{
// we expected an error but got none (or a different one)
if (debuglevel > 2) {
- std::cerr
+ std::cerr
<< filename << ": failed" << std::endl
<< "result: " << std::endl << result << std::endl;
if (!error.empty()) {
- std::cerr << "expected result: " << std::endl
+ std::cerr << "expected result: " << std::endl
<< expected << std::endl;
}
if (!expected_error.empty()) {
- std::cerr << "expected error: " << std::endl
+ std::cerr << "expected error: " << std::endl
<< expected_error << std::endl;
}
}
@@ -433,7 +435,7 @@
else if (!got_expected_result(filename, result, expected)) {
// no preprocessing error encountered
if (debuglevel > 2) {
- std::cerr
+ std::cerr
<< filename << ": failed" << std::endl
<< "result: " << std::endl << result << std::endl
<< "expected: " << std::endl << expected << std::endl;
@@ -446,13 +448,13 @@
else {
// preprocessing succeeded, check hook information, if appropriate
if (test_hooks && !expected_hooks.empty() &&
- !got_expected_result(filename, hooks, expected_hooks))
+ !got_expected_result(filename, hooks, expected_hooks))
{
if (debuglevel > 2) {
std::cerr << filename << ": failed" << std::endl
- << "hooks result: " << std::endl << hooks
+ << "hooks result: " << std::endl << hooks
<< std::endl;
- std::cerr << "expected hooks result: " << std::endl
+ std::cerr << "expected hooks result: " << std::endl
<< expected_hooks << std::endl;
}
else if (debuglevel > 1) {
@@ -461,17 +463,17 @@
retval = false;
}
}
-
+
// print success message, if appropriate
if (retval) {
if (debuglevel > 5) {
- std::cerr
+ std::cerr
<< filename << ": succeeded" << std::endl
<< "result: " << std::endl << result << std::endl
<< "hooks result: " << std::endl << hooks << std::endl;
}
else if (debuglevel > 4) {
- std::cerr
+ std::cerr
<< filename << ": succeeded" << std::endl
<< "result: " << std::endl << result << std::endl;
}
@@ -481,21 +483,21 @@
printed_result = true;
}
}
-
+
if (!pp_result) {
// there was a preprocessing error, was it expected?
std::string expected_error;
if (!extract_special_information(filename, instr, 'E', expected_error))
return false;
-
+
if (!got_expected_result(filename, error, expected_error)) {
// the error was unexpected
if (debuglevel > 2) {
- std::cerr
+ std::cerr
<< filename << ": failed" << std::endl;
if (!expected_error.empty()) {
- std::cerr
+ std::cerr
<< "error result: " << std::endl << error << std::endl
<< "expected error: " << std::endl
<< expected_error << std::endl;
@@ -509,24 +511,24 @@
}
retval = false;
}
-
+
if (retval) {
if (debuglevel > 5) {
- std::cerr
- << filename << ": succeeded (caught expected error)"
- << std::endl << "error result: " << std::endl << error
+ std::cerr
+ << filename << ": succeeded (caught expected error)"
+ << std::endl << "error result: " << std::endl << error
<< std::endl;
-
+
if (!printed_result) {
- std::cerr
- << "hooks result: " << std::endl << hooks
+ std::cerr
+ << "hooks result: " << std::endl << hooks
<< std::endl;
}
}
else if (debuglevel > 4) {
- std::cerr
- << filename << ": succeeded (caught expected error)"
- << std::endl << "error result: " << std::endl << error
+ std::cerr
+ << filename << ": succeeded (caught expected error)"
+ << std::endl << "error result: " << std::endl << error
<< std::endl;
}
else if (debuglevel > 3) {
@@ -538,7 +540,7 @@
return retval;
}
else {
- std::cerr
+ std::cerr
<< filename << ": no information about expected results found"
<< std::endl;
}
@@ -550,13 +552,13 @@
// print the current version of this program
//
///////////////////////////////////////////////////////////////////////////////
-int
+int
testwave_app::print_version()
{
// get time of last compilation of this file
boost::wave::util::time_conversion_helper compilation_time(__DATE__ " " __TIME__);
-// calculate the number of days since Feb 12 2005
+// calculate the number of days since Feb 12 2005
// (the day the testwave project was started)
std::tm first_day;
@@ -566,11 +568,11 @@
first_day.tm_mday = 12; // 12
first_day.tm_year = 105; // 2005
-long seconds = long(std::difftime(compilation_time.get_time(),
+long seconds = long(std::difftime(compilation_time.get_time(),
std::mktime(&first_day)));
- std::cout
- << TESTWAVE_VERSION_MAJOR << '.'
+ std::cout
+ << TESTWAVE_VERSION_MAJOR << '.'
<< TESTWAVE_VERSION_MINOR << '.'
<< TESTWAVE_VERSION_SUBMINOR << '.'
<< seconds/(3600*24) // get number of days from seconds
@@ -583,7 +585,7 @@
// print the copyright statement
//
///////////////////////////////////////////////////////////////////////////////
-int
+int
testwave_app::print_copyright()
{
char const *copyright[] = {
@@ -591,15 +593,15 @@
"Testwave: A test driver for the Boost.Wave C++ preprocessor library",
"http://www.boost.org/",
"",
- "Copyright (c) 2001-2011 Hartmut Kaiser, Distributed under the Boost",
+ "Copyright (c) 2001-2012 Hartmut Kaiser, 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)",
0
};
-
+
for (int i = 0; 0 != copyright[i]; ++i)
std::cout << copyright[i] << std::endl;
-
+
return 0; // exit app
}
@@ -608,36 +610,36 @@
// Read the given file into a string
//
///////////////////////////////////////////////////////////////////////////////
-bool
+bool
testwave_app::read_file(std::string const& filename, std::string& instr)
{
// open the given file and report error, if appropriate
std::ifstream instream(filename.c_str());
if (!instream.is_open()) {
- std::cerr << "testwave: could not open input file: "
+ std::cerr << "testwave: could not open input file: "
<< filename << std::endl;
return false;
}
else if (9 == debuglevel) {
- std::cerr << "read_file: succeeded to open input file: "
+ std::cerr << "read_file: succeeded to open input file: "
<< filename << std::endl;
}
instream.unsetf(std::ios::skipws);
// read the input file into a string
-
+
#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
// this is known to be very slow for large files on some systems
std::copy (std::istream_iterator<char>(instream),
- std::istream_iterator<char>(),
+ std::istream_iterator<char>(),
std::inserter(instr, instr.end()));
#else
instr = std::string(std::istreambuf_iterator<char>(instream.rdbuf()),
std::istreambuf_iterator<char>());
-#endif
-
+#endif
+
if (9 == debuglevel) {
- std::cerr << "read_file: succeeded to read input file: "
+ std::cerr << "read_file: succeeded to read input file: "
<< filename << std::endl;
}
return true;
@@ -649,7 +651,7 @@
std::string const& trim_whitespace(std::string& value)
{
std::string::size_type first = value.find_first_not_of(" \t");
- if (std::string::npos == first)
+ if (std::string::npos == first)
value.clear();
else {
std::string::size_type last = value.find_last_not_of(" \t");
@@ -665,12 +667,12 @@
// Extract special information from comments marked with the given letter
//
///////////////////////////////////////////////////////////////////////////////
-bool
-testwave_app::extract_special_information(std::string const& filename,
+bool
+testwave_app::extract_special_information(std::string const& filename,
std::string const& instr, char flag, std::string& content)
{
if (9 == debuglevel) {
- std::cerr << "extract_special_information: extracting special information ('"
+ std::cerr << "extract_special_information: extracting special information ('"
<< flag << "') from input file: " << filename << std::endl;
}
@@ -678,15 +680,15 @@
typedef boost::wave::cpplexer::lex_token<> token_type;
typedef boost::wave::cpplexer::lex_iterator<token_type> lexer_type;
typedef token_type::position_type position_type;
-
- boost::wave::language_support const lang_opts =
+
+ boost::wave::language_support const lang_opts =
(boost::wave::language_support)(
- boost::wave::support_option_variadics |
+ boost::wave::support_option_variadics |
boost::wave::support_option_long_long |
boost::wave::support_option_no_character_validation |
boost::wave::support_option_convert_trigraphs |
boost::wave::support_option_insert_whitespace);
-
+
position_type pos(filename.c_str());
lexer_type it = lexer_type(instr.begin(), instr.end(), pos, lang_opts);
lexer_type end = lexer_type();
@@ -702,29 +704,29 @@
if (value.size() > 3 && '(' == value[3]) {
std::size_t p = value.find_first_of(")");
if (std::string::npos == p) {
- std::cerr
+ std::cerr
<< "testwave: missing closing parenthesis in '"
<< flag << "()' directive" << std::endl;
return false;
}
std::string source = value.substr(4, p-4);
std::string result, error, hooks;
- bool pp_result = preprocess_file(filename, source,
+ bool pp_result = preprocess_file(filename, source,
result, error, hooks, true);
if (!pp_result) {
- std::cerr
+ std::cerr
<< "testwave: preprocessing error in '" << flag
<< "()' directive: " << error << std::endl;
return false;
}
-
- // include this text into the extracted information
+
+ // include this text into the extracted information
// only if the result is not zero
using namespace std; // some system have atoi in namespace std
if (0 != atoi(result.c_str())) {
std::string thiscontent(value.substr(p+1));
if (9 == debuglevel) {
- std::cerr << "extract_special_information: extracted: "
+ std::cerr << "extract_special_information: extracted: "
<< thiscontent << std::endl;
}
trim_whitespace(thiscontent);
@@ -734,7 +736,7 @@
else {
std::string thiscontent(value.substr(3, value.size()-5));
if (9 == debuglevel) {
- std::cerr << "extract_special_information: extracted: "
+ std::cerr << "extract_special_information: extracted: "
<< thiscontent << std::endl;
}
trim_whitespace(thiscontent);
@@ -748,29 +750,29 @@
if (value.size() > 3 && '(' == value[3]) {
std::size_t p = value.find_first_of(")");
if (std::string::npos == p) {
- std::cerr
+ std::cerr
<< "testwave: missing closing parenthesis in '"
<< flag << "()' directive" << std::endl;
return false;
}
std::string source = value.substr(4, p-4);
std::string result, error, hooks;
- bool pp_result = preprocess_file(filename, source,
+ bool pp_result = preprocess_file(filename, source,
result, error, hooks, true);
if (!pp_result) {
- std::cerr
+ std::cerr
<< "testwave: preprocessing error in '" << flag
<< "()' directive: " << error << std::endl;
return false;
}
-
- // include this text into the extracted information
+
+ // include this text into the extracted information
// only if the result is not zero
using namespace std; // some system have atoi in namespace std
if (0 != atoi(result.c_str())) {
std::string thiscontent(value.substr((' ' == value[p+1]) ? p+2 : p+1));
if (9 == debuglevel) {
- std::cerr << "extract_special_information: extracted: "
+ std::cerr << "extract_special_information: extracted: "
<< thiscontent << std::endl;
}
trim_whitespace(thiscontent);
@@ -780,7 +782,7 @@
else {
std::string thiscontent(value.substr((' ' == value[3]) ? 4 : 3));
if (9 == debuglevel) {
- std::cerr << "extract_special_information: extracted: "
+ std::cerr << "extract_special_information: extracted: "
<< thiscontent;
}
trim_whitespace(content);
@@ -792,14 +794,14 @@
}
catch (boost::wave::cpplexer::lexing_exception const &e) {
// some lexing error
- std::cerr
+ std::cerr
<< e.file_name() << "(" << e.line_no() << "): "
<< e.description() << std::endl;
return false;
}
if (9 == debuglevel) {
- std::cerr << "extract_special_information: succeeded extracting special information ('"
+ std::cerr << "extract_special_information: succeeded extracting special information ('"
<< flag << "')" << std::endl;
}
return true;
@@ -814,8 +816,8 @@
// through the parameter 'expected'.
//
///////////////////////////////////////////////////////////////////////////////
-inline bool
-testwave_app::extract_expected_output(std::string const& filename,
+inline bool
+testwave_app::extract_expected_output(std::string const& filename,
std::string const& instr, std::string& expected, std::string& expectedhooks)
{
return extract_special_information(filename, instr, 'R', expected) &&
@@ -825,41 +827,41 @@
///////////////////////////////////////////////////////////////////////////////
//
// Extracts the required preprocessing options from the given input data and
-// initialises the given Wave context object accordingly.
-// We allow the same (applicable) options to be used as are valid for the wave
+// initialises the given Wave context object accordingly.
+// We allow the same (applicable) options to be used as are valid for the wave
// driver executable.
//
///////////////////////////////////////////////////////////////////////////////
template <typename Context>
-bool
-testwave_app::extract_options(std::string const& filename,
- std::string const& instr, Context& ctx, bool single_line)
+bool
+testwave_app::extract_options(std::string const& filename,
+ std::string const& instr, Context& ctx, bool single_line,
+ po::variables_map& vm)
{
if (9 == debuglevel) {
std::cerr << "extract_options: extracting options" << std::endl;
}
-// extract the required information from the comments flagged by a
+// extract the required information from the comments flagged by a
// capital 'O'
std::string options;
if (!extract_special_information(filename, instr, 'O', options))
return false;
- try {
+ try {
// parse the configuration information into a program_options_description
// object
- po::variables_map local_vm;
- cmd_line_utils::read_config_options(debuglevel, options, desc_options, local_vm);
- initialise_options(ctx, local_vm, single_line);
+ cmd_line_utils::read_config_options(debuglevel, options, desc_options, vm);
+ initialise_options(ctx, vm, single_line);
}
catch (std::exception const &e) {
- std::cerr << filename << ": exception caught: " << e.what()
+ std::cerr << filename << ": exception caught: " << e.what()
<< std::endl;
return false;
}
-
+
if (9 == debuglevel) {
- std::cerr << "extract_options: succeeded extracting options"
+ std::cerr << "extract_options: succeeded extracting options"
<< std::endl;
}
@@ -867,7 +869,7 @@
}
template <typename Context>
-bool
+bool
testwave_app::initialise_options(Context& ctx, po::variables_map const& vm,
bool single_line)
{
@@ -891,8 +893,8 @@
}
ctx.set_language(
boost::wave::language_support(
- boost::wave::support_c99
- | boost::wave::support_option_emit_line_directives
+ boost::wave::support_c99
+ | boost::wave::support_option_emit_line_directives
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
| boost::wave::support_option_include_guard_detection
#endif
@@ -919,9 +921,9 @@
ctx.set_language(
boost::wave::language_support(
boost::wave::support_cpp0x
- | boost::wave::support_option_convert_trigraphs
- | boost::wave::support_option_long_long
- | boost::wave::support_option_emit_line_directives
+ | boost::wave::support_option_convert_trigraphs
+ | boost::wave::support_option_long_long
+ | boost::wave::support_option_emit_line_directives
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
| boost::wave::support_option_include_guard_detection
#endif
@@ -940,7 +942,7 @@
}
ctx.set_language(boost::wave::enable_long_long(ctx.get_language()));
}
-
+
// enable preserving comments mode, if appropriate
if (vm.count("preserve")) {
if (9 == debuglevel) {
@@ -949,7 +951,7 @@
ctx.set_language(
boost::wave::enable_preserve_comments(ctx.get_language()));
}
-
+
// disable automatic include guard detection
if (vm.count("noguard")) {
if (9 == debuglevel) {
@@ -958,7 +960,7 @@
ctx.set_language(
boost::wave::enable_include_guard_detection(ctx.get_language(), false));
}
-
+
// enable trigraph conversion
if (9 == debuglevel) {
std::cerr << "initialise_options: option: convert_trigraphs" << std::endl;
@@ -973,35 +975,35 @@
ctx.set_language(boost::wave::enable_single_line(ctx.get_language()));
ctx.set_language(boost::wave::enable_emit_line_directives(ctx.get_language(), false));
}
-
+
// add include directories to the system include search paths
if (vm.count("sysinclude")) {
- std::vector<std::string> const& syspaths =
+ std::vector<std::string> const& syspaths =
variables_map_as(vm["sysinclude"], (std::vector<std::string> *)NULL);
-
+
std::vector<std::string>::const_iterator end = syspaths.end();
- for (std::vector<std::string>::const_iterator cit = syspaths.begin();
+ for (std::vector<std::string>::const_iterator cit = syspaths.begin();
cit != end; ++cit)
{
if (9 == debuglevel) {
- std::cerr << "initialise_options: option: -S" << *cit
+ std::cerr << "initialise_options: option: -S" << *cit
<< std::endl;
}
ctx.add_sysinclude_path((*cit).c_str());
}
}
-
+
// add include directories to the user include search paths
if (vm.count("include")) {
- cmd_line_utils::include_paths const &ip =
+ cmd_line_utils::include_paths const &ip =
variables_map_as(vm["include"], (cmd_line_utils::include_paths*)NULL);
std::vector<std::string>::const_iterator end = ip.paths.end();
- for (std::vector<std::string>::const_iterator cit = ip.paths.begin();
+ for (std::vector<std::string>::const_iterator cit = ip.paths.begin();
cit != end; ++cit)
{
if (9 == debuglevel) {
- std::cerr << "initialise_options: option: -I" << *cit
+ std::cerr << "initialise_options: option: -I" << *cit
<< std::endl;
}
ctx.add_include_path((*cit).c_str());
@@ -1014,46 +1016,46 @@
}
ctx.set_sysinclude_delimiter();
}
-
+
// add system include directories to the include path
std::vector<std::string>::const_iterator sysend = ip.syspaths.end();
- for (std::vector<std::string>::const_iterator syscit = ip.syspaths.begin();
+ for (std::vector<std::string>::const_iterator syscit = ip.syspaths.begin();
syscit != sysend; ++syscit)
{
if (9 == debuglevel) {
- std::cerr << "initialise_options: option: -S" << *syscit
+ std::cerr << "initialise_options: option: -S" << *syscit
<< std::endl;
}
ctx.add_sysinclude_path((*syscit).c_str());
}
}
-// add additional defined macros
+// add additional defined macros
if (vm.count("define")) {
- std::vector<std::string> const ¯os =
+ std::vector<std::string> const ¯os =
variables_map_as(vm["define"], (std::vector<std::string>*)NULL);
std::vector<std::string>::const_iterator end = macros.end();
- for (std::vector<std::string>::const_iterator cit = macros.begin();
+ for (std::vector<std::string>::const_iterator cit = macros.begin();
cit != end; ++cit)
{
if (9 == debuglevel) {
- std::cerr << "initialise_options: option: -D" << *cit
+ std::cerr << "initialise_options: option: -D" << *cit
<< std::endl;
}
ctx.add_macro_definition(*cit, true);
}
}
-// add additional predefined macros
+// add additional predefined macros
if (vm.count("predefine")) {
- std::vector<std::string> const &predefmacros =
+ std::vector<std::string> const &predefmacros =
variables_map_as(vm["predefine"], (std::vector<std::string>*)NULL);
std::vector<std::string>::const_iterator end = predefmacros.end();
- for (std::vector<std::string>::const_iterator cit = predefmacros.begin();
+ for (std::vector<std::string>::const_iterator cit = predefmacros.begin();
cit != end; ++cit)
{
if (9 == debuglevel) {
- std::cerr << "initialise_options: option: -P" << *cit
+ std::cerr << "initialise_options: option: -P" << *cit
<< std::endl;
}
ctx.add_macro_definition(*cit, true);
@@ -1062,14 +1064,14 @@
// undefine specified macros
if (vm.count("undefine")) {
- std::vector<std::string> const &undefmacros =
+ std::vector<std::string> const &undefmacros =
variables_map_as(vm["undefine"], (std::vector<std::string>*)NULL);
std::vector<std::string>::const_iterator end = undefmacros.end();
- for (std::vector<std::string>::const_iterator cit = undefmacros.begin();
+ for (std::vector<std::string>::const_iterator cit = undefmacros.begin();
cit != end; ++cit)
{
if (9 == debuglevel) {
- std::cerr << "initialise_options: option: -U" << *cit
+ std::cerr << "initialise_options: option: -U" << *cit
<< std::endl;
}
ctx.remove_macro_definition(*cit);
@@ -1080,19 +1082,19 @@
if (vm.count("nesting")) {
int max_depth = variables_map_as(vm["nesting"], (int*)NULL);
if (max_depth < 1 || max_depth > 100000) {
- std::cerr << "testwave: bogus maximal include nesting depth: "
+ std::cerr << "testwave: bogus maximal include nesting depth: "
<< max_depth << std::endl;
return false;
}
else if (9 == debuglevel) {
- std::cerr << "initialise_options: option: -n" << max_depth
+ std::cerr << "initialise_options: option: -n" << max_depth
<< std::endl;
}
ctx.set_max_include_nesting_depth(max_depth);
}
if (9 == debuglevel) {
- std::cerr << "initialise_options: succeeded to initialize options"
+ std::cerr << "initialise_options: succeeded to initialize options"
<< std::endl;
}
return true;
@@ -1101,7 +1103,7 @@
///////////////////////////////////////////////////////////////////////////////
// construct a SIZEOF macro definition string and predefine this macro
template <typename Context>
-inline bool
+inline bool
testwave_app::add_sizeof_definition(Context& ctx, char const *name, int value)
{
BOOST_WAVETEST_OSSTREAM strm;
@@ -1109,12 +1111,12 @@
std::string macro(BOOST_WAVETEST_GETSTRING(strm));
if (!ctx.add_macro_definition(macro, true)) {
- std::cerr << "testwave: failed to predefine macro: " << macro
+ std::cerr << "testwave: failed to predefine macro: " << macro
<< std::endl;
return false;
}
else if (9 == debuglevel) {
- std::cerr << "add_sizeof_definition: predefined macro: " << macro
+ std::cerr << "add_sizeof_definition: predefined macro: " << macro
<< std::endl;
}
return true;
@@ -1122,28 +1124,28 @@
// construct a MIN macro definition string and predefine this macro
template <typename T, typename Context>
-inline bool
+inline bool
testwave_app::add_min_definition(Context& ctx, char const *name)
{
BOOST_WAVETEST_OSSTREAM strm;
if (!std::numeric_limits<T>::is_signed) {
- strm << "__TESTWAVE_" << name << "_MIN__="
- << "0x" << std::hex
+ strm << "__TESTWAVE_" << name << "_MIN__="
+ << "0x" << std::hex
<< (std::numeric_limits<T>::min)() << "U";
}
else {
- strm << "__TESTWAVE_" << name << "_MIN__=( "
+ strm << "__TESTWAVE_" << name << "_MIN__=( "
<< (std::numeric_limits<T>::min)()+1 << "-1)";
}
-
+
std::string macro(BOOST_WAVETEST_GETSTRING(strm));
if (!ctx.add_macro_definition(macro, true)) {
- std::cerr << "testwave: failed to predefine macro: " << macro
+ std::cerr << "testwave: failed to predefine macro: " << macro
<< std::endl;
return false;
}
else if (9 == debuglevel) {
- std::cerr << "add_min_definition: predefined macro: " << macro
+ std::cerr << "add_min_definition: predefined macro: " << macro
<< std::endl;
}
return true;
@@ -1151,28 +1153,28 @@
// construct a MAX macro definition string and predefine this macro
template <typename T, typename Context>
-inline bool
+inline bool
testwave_app::add_max_definition(Context& ctx, char const *name)
{
BOOST_WAVETEST_OSSTREAM strm;
if (!std::numeric_limits<T>::is_signed) {
- strm << "__TESTWAVE_" << name << "_MAX__="
- << "0x" << std::hex
+ strm << "__TESTWAVE_" << name << "_MAX__="
+ << "0x" << std::hex
<< (std::numeric_limits<T>::max)() << "U";
}
else {
- strm << "__TESTWAVE_" << name << "_MAX__="
+ strm << "__TESTWAVE_" << name << "_MAX__="
<< (std::numeric_limits<T>::max)();
}
-
+
std::string macro(BOOST_WAVETEST_GETSTRING(strm));
if (!ctx.add_macro_definition(macro, true)) {
- std::cerr << "testwave: failed to predefine macro: " << macro
+ std::cerr << "testwave: failed to predefine macro: " << macro
<< std::endl;
return false;
}
else if (9 == debuglevel) {
- std::cerr << "add_max_definition: predefined macro: " << macro
+ std::cerr << "add_max_definition: predefined macro: " << macro
<< std::endl;
}
return true;
@@ -1180,17 +1182,17 @@
// Predefine __TESTWAVE_HAS_STRICT_LEXER__
template <typename Context>
-inline bool
+inline bool
testwave_app::add_strict_lexer_definition(Context& ctx)
{
std::string macro("__TESTWAVE_HAS_STRICT_LEXER__=1");
if (!ctx.add_macro_definition(macro, true)) {
- std::cerr << "testwave: failed to predefine macro: " << macro
+ std::cerr << "testwave: failed to predefine macro: " << macro
<< std::endl;
return false;
}
else if (9 == debuglevel) {
- std::cerr << "add_strict_lexer_definition: predefined macro: " << macro
+ std::cerr << "add_strict_lexer_definition: predefined macro: " << macro
<< std::endl;
}
return true;
@@ -1200,12 +1202,12 @@
//
// Add special predefined macros to the context object.
//
-// This adds a lot of macros to the test environment, which allows to adjust
+// This adds a lot of macros to the test environment, which allows to adjust
// the test cases for different platforms.
//
///////////////////////////////////////////////////////////////////////////////
template <typename Context>
-bool
+bool
testwave_app::add_predefined_macros(Context& ctx)
{
// add the __TESTWAVE_SIZEOF_<type>__ macros
@@ -1217,11 +1219,11 @@
#endif
!add_sizeof_definition(ctx, "LONG", sizeof(long)))
{
- std::cerr << "testwave: failed to add a predefined macro (SIZEOF)."
+ std::cerr << "testwave: failed to add a predefined macro (SIZEOF)."
<< std::endl;
return false;
}
-
+
// add the __TESTWAVE_<type>_MIN__ macros
if (/*!add_min_definition<char>(ctx, "CHAR") ||*/
/*!add_min_definition<unsigned char>(ctx, "UCHAR") ||*/
@@ -1236,10 +1238,10 @@
!add_min_definition<long>(ctx, "LONG") ||
!add_min_definition<unsigned long>(ctx, "ULONG"))
{
- std::cerr << "testwave: failed to add a predefined macro (MIN)."
+ std::cerr << "testwave: failed to add a predefined macro (MIN)."
<< std::endl;
}
-
+
// add the __TESTWAVE_<type>_MAX__ macros
if (/*!add_max_definition<char>(ctx, "CHAR") ||*/
/*!add_max_definition<unsigned char>(ctx, "UCHAR") ||*/
@@ -1254,7 +1256,7 @@
!add_max_definition<long>(ctx, "LONG") ||
!add_max_definition<unsigned long>(ctx, "ULONG"))
{
- std::cerr << "testwave: failed to add a predefined macro (MAX)."
+ std::cerr << "testwave: failed to add a predefined macro (MAX)."
<< std::endl;
}
@@ -1267,31 +1269,31 @@
///////////////////////////////////////////////////////////////////////////////
//
-// Preprocess the given input data and return the generated output through
+// Preprocess the given input data and return the generated output through
// the parameter 'result'.
//
///////////////////////////////////////////////////////////////////////////////
-bool
-testwave_app::preprocess_file(std::string filename, std::string const& instr,
+bool
+testwave_app::preprocess_file(std::string filename, std::string const& instr,
std::string& result, std::string& error, std::string& hooks,
bool single_line)
{
-// create the wave::context object and initialize it from the file to
+// create the wave::context object and initialize it from the file to
// preprocess (may contain options inside of special comments)
typedef boost::wave::cpplexer::lex_token<> token_type;
typedef boost::wave::cpplexer::lex_iterator<token_type> lexer_type;
typedef boost::wave::context<
std::string::const_iterator, lexer_type,
boost::wave::iteration_context_policies::load_file_to_string,
- collect_hooks_information<token_type> >
+ collect_hooks_information<token_type> >
context_type;
if (9 == debuglevel) {
- std::cerr << "preprocess_file: preprocessing input file: " << filename
+ std::cerr << "preprocess_file: preprocessing input file: " << filename
<< std::endl;
}
- try {
+ try {
// create preprocessing context
context_type ctx(instr.begin(), instr.end(), filename.c_str(),
collect_hooks_information<token_type>(hooks));
@@ -1300,21 +1302,44 @@
if (!initialise_options(ctx, global_vm, single_line))
return false;
- // extract the options from the input data and initialize the context
- if (!extract_options(filename, instr, ctx, single_line))
+ // extract the options from the input data and initialize the context
+ boost::program_options::variables_map local_vm;
+ if (!extract_options(filename, instr, ctx, single_line, local_vm))
return false;
// add special predefined macros
if (!add_predefined_macros(ctx))
return false;
-
- // preprocess the input, loop over all generated tokens collecting the
- // generated text
+
+ // preprocess the input, loop over all generated tokens collecting the
+ // generated text
+ context_type::iterator_type it = ctx.begin();
context_type::iterator_type end = ctx.end();
- for (context_type::iterator_type it = ctx.begin(); it != end; ++it)
+
+ if (local_vm.count("forceinclude")) {
+ // add the filenames to force as include files in _reverse_ order
+ // the second parameter 'is_last' of the force_include function should
+ // be set to true for the last (first given) file.
+ std::vector<std::string> const &force =
+ local_vm["forceinclude"].as<std::vector<std::string> >();
+ std::vector<std::string>::const_reverse_iterator rend = force.rend();
+ for (std::vector<std::string>::const_reverse_iterator cit = force.rbegin();
+ cit != rend; /**/)
+ {
+ std::string forceinclude(*cit);
+ if (9 == debuglevel) {
+ std::cerr << "preprocess_file: option: forceinclude ("
+ << forceinclude << ")" << std::endl;
+ }
+ it.force_include(forceinclude.c_str(), ++cit == rend);
+ }
+ }
+
+ // perform actual preprocessing
+ for (/**/; it != end; ++it)
{
using namespace boost::wave;
-
+
if (T_PP_LINE == token_id(*it)) {
// special handling of the whole #line directive is required to
// allow correct file name matching
@@ -1322,8 +1347,8 @@
return false; // unexpected eof
}
else {
- // add the value of the current token
- result = result + (*it).get_value().c_str();
+ // add the value of the current token
+ result = result + (*it).get_value().c_str();
}
}
error.clear();
@@ -1332,10 +1357,10 @@
// some lexer error
BOOST_WAVETEST_OSSTREAM strm;
std::string filename = e.file_name();
- strm
+ strm
<< handle_filepath(filename) << "(" << e.line_no() << "): "
<< e.description() << std::endl;
-
+
error = BOOST_WAVETEST_GETSTRING(strm);
return false;
}
@@ -1343,16 +1368,16 @@
// some preprocessing error
BOOST_WAVETEST_OSSTREAM strm;
std::string filename = e.file_name();
- strm
+ strm
<< handle_filepath(filename) << "(" << e.line_no() << "): "
<< e.description() << std::endl;
-
+
error = BOOST_WAVETEST_GETSTRING(strm);
return false;
}
-
+
if (9 == debuglevel) {
- std::cerr << "preprocess_file: succeeded to preprocess input file: "
+ std::cerr << "preprocess_file: succeeded to preprocess input file: "
<< filename << std::endl;
}
Modified: trunk/libs/wave/test/testwave/testwave_app.hpp
==============================================================================
--- trunk/libs/wave/test/testwave/testwave_app.hpp (original)
+++ trunk/libs/wave/test/testwave/testwave_app.hpp 2012-05-23 10:38:10 EDT (Wed, 23 May 2012)
@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
- Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost
+ Copyright (c) 2001-2012 Hartmut Kaiser. 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)
=============================================================================*/
@@ -23,25 +23,25 @@
{
public:
testwave_app(boost::program_options::variables_map const& vm);
-
- // Test the given file (i.e. preprocess the file and compare the result
+
+ // Test the given file (i.e. preprocess the file and compare the result
// against the embedded 'R' comments, if an error occurs compare the error
// message against the given 'E' comments).
bool test_a_file(std::string filename);
-
+
// print the current version of this program
int print_version();
-
+
// print the copyright statement
int print_copyright();
// access the common options used for the command line and the config
// options inside the test files
boost::program_options::options_description const& common_options() const
- {
- return desc_options;
+ {
+ return desc_options;
}
-
+
void set_debuglevel(int debuglevel_)
{
debuglevel = debuglevel_;
@@ -50,67 +50,68 @@
{
return debuglevel;
}
-
+
protected:
// Read the given file into a string
bool read_file(std::string const& filename, std::string& instr);
// Extract special information from comments marked with the given letter
- bool extract_special_information(std::string const& filename,
+ bool extract_special_information(std::string const& filename,
std::string const& instr, char flag, std::string& content);
- // Extract the expected output and expected hooks information from the
+ // Extract the expected output and expected hooks information from the
// given input data.
// The expected output has to be provided inside of special comments which
- // start with a capital 'R' ('H' for the hooks information). All such
+ // start with a capital 'R' ('H' for the hooks information). All such
// comments are concatenated and returned through the parameter 'expected'
// ('expectedhooks' for hooks information).
- bool extract_expected_output(std::string const& filename,
- std::string const& instr, std::string& expected,
+ bool extract_expected_output(std::string const& filename,
+ std::string const& instr, std::string& expected,
std::string& expectedhooks);
-
- // Extracts the required preprocessing options from the given input data
- // and initializes the given Wave context object accordingly.
- // We allow the same (applicable) options to be used as are valid for the
+
+ // Extracts the required preprocessing options from the given input data
+ // and initializes the given Wave context object accordingly.
+ // We allow the same (applicable) options to be used as are valid for the
// wave driver executable.
template <typename Context>
- bool extract_options(std::string const& filename,
- std::string const& instr, Context& ctx, bool single_line);
+ bool extract_options(std::string const& filename,
+ std::string const& instr, Context& ctx, bool single_line,
+ boost::program_options::variables_map& vm);
- // transfers the options collected in the vm parameter into the given
+ // transfers the options collected in the vm parameter into the given
// context
template <typename Context>
- bool initialise_options(Context& ctx,
+ bool initialise_options(Context& ctx,
boost::program_options::variables_map const& vm, bool single_line);
- // Preprocess the given input data and return the generated output through
+ // Preprocess the given input data and return the generated output through
// the parameter 'result'.
- bool preprocess_file(std::string filename, std::string const& instr,
- std::string& result, std::string& error, std::string& hooks,
+ bool preprocess_file(std::string filename, std::string const& instr,
+ std::string& result, std::string& error, std::string& hooks,
bool single_line = false);
// Add special predefined macros to the context object
template <typename Context>
bool add_predefined_macros(Context& ctx);
- // This function compares the real result and the expected one but first
- // replaces all occurrences in the expected result of
+ // This function compares the real result and the expected one but first
+ // replaces all occurrences in the expected result of
// $E: to the result of preprocessing the given expression
- // $F: to the passed full filepath
+ // $F: to the passed full filepath
// $P: to the full path
// $R: to the relative path
// $V: to the current Boost version number
- bool got_expected_result(std::string const& filename,
+ bool got_expected_result(std::string const& filename,
std::string const& result, std::string& expected);
// construct a SIZEOF macro definition string and predefine this macro
template <typename Context>
bool add_sizeof_definition(Context& ctx, char const *name, int value);
-
+
// construct a MIN macro definition string and predefine this macro
template <typename T, typename Context>
bool add_min_definition(Context& ctx, char const *name);
-
+
// construct a MAX macro definition string and predefine this macro
template <typename T, typename Context>
bool add_max_definition(Context& ctx, char const *name);
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