Skip to content

Commit

Permalink
xml parser: reduce duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
bbshelper authored and poire-z committed Jun 27, 2024
1 parent 40082dc commit 8b1cb64
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions crengine/src/lvxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5749,13 +5749,8 @@ bool LVXMLParser::ReadText()
if ( ptr[1] == ']' ) {
if ( ptr + 2 < end ) {
if ( ptr[2] == '>' ) {
flgBreak = true;
nbCharToSkipOnFlgBreak = 3;
if (!tlen && ptr == begin) {
m_read_buffer_pos += nbCharToSkipOnFlgBreak;
return false;
}
break;
goto end_of_node;
}
}
else if ( !hasNoMoreData ) {
Expand All @@ -5776,13 +5771,8 @@ bool LVXMLParser::ReadText()
const lChar32 * buf = ptr + 2;
lString32 tag(buf, 6);
if ( tag.lowercase() == U"script" ) {
flgBreak = true;
nbCharToSkipOnFlgBreak = 1;
if (!tlen && ptr == begin) {
m_read_buffer_pos += nbCharToSkipOnFlgBreak;
return false;
}
break;
goto end_of_node;
}
}
else if ( !hasNoMoreData ) {
Expand All @@ -5795,13 +5785,8 @@ bool LVXMLParser::ReadText()
}
}
else { // '<' marks the end of this text node
flgBreak = true;
nbCharToSkipOnFlgBreak = 1;
if (!tlen && ptr == begin) {
m_read_buffer_pos += nbCharToSkipOnFlgBreak;
return false;
}
break;
goto end_of_node;
}
}
if (pre_para_splitting) {
Expand All @@ -5812,6 +5797,14 @@ bool LVXMLParser::ReadText()
break;
last_eol = ch == '\r' || ch == '\n';
}
continue;
end_of_node:
flgBreak = true;
if (!tlen && ptr == begin) {
m_read_buffer_pos += nbCharToSkipOnFlgBreak;
return false;
}
break;
}
if ( ptr > begin) { // Append passed-by regular text content to m_txt_buf
tlen += ptr - begin;
Expand Down

0 comments on commit 8b1cb64

Please sign in to comment.