134#define DECLARE_DIFF_SOURCE_HELPERS(decl)\
135decl void ida_export diff_source_merge_region(class diff_source_t *destination, class diff_source_t *source, const diff_range_t &dr);
137#define DECLARE_DIFF_SOURCE_HELPERS(decl)
154 if ( last < r.
start )
161 void _merge_region(diff_source_t *source,
const diff_range_t &dr);
169 diff_source_t(
int id) : dbctx_id(
id) {}
171 virtual ~diff_source_t() {}
181 virtual void init_diff_source() {}
184 virtual void set_range(
const diff_range_t &r) { range = r; }
187 virtual const diff_range_t &get_range()
const {
return range; }
213 diff_source_t * )
const
230 virtual void merge_add(diff_source_t * ,
diffpos_t ) {}
237 virtual void merge_replace(diff_source_t *src,
diffpos_t dpos)
240 merge_add(src, dpos);
247 virtual void merge_region(diff_source_t *src,
const diff_range_t ®ion)
249 diff_source_merge_region(
this, src, region);
255 virtual void dump_merge_results(FILE * )
const {}
259 void test_diffpos_behavior()
const;
260 bool is_valid_position(
diffpos_t dpos)
const
262 return get_range().contains(dpos) && check_position(dpos) == dpos;
264 diff_texts_t print_diff_source(
bool with_details=
true)
const
266 return print_range(
nullptr, with_details);
274 MERGE_POLICY_USE_LOCAL,
275 MERGE_POLICY_USE_REMOTE,
276 MERGE_POLICY_POSTPONE,
305 bool merge_one_region(
size_t n, merge_policy_t merge_policy)
const;
366 diff_source_t *
src2);
378 diff_source_t *src2);
381 const char *
const *headers,
385#define PSBS_DIFF_STARS 0x01
386#define PSBS_ONLY_DIFFS 0x02
413 void append(
const T &v,
size_t idx) {
part.push_back(v[idx]); }
438 void eq(
const T &v,
size_t idx)
445 void add(
const T &v,
size_t idx)
452 void sub(
const T &v,
size_t idx)
461 if ( this->
empty() || this->
back().action != wanted_action )
487 lcsdiff_t(
const T &_x,
const T &_y,
size_t _n,
size_t _m)
495 const size_t rows =
n + 1;
496 const size_t cols =
m + 1;
500 for (
size_t i=0; i < rows; ++i )
502 for (
size_t j=0; j < cols; ++j )
504 if ( i == 0 || j == 0 )
508 else if (
x[i - 1] ==
y[j - 1] )
510 table(i, j) = 1 + table(i - 1, j - 1);
514 size_t l = table(i - 1, j);
515 size_t u = table(i, j - 1);
516 table(i, j) = qmax(l, u);
530 while ( i != 0 || j != 0 )
544 else if (
x[i - 1] ==
y[j - 1] )
550 else if ( table(i - 1, j) <= table(i, j - 1) )
560 for (
auto &part :
result )
565 size_t &table(
size_t i,
size_t j)
567 const size_t idx = i * (
m + 1) + j;
607#define DECLARE_TXTDIFF_HELPERS(decl)\
608decl void ida_export txtdiff_t_diff_mod(txtdiff_t *_this);\
609decl void ida_export txtdiff_t_serialize(txtdiff_t *_this, txtdiff_printer_t &printer);
611#define DECLARE_TXTDIFF_HELPERS(decl)
614DECLARE_TXTDIFF_HELPERS(idaman)
618class txtdiff_t :
public lcsdiff_t<qstrvec_t>
628 void diff_mod() { txtdiff_t_diff_mod(
this); }
633 void serialize(txtdiff_printer_t &printer) { txtdiff_t_serialize(
this, printer); }
647 use_mod ? d.diff_mod() : d.diff();
648 for (
const auto &dl : d.result )
650 char c = dl.action ==
TDLA_EQ ?
' '
654 for (
auto &p : dl.part )
655 res->
push_back().sprnt(
"%c %s", c, p.c_str());
660 DECLARE_TXTDIFF_HELPERS(
friend)
663 void _serialize(txtdiff_printer_t &printer);
665#undef DECLARE_TXTDIFF_HELPERS
694#define DECLARE_STRDIFF_HELPERS(decl)\
695decl void ida_export strdiff_t_serialize(strdiff_t *_this, strdiff_printer_t &printer);
697#define DECLARE_STRDIFF_HELPERS(decl)
700DECLARE_STRDIFF_HELPERS(idaman)
704class strdiff_t :
public lcsdiff_t<qstring>
712 void serialize(strdiff_printer_t &printer) { strdiff_t_serialize(
this, printer); }
715 DECLARE_STRDIFF_HELPERS(
friend)
717 void _serialize(strdiff_printer_t &printer);
719#undef DECLARE_STRDIFF_HELPERS
virtual bool get_diff_regions(diff_regions_t *out) override
diff2_engine_t(diff_source_t *_src1, diff_source_t *_src2)
Definition diff3.hpp:341
bool get_diff_region(diff_region_t *out)
A 3-way difference engine.
Definition diff3.hpp:357
virtual bool get_diff_regions(diff_regions_t *out) override
diff3_engine_t(diff_source_t *base, diff_source_t *src1, diff_source_t *src2)
virtual ~diff3_engine_t()
Definition diff3.hpp:367
diff_source_t * src1
Definition diff3.hpp:315
diff_source_t * src2
Definition diff3.hpp:316
diff_engine_t(diff_source_t *_src1, diff_source_t *_src2)
Definition diff3.hpp:319
virtual bool get_diff_regions(diff_regions_t *out)=0
friend class diff3_engine_t
Definition diff3.hpp:313
diff_result_t perform_diff()
result
Definition diff3.hpp:435
void add(const T &v, size_t idx)
vector's item should be added
Definition diff3.hpp:445
void sub(const T &v, size_t idx)
vector's item should be deleted
Definition diff3.hpp:452
void eq(const T &v, size_t idx)
vector's items are equal
Definition diff3.hpp:438
Calculate difference between two vectors.
Definition diff3.hpp:473
const size_t n
left argument size
Definition diff3.hpp:477
lcsdiff_t(const T &_x, const T &_y, size_t _n, size_t _m)
prepare LCS table
Definition diff3.hpp:487
sizevec_t lcs_table
table to store LCS for each step of the calculation
Definition diff3.hpp:479
void diff()
get a difference between two vectors RESULT will contain only TDLA_EQ, TDLA_ADD, TDLA_SUB actions
Definition diff3.hpp:525
result_t result
Definition diff3.hpp:483
const size_t m
right argument size
Definition diff3.hpp:478
const T & y
right argument
Definition diff3.hpp:476
const T & x
left argument
Definition diff3.hpp:475
lcsdiff_res_t< T > result_t
Definition diff3.hpp:482
Reimplementation of vector class from STL.
Definition pro.h:2250
bool empty(void) const
Definition pro.h:2424
const T & back(void) const
Definition pro.h:2431
qvector(void)
Definition pro.h:2328
void push_back(T &&x)
Definition pro.h:2361
size_t size(void) const
Get the number of elements in the qvector.
Definition pro.h:2423
diff_result_t perform_diff3(diff_source_t *base, diff_source_t *src1, diff_source_t *src2)
Perform 3-way difference.
diffpos_check_t
Definition diff3.hpp:107
@ DIFFPOS_BACKWARD
back off to the previous valid position
Definition diff3.hpp:111
@ DIFFPOS_FORWARD
advance to the next valid position
Definition diff3.hpp:110
@ DIFFPOS_CHECK
verify if the position is valid; if not, return the next valid position
Definition diff3.hpp:108
qvector< diff_text_t > diff_texts_t
Definition diff3.hpp:120
DECLARE_DIFF_SOURCE_HELPERS(idaman) class diff_source_t
A difference source.
Definition diff3.hpp:140
enum merge_policy_t ENUM_SIZE(uint8)
Definition diff3.hpp:271
diff_source_idx_t
standard indexes into dbctx_ids[] and similar arrays
Definition diff3.hpp:125
@ BASE_IDX
Definition diff3.hpp:129
@ LOCAL_IDX
Definition diff3.hpp:127
@ NONE_IDX
Definition diff3.hpp:126
@ REMOTE_IDX
Definition diff3.hpp:128
lcsdiff_result_action_t
diff result actions, lcsdiff_t::diff lcsdiff_t::diff_mod
Definition diff3.hpp:391
@ TDLA_MOD
updated items (new content)
Definition diff3.hpp:395
@ TDLA_SUB
removed items
Definition diff3.hpp:394
@ TDLA_ADD
added items
Definition diff3.hpp:393
@ TDLA_EQ
items are equal
Definition diff3.hpp:392
qvector< diff_region_t > diff_regions_t
Definition diff3.hpp:103
diff_action_t
Definition diff3.hpp:84
@ DIFF_USE1
use information from src1
Definition diff3.hpp:86
@ DIFF_BOTH
use information from both (conflict)
Definition diff3.hpp:88
@ DIFF_USE2
use information from src2
Definition diff3.hpp:87
@ DIFF_NONE
unknown
Definition diff3.hpp:85
DECLARE_TYPE_AS_MOVABLE(diff_range_t)
qstrvec_t put_side_by_side(const char *const *headers, const diff_texts_t *const *linevecs, size_t n, int psbs_flags=0)
ssize_t diff_degree_t
A difference degree.
Definition diff3.hpp:80
idaman size_t n
Definition pro.h:997
cexpr_t * e
Definition hexrays.hpp:7308
asize_t size
Definition kernwin.hpp:6339
void(idaapi *range_marker)(ea_t ea
Pointer to range marker function (for idaviews and hexviews) This pointer is initialized by setup_ran...
qvector< size_t > sizevec_t
vector of sizes
Definition pro.h:2767
size_t diffpos_t
Definition pro.h:479
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:381
constexpr diffpos_t BADDIFF
Definition pro.h:480
unsigned char uint8
unsigned 8 bit value
Definition pro.h:344
_qstring< char > qstring
regular string
Definition pro.h:3694
qvector< qstring > qstrvec_t
vector of strings
Definition pro.h:3697
A range of the difference source.
Definition diff3.hpp:30
diffpos_t end
Definition diff3.hpp:32
void set_start(diffpos_t p)
Definition diff3.hpp:37
bool contains(diffpos_t p) const
Definition diff3.hpp:36
void set_end(diffpos_t p)
Definition diff3.hpp:43
bool operator==(const diff_range_t &r) const
Definition diff3.hpp:61
int compare(const diff_range_t &r) const
Definition diff3.hpp:59
diff_range_t(diffpos_t s=0, diffpos_t e=0)
Definition diff3.hpp:33
void intersect(const diff_range_t &r)
Definition diff3.hpp:49
void clear()
Definition diff3.hpp:35
bool empty() const
Definition diff3.hpp:34
diffpos_t start
Definition diff3.hpp:31
bool operator!=(const diff_range_t &r) const
Definition diff3.hpp:62
A difference region.
Definition diff3.hpp:95
void clear()
Definition diff3.hpp:98
diff_degree_t diff_degree
Definition diff3.hpp:96
bool is_useless() const
Definition diff3.hpp:99
diff_action_t action
Definition diff3.hpp:97
A difference result.
Definition diff3.hpp:287
diff_regions_t regions
Definition diff3.hpp:290
size_t size() const
Definition diff3.hpp:294
diff_source_t * src2
Definition diff3.hpp:289
bool empty() const
Definition diff3.hpp:295
qstrvec_t print_region(const diff_region_t &b, bool with_details=true) const
qstrvec_t print_diff_result(bool with_details=true) const
diff_source_t * src1
Definition diff3.hpp:288
size_t merge_diff_sources(merge_policy_t merge_policy, size_t i1=0, size_t i2=SIZE_MAX)
merge src1 and src2 into src1.
diff_result_t(diff_source_t *s1=nullptr, diff_source_t *s2=nullptr)
Definition diff3.hpp:291
diffpos_t pos
Definition diff3.hpp:117
void reverse()
Definition diff3.hpp:427
void append(const qstring &v, size_t idx)
Definition diff3.hpp:426
qstring part
vector's items
Definition diff3.hpp:420
lcsdiff_res_part_t(lcsdiff_result_action_t _a)
Definition diff3.hpp:424
lcsdiff_result_action_t action
action for items, lcsdiff_result_action_t
Definition diff3.hpp:422
qstring x_part
previous content, only for TDLA_MOD
Definition diff3.hpp:421
difference result, stores vectors' items with action to be applied to construct Y from X
Definition diff3.hpp:406
T x_part
previous content, only for TDLA_MOD
Definition diff3.hpp:408
void append(const T &v, size_t idx)
Definition diff3.hpp:413
T part
vector's items
Definition diff3.hpp:407
void reverse()
Definition diff3.hpp:414
lcsdiff_res_part_t(lcsdiff_result_action_t _a)
Definition diff3.hpp:411
lcsdiff_result_action_t action
action for items, lcsdiff_result_action_t
Definition diff3.hpp:409
virtual void on_event(event_t ev,...)=0
strdiff_printer_t()
Definition diff3.hpp:684
virtual ~strdiff_printer_t()
Definition diff3.hpp:685
event_t
Definition diff3.hpp:672
@ del_chars
deleted chars from line X, TDLA_SUB
Definition diff3.hpp:680
@ add_chars
added chars to line from X, TDLA_ADD
Definition diff3.hpp:678
@ same_chars
the same chars, TDLA_EQ
Definition diff3.hpp:676
@ term_chars
end printing
Definition diff3.hpp:674
@ init_chars
start printing
Definition diff3.hpp:673
event_t
Definition diff3.hpp:578
@ del_line
line is removed from X, TDLA_SUB
Definition diff3.hpp:590
@ next_line
start to print next line
Definition diff3.hpp:583
@ add_line
line is added to X, TDLA_ADD
Definition diff3.hpp:588
@ mod_line
line is changed, TDLA_MOD
Definition diff3.hpp:592
@ init
start printing
Definition diff3.hpp:579
@ same_line
line is the same in X and Y, TDLA_EQ
Definition diff3.hpp:586
@ term
end printing
Definition diff3.hpp:580
txtdiff_printer_t()
Definition diff3.hpp:597
virtual ~txtdiff_printer_t()
Definition diff3.hpp:598
virtual void on_event(event_t ev,...)=0