Show More
@@ -398,12 +398,11 b' static xdchange_t *xdl_add_change(xdchan' | |||||
398 | } |
|
398 | } | |
399 |
|
399 | |||
400 |
|
400 | |||
401 |
static int recs_match(xrecord_t *rec1, xrecord_t *rec2 |
|
401 | static int recs_match(xrecord_t *rec1, xrecord_t *rec2) | |
402 | { |
|
402 | { | |
403 | return (rec1->ha == rec2->ha && |
|
403 | return (rec1->ha == rec2->ha && | |
404 | xdl_recmatch(rec1->ptr, rec1->size, |
|
404 | xdl_recmatch(rec1->ptr, rec1->size, | |
405 |
rec2->ptr, rec2->size |
|
405 | rec2->ptr, rec2->size)); | |
406 | flags)); |
|
|||
407 | } |
|
406 | } | |
408 |
|
407 | |||
409 | /* |
|
408 | /* | |
@@ -762,10 +761,10 b' static inline int group_previous(xdfile_' | |||||
762 | * following group, expand this group to include it. Return 0 on success or -1 |
|
761 | * following group, expand this group to include it. Return 0 on success or -1 | |
763 | * if g cannot be slid down. |
|
762 | * if g cannot be slid down. | |
764 | */ |
|
763 | */ | |
765 |
static int group_slide_down(xdfile_t *xdf, struct xdlgroup *g |
|
764 | static int group_slide_down(xdfile_t *xdf, struct xdlgroup *g) | |
766 | { |
|
765 | { | |
767 | if (g->end < xdf->nrec && |
|
766 | if (g->end < xdf->nrec && | |
768 |
recs_match(xdf->recs[g->start], xdf->recs[g->end] |
|
767 | recs_match(xdf->recs[g->start], xdf->recs[g->end])) { | |
769 | xdf->rchg[g->start++] = 0; |
|
768 | xdf->rchg[g->start++] = 0; | |
770 | xdf->rchg[g->end++] = 1; |
|
769 | xdf->rchg[g->end++] = 1; | |
771 |
|
770 | |||
@@ -783,10 +782,10 b' static int group_slide_down(xdfile_t *xd' | |||||
783 | * into a previous group, expand this group to include it. Return 0 on success |
|
782 | * into a previous group, expand this group to include it. Return 0 on success | |
784 | * or -1 if g cannot be slid up. |
|
783 | * or -1 if g cannot be slid up. | |
785 | */ |
|
784 | */ | |
786 |
static int group_slide_up(xdfile_t *xdf, struct xdlgroup *g |
|
785 | static int group_slide_up(xdfile_t *xdf, struct xdlgroup *g) | |
787 | { |
|
786 | { | |
788 | if (g->start > 0 && |
|
787 | if (g->start > 0 && | |
789 |
recs_match(xdf->recs[g->start - 1], xdf->recs[g->end - 1] |
|
788 | recs_match(xdf->recs[g->start - 1], xdf->recs[g->end - 1])) { | |
790 | xdf->rchg[--g->start] = 1; |
|
789 | xdf->rchg[--g->start] = 1; | |
791 | xdf->rchg[--g->end] = 0; |
|
790 | xdf->rchg[--g->end] = 0; | |
792 |
|
791 | |||
@@ -847,7 +846,7 b' int xdl_change_compact(xdfile_t *xdf, xd' | |||||
847 | end_matching_other = -1; |
|
846 | end_matching_other = -1; | |
848 |
|
847 | |||
849 | /* Shift the group backward as much as possible: */ |
|
848 | /* Shift the group backward as much as possible: */ | |
850 |
while (!group_slide_up(xdf, &g |
|
849 | while (!group_slide_up(xdf, &g)) | |
851 | if (group_previous(xdfo, &go)) |
|
850 | if (group_previous(xdfo, &go)) | |
852 | xdl_bug("group sync broken sliding up"); |
|
851 | xdl_bug("group sync broken sliding up"); | |
853 |
|
852 | |||
@@ -862,7 +861,7 b' int xdl_change_compact(xdfile_t *xdf, xd' | |||||
862 |
|
861 | |||
863 | /* Now shift the group forward as far as possible: */ |
|
862 | /* Now shift the group forward as far as possible: */ | |
864 | while (1) { |
|
863 | while (1) { | |
865 |
if (group_slide_down(xdf, &g |
|
864 | if (group_slide_down(xdf, &g)) | |
866 | break; |
|
865 | break; | |
867 | if (group_next(xdfo, &go)) |
|
866 | if (group_next(xdfo, &go)) | |
868 | xdl_bug("group sync broken sliding down"); |
|
867 | xdl_bug("group sync broken sliding down"); | |
@@ -889,7 +888,7 b' int xdl_change_compact(xdfile_t *xdf, xd' | |||||
889 | * that it can align with. |
|
888 | * that it can align with. | |
890 | */ |
|
889 | */ | |
891 | while (go.end == go.start) { |
|
890 | while (go.end == go.start) { | |
892 |
if (group_slide_up(xdf, &g |
|
891 | if (group_slide_up(xdf, &g)) | |
893 | xdl_bug("match disappeared"); |
|
892 | xdl_bug("match disappeared"); | |
894 | if (group_previous(xdfo, &go)) |
|
893 | if (group_previous(xdfo, &go)) | |
895 | xdl_bug("group sync broken sliding to match"); |
|
894 | xdl_bug("group sync broken sliding to match"); | |
@@ -950,7 +949,7 b' int xdl_change_compact(xdfile_t *xdf, xd' | |||||
950 | } |
|
949 | } | |
951 |
|
950 | |||
952 | while (g.end > best_shift) { |
|
951 | while (g.end > best_shift) { | |
953 |
if (group_slide_up(xdf, &g |
|
952 | if (group_slide_up(xdf, &g)) | |
954 | xdl_bug("best shift unreached"); |
|
953 | xdl_bug("best shift unreached"); | |
955 | if (group_previous(xdfo, &go)) |
|
954 | if (group_previous(xdfo, &go)) | |
956 | xdl_bug("group sync broken sliding to blank line"); |
|
955 | xdl_bug("group sync broken sliding to blank line"); |
@@ -118,7 +118,7 b' static int xdl_classify_record(unsigned ' | |||||
118 | for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next) |
|
118 | for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next) | |
119 | if (rcrec->ha == rec->ha && |
|
119 | if (rcrec->ha == rec->ha && | |
120 | xdl_recmatch(rcrec->line, rcrec->size, |
|
120 | xdl_recmatch(rcrec->line, rcrec->size, | |
121 |
rec->ptr, rec->size |
|
121 | rec->ptr, rec->size)) | |
122 | break; |
|
122 | break; | |
123 |
|
123 | |||
124 | if (!rcrec) { |
|
124 | if (!rcrec) { | |
@@ -273,7 +273,7 b' static int xdl_prepare_ctx(unsigned int ' | |||||
273 | if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) { |
|
273 | if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) { | |
274 | for (top = blk + bsize; cur < top; ) { |
|
274 | for (top = blk + bsize; cur < top; ) { | |
275 | prev = cur; |
|
275 | prev = cur; | |
276 |
hav = xdl_hash_record(&cur, top |
|
276 | hav = xdl_hash_record(&cur, top); | |
277 | if (nrec >= narec) { |
|
277 | if (nrec >= narec) { | |
278 | narec *= 2; |
|
278 | narec *= 2; | |
279 | if (!(rrecs = (xrecord_t **) xdl_realloc(recs, narec * sizeof(xrecord_t *)))) |
|
279 | if (!(rrecs = (xrecord_t **) xdl_realloc(recs, narec * sizeof(xrecord_t *)))) |
@@ -121,14 +121,14 b' int64_t xdl_guess_lines(mmfile_t *mf, in' | |||||
121 | return nl + 1; |
|
121 | return nl + 1; | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 |
int xdl_recmatch(const char *l1, int64_t s1, const char *l2, int64_t s2 |
|
124 | int xdl_recmatch(const char *l1, int64_t s1, const char *l2, int64_t s2) | |
125 | { |
|
125 | { | |
126 | if (s1 == s2 && !memcmp(l1, l2, s1)) |
|
126 | if (s1 == s2 && !memcmp(l1, l2, s1)) | |
127 | return 1; |
|
127 | return 1; | |
128 | return 0; |
|
128 | return 0; | |
129 | } |
|
129 | } | |
130 |
|
130 | |||
131 |
uint64_t xdl_hash_record(char const **data, char const *top |
|
131 | uint64_t xdl_hash_record(char const **data, char const *top) { | |
132 | uint64_t ha = 5381; |
|
132 | uint64_t ha = 5381; | |
133 | char const *ptr = *data; |
|
133 | char const *ptr = *data; | |
134 |
|
134 |
@@ -30,8 +30,8 b' int xdl_cha_init(chastore_t *cha, int64_' | |||||
30 | void xdl_cha_free(chastore_t *cha); |
|
30 | void xdl_cha_free(chastore_t *cha); | |
31 | void *xdl_cha_alloc(chastore_t *cha); |
|
31 | void *xdl_cha_alloc(chastore_t *cha); | |
32 | int64_t xdl_guess_lines(mmfile_t *mf, int64_t sample); |
|
32 | int64_t xdl_guess_lines(mmfile_t *mf, int64_t sample); | |
33 |
int xdl_recmatch(const char *l1, int64_t s1, const char *l2, int64_t s2 |
|
33 | int xdl_recmatch(const char *l1, int64_t s1, const char *l2, int64_t s2); | |
34 |
uint64_t xdl_hash_record(char const **data, char const *top |
|
34 | uint64_t xdl_hash_record(char const **data, char const *top); | |
35 | unsigned int xdl_hashbits(unsigned int size); |
|
35 | unsigned int xdl_hashbits(unsigned int size); | |
36 |
|
36 | |||
37 |
|
37 |
General Comments 0
You need to be logged in to leave comments.
Login now