From 2985cccb25adfa70e500b0dd9b3a55ab5b59ae2f Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Sat, 7 Feb 2004 13:09:44 +0000 Subject: [PATCH] Fixed certain minor bugs. [SVN r1940] --- include/boost/wave/util/cpp_ifblock.hpp | 2 +- include/boost/wave/util/cpp_iterator.hpp | 23 ++++++++++---- include/boost/wave/util/cpp_macromap.hpp | 38 +++++++++++++----------- include/boost/wave/wave_config.hpp | 2 +- include/boost/wave/wave_version.hpp | 4 +-- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/include/boost/wave/util/cpp_ifblock.hpp b/include/boost/wave/util/cpp_ifblock.hpp index ad6de6a..2ff6d78 100644 --- a/include/boost/wave/util/cpp_ifblock.hpp +++ b/include/boost/wave/util/cpp_ifblock.hpp @@ -98,7 +98,7 @@ public: this->top().set_status(true); } else if (get_status()) { - // Entered (false) else block from true block + // Entered (false) #else block from true block this->top().set_status(false); } diff --git a/include/boost/wave/util/cpp_iterator.hpp b/include/boost/wave/util/cpp_iterator.hpp index 5b85564..c61b5e1 100644 --- a/include/boost/wave/util/cpp_iterator.hpp +++ b/include/boost/wave/util/cpp_iterator.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -140,12 +141,20 @@ bool add_macro_definition(ContextT &ctx, std::string macrostring, predef_macros_t; using namespace boost::wave; + using namespace std; // isspace is in std namespace for some systems +// skip leading whitespace +std::string::iterator begin = macrostring.begin(); +std::string::iterator end = macrostring.end(); + + while(begin != end && isspace(*begin)) + ++begin; + +// parse the macr definition position_t act_pos("command line", 0); boost::spirit::tree_parse_info hit = predef_macros_t::parse_predefined_macro( - lex_t(macrostring.begin(), macrostring.end(), position_t(), language), - lex_t()); + lex_t(begin, end, position_t(), language), lex_t()); if (!hit.match || (!hit.full && T_EOF != token_id(*hit.stop))) { BOOST_WAVE_THROW(preprocess_exception, bad_macro_definition, macrostring, @@ -1300,6 +1309,7 @@ token_sequence_t toexpand; typename token_sequence_t::iterator begin2 = toexpand.begin(); ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded); +// replace all remaining (== undefined) identifiers with a integer lliteral '0' typename token_sequence_t::iterator exp_end = expanded.end(); for (typename token_sequence_t::iterator exp_it = expanded.begin(); exp_it != exp_end; ++exp_it) @@ -1362,6 +1372,7 @@ token_sequence_t toexpand; typename token_sequence_t::iterator begin2 = toexpand.begin(); ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded); +// replace all remaining (== undefined) identifiers with a integer lliteral '0' typename token_sequence_t::iterator exp_end = expanded.end(); for (typename token_sequence_t::iterator exp_it = expanded.begin(); exp_it != exp_end; ++exp_it) @@ -1539,7 +1550,7 @@ typename ref_transform_iterator_generator< >::type first = make_ref_transform_iterator(begin, get_value); #if BOOST_WAVE_PREPROCESS_ERROR_MESSAGE_BODY != 0 -// preprocess the body of this #warning message +// preprocess the body of this #error message token_sequence_t toexpand; std::copy(first, make_ref_transform_iterator(end, get_value), @@ -1549,13 +1560,13 @@ token_sequence_t toexpand; ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded, false); #else -// simply copy the body of this #warning message to the issued diagnostic +// simply copy the body of this #error message to the issued diagnostic // message std::copy(first, make_ref_transform_iterator(end, get_value), std::inserter(expanded, expanded.end())); #endif -// throw the corresponding exception +// report the corresponding error BOOST_WAVE_THROW(preprocess_exception, error_directive, boost::wave::util::impl::as_string(expanded), act_pos); } @@ -1600,7 +1611,7 @@ token_sequence_t toexpand; std::inserter(expanded, expanded.end())); #endif -// throw the corresponding exception +// report the corresponding error BOOST_WAVE_THROW(preprocess_exception, warning_directive, boost::wave::util::impl::as_string(expanded), act_pos); } diff --git a/include/boost/wave/util/cpp_macromap.hpp b/include/boost/wave/util/cpp_macromap.hpp index e544380..f79e694 100644 --- a/include/boost/wave/util/cpp_macromap.hpp +++ b/include/boost/wave/util/cpp_macromap.hpp @@ -51,7 +51,7 @@ namespace util { namespace on_exit { - // on destruction pop the first element of the argument list + // on destruction pop the first element of the list given as the argument template struct pop_front { @@ -61,8 +61,8 @@ namespace on_exit { ContainerT &list; }; - // append a given list to the argument list - // on destruction pop the first element of the argument list + // append a given list to the list given as argument + // on destruction pop the first element of the list given as argument template struct splice_pop_front { @@ -109,7 +109,8 @@ namespace on_exit { // // macromap // -// This class holds all currently defined macros +// This class holds all currently defined macros and on demand expands +// those macrodefinitions // /////////////////////////////////////////////////////////////////////////////// template @@ -446,7 +447,7 @@ typename defined_macros_t::iterator it = current_scope->find(name.get_value()); /////////////////////////////////////////////////////////////////////////////// // -// is_defined(): returnes, whether a given macro is already defined +// is_defined(): returns, whether a given macro is already defined // /////////////////////////////////////////////////////////////////////////////// template @@ -1428,14 +1429,6 @@ token_t startof_argument_list = *next; return count_arguments; } -/////////////////////////////////////////////////////////////////////////////// -// -// expand_macro(): expands a defined macro -// -// This functions tries to expand the macro, to which points the 'first' -// iterator. The functions eats up more tokens, if the macro to expand is -// a function-like macro. -// /////////////////////////////////////////////////////////////////////////////// namespace { @@ -1773,6 +1766,15 @@ namespace impl { }; } +/////////////////////////////////////////////////////////////////////////////// +// +// expand_macro(): expands a defined macro +// +// This functions tries to expand the macro, to which points the 'first' +// iterator. The functions eats up more tokens, if the macro to expand is +// a function-like macro. +// +/////////////////////////////////////////////////////////////////////////////// template template inline bool @@ -2094,16 +2096,16 @@ macromap::resolve_operator_pragma(IteratorT &first, if (T_STRINGLIT != token_id(*it_exp)) { // ill formed operator _Pragma - BOOST_WAVE_THROW(preprocess_exception, ill_formed_pragma_option, "_Pragma", - pragma_token.get_position()); + BOOST_WAVE_THROW(preprocess_exception, ill_formed_pragma_option, + "_Pragma", pragma_token.get_position()); } if (pragma_cmd.size() > 0) { // there should be exactly one string literal (string literals are to // be concatenated at translation phase 6, but _Pragma operators are // to be executed at translation phase 4) - BOOST_WAVE_THROW(preprocess_exception, ill_formed_pragma_option, "_Pragma", - pragma_token.get_position()); + BOOST_WAVE_THROW(preprocess_exception, ill_formed_pragma_option, + "_Pragma", pragma_token.get_position()); } // remove the '\"' and concat all given string literal-values @@ -2381,7 +2383,7 @@ namespace { // // #region [] // -// Where is a simple name (non-qualified name) defining the +// Where is a possibly qualified name defining the // name of the region to open. This name is optional. If the name is // omitted a nameless region is opened. Macros defined inside a nameless // region may not be accessed from outside this region. diff --git a/include/boost/wave/wave_config.hpp b/include/boost/wave/wave_config.hpp index fb64ea4..6350746 100644 --- a/include/boost/wave/wave_config.hpp +++ b/include/boost/wave/wave_config.hpp @@ -98,7 +98,7 @@ #endif /////////////////////////////////////////////////////////////////////////////// -// Uncomment the following, to enable some MS specific language extensions: +// Undefine the following, to enable some MS specific language extensions: // __int8, __int16, __int32, __int64, __based, __declspec, __cdecl, // __fastcall, __stdcall, __try, __except, __finally, __leave, __inline, // __asm diff --git a/include/boost/wave/wave_version.hpp b/include/boost/wave/wave_version.hpp index b2a698b..759d3a2 100644 --- a/include/boost/wave/wave_version.hpp +++ b/include/boost/wave/wave_version.hpp @@ -17,11 +17,11 @@ // BOOST_WAVE_VERSION & 0x00FF is the sub-minor version // BOOST_WAVE_VERSION & 0x0F00 is the minor version // BOOST_WAVE_VERSION & 0xF000 is the major version -#define BOOST_WAVE_VERSION 0x1100 +#define BOOST_WAVE_VERSION 0x1101 // The following defines contain the same information as above #define BOOST_WAVE_VERSION_MAJOR 1 #define BOOST_WAVE_VERSION_MINOR 1 -#define BOOST_WAVE_VERSION_SUBMINOR 0 +#define BOOST_WAVE_VERSION_SUBMINOR 1 #endif // !defined(WAVE_VERSION_H_9D79ABDB_AC54_4C0A_89B1_F70A2DCFE21E_INCLUDED)