mirror of
https://github.com/boostorg/wave.git
synced 2026-01-19 04:42:16 +00:00
Wave: Fixed a problem in preserve=1 mode, when a C style comment triggered the generation of a #line directive.
[SVN r36710]
This commit is contained in:
@@ -343,7 +343,9 @@ Sat Dec 24 13:33:53 CST 2005
|
||||
- Added the get_severity() function to the exceptions thrown by the Wave
|
||||
library.
|
||||
- Extended the copyright notice to include the year 2006.
|
||||
|
||||
- Fixed a problem in preserve=1 mode, when a C style comment triggered the
|
||||
generation of a #line directive.
|
||||
|
||||
Mon Dec 5 22:05:22 CST 2005
|
||||
Boost V1.33.1
|
||||
- Version 1.2.1
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
<td class="table_cells"><p>The <tt>option(line: ...)</tt> directive allows to control, whether <span class="preprocessor">#line</span> directives will be generated in the output stream. Specify either '0' or '1' as the option parameter. All other values will be flaged as illegal. </p>
|
||||
<p>The <tt>option(preserve: ...)</tt> directive allows to control the amount of whitespace generated in the output stream. The value '0' removes any not needed whitespace, the value '1' keeps comments only and the value '2' does not remove any whitespace.</p>
|
||||
<p>The <tt>option(output: ...)</tt> directive allows to specify the name of the file, where the output is generated to. Specify either a valid filename (which will be interpreted relative to directory of the processed file), the value <tt>null</tt> to disable the output at all, or the value <tt>default</tt> to use the output as specified on the command line using the --output/-o option. </p>
|
||||
<p>The pragma values <tt>push</tt> and <tt>pop</tt> may be used for all of the options (<tt>line</tt>, <tt>preserve</tt> and <tt>output</tt>) to store and restore the current value of the corresponding option . </p></td>
|
||||
<p>The pragma values <tt>push</tt> and <tt>pop</tt> may be used for all of the options (<tt>line</tt>, <tt>preserve</tt> and <tt>output</tt>) to store and restore the current value of the corresponding option. </p></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>All pragma's not listed here but flagged as <tt>'wave'</tt> are currently reported as
|
||||
@@ -134,7 +134,7 @@
|
||||
<font size="2">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) </font> </p>
|
||||
<span class="updated"></span>
|
||||
<p class="copyright"><span class="updated">Last updated:
|
||||
<!-- #BeginDate format:fcAm1m -->Thursday, January 11, 2007 20:11<!-- #EndDate -->
|
||||
<!-- #BeginDate format:fcAm1m -->Thursday, January 11, 2007 20:14<!-- #EndDate -->
|
||||
</span>
|
||||
</p>
|
||||
<p> </p>
|
||||
|
||||
@@ -505,15 +505,13 @@ pp_iterator_functor<ContextT>::operator()()
|
||||
seen_newline = false;
|
||||
switch (static_cast<unsigned int>(id)) {
|
||||
case T_NONREPLACABLE_IDENTIFIER:
|
||||
act_token.set_token_id(T_IDENTIFIER);
|
||||
id = T_IDENTIFIER;
|
||||
act_token.set_token_id(id = T_IDENTIFIER);
|
||||
break;
|
||||
|
||||
case T_GENERATEDNEWLINE: // was generated by emit_line_directive()
|
||||
act_token.set_token_id(T_NEWLINE);
|
||||
case T_GENERATEDNEWLINE: // was generated by emit_line_directive()
|
||||
act_token.set_token_id(id = T_NEWLINE);
|
||||
++iter_ctx->emitted_lines;
|
||||
seen_newline = true;
|
||||
id = T_NEWLINE;
|
||||
break;
|
||||
|
||||
case T_NEWLINE:
|
||||
@@ -522,9 +520,13 @@ pp_iterator_functor<ContextT>::operator()()
|
||||
++iter_ctx->emitted_lines;
|
||||
break;
|
||||
|
||||
case T_PP_NUMBER:
|
||||
case T_CCOMMENT: // will come here only if whitespace is preserved
|
||||
iter_ctx->emitted_lines +=
|
||||
context_policies::util::ccomment_count_newlines(act_token);
|
||||
break;
|
||||
|
||||
case T_PP_NUMBER: // re-tokenize the pp-number
|
||||
{
|
||||
// re-tokenize the pp-number
|
||||
token_sequence_type rescanned;
|
||||
|
||||
std::string pp_number(act_token.get_value().c_str());
|
||||
@@ -546,8 +548,7 @@ pp_iterator_functor<ContextT>::operator()()
|
||||
seen_newline = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
// make sure whitespace at line begin keeps seen_newline status
|
||||
default: // make sure whitespace at line begin keeps seen_newline status
|
||||
if (IS_CATEGORY(id, WhiteSpaceTokenType))
|
||||
seen_newline = skipped_newline;
|
||||
break;
|
||||
@@ -815,6 +816,7 @@ token_id id = token_id(*iter_ctx->first);
|
||||
|
||||
} while (T_PLACEHOLDER == id);
|
||||
|
||||
act_pos = act_token.get_position();
|
||||
return act_token;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,20 +29,40 @@ namespace context_policies {
|
||||
|
||||
namespace util {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This function returns true if the given C style comment contains at
|
||||
// least one newline
|
||||
template <typename TokenT>
|
||||
bool ccomment_has_newline(TokenT const& token)
|
||||
{
|
||||
using namespace boost::wave;
|
||||
|
||||
if (T_CCOMMENT == token_id(token)) {
|
||||
if (TokenT::string_type::npos !=
|
||||
token.get_value().find_first_of("\n"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (T_CCOMMENT == token_id(token) &&
|
||||
TokenT::string_type::npos != token.get_value().find_first_of("\n"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This function returns the number of newlines in the given C style
|
||||
// comment
|
||||
template <typename TokenT>
|
||||
int ccomment_count_newlines(TokenT const& token)
|
||||
{
|
||||
using namespace boost::wave;
|
||||
int newlines = 0;
|
||||
if (T_CCOMMENT == token_id(token)) {
|
||||
TokenT::string_type const& value = token.get_value();
|
||||
TokenT::string_type::size_type p = value.find_first_of("\n");
|
||||
|
||||
while (TokenT::string_type::npos != p) {
|
||||
++newlines;
|
||||
p = value.find_first_of("\n", p+1);
|
||||
}
|
||||
}
|
||||
return newlines;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user