diff --git a/ChangeLog b/ChangeLog index 3cb10d3..824d694 100644 --- a/ChangeLog +++ b/ChangeLog @@ -165,7 +165,8 @@ Boost V1.34.0 - The warning, that a file is not terminated by a newline is now issued for all files, not only for the main file (as previous). - Added a couple of new test cases to verify various diagnostics. - +- Fixed wave applet not to report missing #endif's when in interactive mode. + Sat Feb 18 2005 - Version 1.2.3 - Added a missing throw() specification to the function diff --git a/include/boost/wave/util/cpp_iterator.hpp b/include/boost/wave/util/cpp_iterator.hpp index 6141cd6..02cd109 100644 --- a/include/boost/wave/util/cpp_iterator.hpp +++ b/include/boost/wave/util/cpp_iterator.hpp @@ -642,7 +642,9 @@ bool returned_from_include_file = returned_from_include(); (returned_from_include_file = returned_from_include())); // overall eof reached - if (ctx.get_if_block_depth() > 0) { + if (ctx.get_if_block_depth() > 0 && + !(support_option_single_line & get_support_options(ctx.get_language()))) + { // missing endif directive(s) BOOST_WAVE_THROW(preprocess_exception, missing_matching_endif, "", act_pos); diff --git a/tool/cpp.cpp b/tool/cpp.cpp index f4fea0d..e32398e 100644 --- a/tool/cpp.cpp +++ b/tool/cpp.cpp @@ -356,15 +356,27 @@ namespace { /////////////////////////////////////////////////////////////////////////// // Generate some meaningful error messages - template + template inline int - report_error_message(Context &ctx, boost::wave::cpp_exception const &e) + report_error_message(Exception const &e) { // default error reporting cerr << e.file_name() << ":" << e.line_no() << ":" << e.column_no() << ": " << e.description() << endl; + // errors count as one + return (e.get_severity() == boost::wave::util::severity_error || + e.get_severity() == boost::wave::util::severity_fatal) ? 1 : 0; + } + + template + inline int + report_error_message(Context &ctx, boost::wave::cpp_exception const &e) + { + // default error reporting + int result = report_error_message(e); + using boost::wave::preprocess_exception; switch(e.get_errorcode()) { case preprocess_exception::macro_redefinition: @@ -392,12 +404,10 @@ namespace { default: break; } - - // errors count as one - return (e.get_severity() == boost::wave::util::severity_error || - e.get_severity() == boost::wave::util::severity_fatal) ? 1 : 0; - } + return result; + } + /////////////////////////////////////////////////////////////////////////// // Read one logical line of text inline bool @@ -797,6 +807,20 @@ int error_count = 0; default_outfile = out_file.string(); } + // we assume the session to be interactive if input is stdin and output is + // stdout and the output is not inhibited + bool is_interactive = input_is_stdin && !output.is_open() && allow_output; + + if (is_interactive) { + // if interactive we don't warn for missing endif's etc. + ctx.set_language(boost::wave::set_support_options(ctx.get_language(), + (boost::wave::language_support)( + boost::wave::get_support_options(ctx.get_language()) | + boost::wave::support_option_single_line) + ) + ); + } + // analyze the input file context_type::iterator_type first = ctx.begin(); context_type::iterator_type last = ctx.end(); @@ -817,10 +841,6 @@ int error_count = 0; } } - // we assume the session to be interactive if input is stdin and output is - // stdout and the output is not inhibited - bool is_interactive = input_is_stdin && !output.is_open() && allow_output; - elapsed_time.set_print_time(!input_is_stdin && vm.count("timer") > 0); if (is_interactive) { print_interactive_version(); // print welcome message @@ -890,10 +910,7 @@ int error_count = 0; if (is_interactive || boost::wave::cpplexer::is_recoverable(e)) { - cerr - << e.file_name() << ":" << e.line_no() << ":" - << e.column_no() << ": " << e.description() << endl; - ++error_count; + error_count += report_error_message(e); } else { throw; // re-throw for non-recoverable errors @@ -907,16 +924,12 @@ int error_count = 0; } catch (boost::wave::cpp_exception const &e) { // some preprocessing error - cerr - << e.file_name() << ":" << e.line_no() << ":" << e.column_no() << ": " - << e.description() << endl; + report_error_message(e); return 1; } catch (boost::wave::cpplexer::lexing_exception const &e) { // some lexing error - cerr - << e.file_name() << ":" << e.line_no() << ":" << e.column_no() << ": " - << e.description() << endl; + report_error_message(e); return 2; } catch (std::exception const &e) {