Skip to content

Commit 0470d7c

Browse files
committed
fix macro-define fail with '/' char when comment(/**/) in last line
1 parent 6e0fffb commit 0470d7c

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

cpptoxml/parser/rpp/pp-engine-bits.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,11 @@ _InputIterator pp::handle_define (_InputIterator __first, _InputIterator __last)
606606
{
607607
if (*__first == '/') {
608608
__first = skip_comment_or_divop(__first, __last);
609-
if (skip_comment_or_divop.lines == 0)
610-
definition += '/';
611-
else
609+
if (skip_comment_or_divop.lines == 0) {
610+
if (skip_comment_or_divop.state != skip_comment_or_divop.END) {
611+
definition += '/';
612+
}
613+
} else
612614
env.current_line += skip_comment_or_divop.lines;
613615
}
614616

cpptoxml/parser/rpp/pp-scanner.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,20 @@ struct pp_skip_comment_or_divop
6969
{
7070
int lines;
7171

72+
enum {
73+
MAYBE_BEGIN,
74+
BEGIN,
75+
MAYBE_END,
76+
END,
77+
IN_COMMENT,
78+
IN_CXX_COMMENT
79+
} state;
80+
7281
template <typename _InputIterator>
7382
_InputIterator operator () (_InputIterator __first, _InputIterator __last)
7483
{
75-
enum {
76-
MAYBE_BEGIN,
77-
BEGIN,
78-
MAYBE_END,
79-
END,
80-
IN_COMMENT,
81-
IN_CXX_COMMENT
82-
} state (MAYBE_BEGIN);
83-
8484
lines = 0;
85+
state = MAYBE_BEGIN;
8586

8687
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
8788
{

0 commit comments

Comments
 (0)