mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
No more magic booleans. The word of Andre is spreading.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32926 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
33e123a5cd
commit
28b0075b11
@ -27,6 +27,13 @@ using namespace lyx::support;
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
|
||||||
|
enum Direction {
|
||||||
|
Forward = 0,
|
||||||
|
Backward
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void step_forward(DocIterator & dit)
|
void step_forward(DocIterator & dit)
|
||||||
{
|
{
|
||||||
dit.top().forwardPos();
|
dit.top().forwardPos();
|
||||||
@ -386,19 +393,19 @@ bool equal(DocIterator & o, DocIterator & n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool traverse_snake(DocPair & p, DocRangePair const & rp, bool forward)
|
bool traverse_snake(DocPair & p, DocRangePair const & rp, Direction direction)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
DocPair const & p_end = forward ? rp.to() : rp.from();
|
DocPair const & p_end = direction == Forward ? rp.to() : rp.from();
|
||||||
while (p != p_end) {
|
while (p != p_end) {
|
||||||
if (!forward)
|
if (direction == Backward)
|
||||||
--p;
|
--p;
|
||||||
if (!equal(p.o, p.n)) {
|
if (!equal(p.o, p.n)) {
|
||||||
if (!forward)
|
if (direction == Backward)
|
||||||
++p;
|
++p;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (forward)
|
if (direction == Forward)
|
||||||
++p;
|
++p;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
@ -439,7 +446,7 @@ bool Compare::Impl::diff(Buffer const * new_buf, Buffer const * old_buf,
|
|||||||
DocRangePair rp(old_buf_, new_buf_);
|
DocRangePair rp(old_buf_, new_buf_);
|
||||||
|
|
||||||
DocPair from = rp.from();
|
DocPair from = rp.from();
|
||||||
traverse_snake(from, rp, true);
|
traverse_snake(from, rp, Forward);
|
||||||
DocRangePair const snake(rp.from(), from);
|
DocRangePair const snake(rp.from(), from);
|
||||||
process_snake(snake);
|
process_snake(snake);
|
||||||
|
|
||||||
@ -484,11 +491,11 @@ void Compare::Impl::diff_i(DocRangePair const & rp)
|
|||||||
} else {
|
} else {
|
||||||
// Retrieve the complete snake
|
// Retrieve the complete snake
|
||||||
DocPair first_part_end = middle_snake;
|
DocPair first_part_end = middle_snake;
|
||||||
traverse_snake(first_part_end, rp, false);
|
traverse_snake(first_part_end, rp, Backward);
|
||||||
DocRangePair first_part(rp.from(), first_part_end);
|
DocRangePair first_part(rp.from(), first_part_end);
|
||||||
|
|
||||||
DocPair second_part_begin = middle_snake;
|
DocPair second_part_begin = middle_snake;
|
||||||
traverse_snake(second_part_begin, rp, true);
|
traverse_snake(second_part_begin, rp, Forward);
|
||||||
DocRangePair second_part(second_part_begin, rp.to());
|
DocRangePair second_part(second_part_begin, rp.to());
|
||||||
|
|
||||||
// Split the string in three parts:
|
// Split the string in three parts:
|
||||||
|
Loading…
Reference in New Issue
Block a user