Skip to content

Commit b7de64a

Browse files
ezekielnewrengitster
authored andcommitted
xdiff: rename rchg -> changed in xdfile_t
The field rchg (now 'changed') declares if a line in a file is changed or not. A later commit will change it's type from 'char' to 'bool' to make its purpose even more clear. Best-viewed-with: --color-words Signed-off-by: Ezekiel Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d43d591 commit b7de64a

File tree

6 files changed

+32
-32
lines changed

6 files changed

+32
-32
lines changed

xdiff/xdiffi.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,10 @@ int xdl_recs_cmp(xdfile_t *xdf1, long off1, long lim1,
278278
*/
279279
if (off1 == lim1) {
280280
for (; off2 < lim2; off2++)
281-
xdf2->rchg[xdf2->rindex[off2]] = 1;
281+
xdf2->changed[xdf2->rindex[off2]] = 1;
282282
} else if (off2 == lim2) {
283283
for (; off1 < lim1; off1++)
284-
xdf1->rchg[xdf1->rindex[off1]] = 1;
284+
xdf1->changed[xdf1->rindex[off1]] = 1;
285285
} else {
286286
xdpsplit_t spl;
287287
spl.i1 = spl.i2 = 0;
@@ -708,7 +708,7 @@ struct xdlgroup {
708708
static void group_init(xdfile_t *xdf, struct xdlgroup *g)
709709
{
710710
g->start = g->end = 0;
711-
while (xdf->rchg[g->end])
711+
while (xdf->changed[g->end])
712712
g->end++;
713713
}
714714

@@ -722,7 +722,7 @@ static inline int group_next(xdfile_t *xdf, struct xdlgroup *g)
722722
return -1;
723723

724724
g->start = g->end + 1;
725-
for (g->end = g->start; xdf->rchg[g->end]; g->end++)
725+
for (g->end = g->start; xdf->changed[g->end]; g->end++)
726726
;
727727

728728
return 0;
@@ -738,7 +738,7 @@ static inline int group_previous(xdfile_t *xdf, struct xdlgroup *g)
738738
return -1;
739739

740740
g->end = g->start - 1;
741-
for (g->start = g->end; xdf->rchg[g->start - 1]; g->start--)
741+
for (g->start = g->end; xdf->changed[g->start - 1]; g->start--)
742742
;
743743

744744
return 0;
@@ -753,10 +753,10 @@ static int group_slide_down(xdfile_t *xdf, struct xdlgroup *g)
753753
{
754754
if (g->end < xdf->nrec &&
755755
recs_match(&xdf->recs[g->start], &xdf->recs[g->end])) {
756-
xdf->rchg[g->start++] = 0;
757-
xdf->rchg[g->end++] = 1;
756+
xdf->changed[g->start++] = 0;
757+
xdf->changed[g->end++] = 1;
758758

759-
while (xdf->rchg[g->end])
759+
while (xdf->changed[g->end])
760760
g->end++;
761761

762762
return 0;
@@ -774,10 +774,10 @@ static int group_slide_up(xdfile_t *xdf, struct xdlgroup *g)
774774
{
775775
if (g->start > 0 &&
776776
recs_match(&xdf->recs[g->start - 1], &xdf->recs[g->end - 1])) {
777-
xdf->rchg[--g->start] = 1;
778-
xdf->rchg[--g->end] = 0;
777+
xdf->changed[--g->start] = 1;
778+
xdf->changed[--g->end] = 0;
779779

780-
while (xdf->rchg[g->start - 1])
780+
while (xdf->changed[g->start - 1])
781781
g->start--;
782782

783783
return 0;
@@ -932,16 +932,16 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
932932

933933
int xdl_build_script(xdfenv_t *xe, xdchange_t **xscr) {
934934
xdchange_t *cscr = NULL, *xch;
935-
char *rchg1 = xe->xdf1.rchg, *rchg2 = xe->xdf2.rchg;
935+
char *changed1 = xe->xdf1.changed, *changed2 = xe->xdf2.changed;
936936
long i1, i2, l1, l2;
937937

938938
/*
939939
* Trivial. Collects "groups" of changes and creates an edit script.
940940
*/
941941
for (i1 = xe->xdf1.nrec, i2 = xe->xdf2.nrec; i1 >= 0 || i2 >= 0; i1--, i2--)
942-
if (rchg1[i1 - 1] || rchg2[i2 - 1]) {
943-
for (l1 = i1; rchg1[i1 - 1]; i1--);
944-
for (l2 = i2; rchg2[i2 - 1]; i2--);
942+
if (changed1[i1 - 1] || changed2[i2 - 1]) {
943+
for (l1 = i1; changed1[i1 - 1]; i1--);
944+
for (l2 = i2; changed2[i2 - 1]; i2--);
945945

946946
if (!(xch = xdl_add_change(cscr, i1, i2, l1 - i1, l2 - i2))) {
947947
xdl_free_script(cscr);

xdiff/xhistogram.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,11 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
318318

319319
if (!count1) {
320320
while(count2--)
321-
env->xdf2.rchg[line2++ - 1] = 1;
321+
env->xdf2.changed[line2++ - 1] = 1;
322322
return 0;
323323
} else if (!count2) {
324324
while(count1--)
325-
env->xdf1.rchg[line1++ - 1] = 1;
325+
env->xdf1.changed[line1++ - 1] = 1;
326326
return 0;
327327
}
328328

@@ -335,9 +335,9 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
335335
else {
336336
if (lcs.begin1 == 0 && lcs.begin2 == 0) {
337337
while (count1--)
338-
env->xdf1.rchg[line1++ - 1] = 1;
338+
env->xdf1.changed[line1++ - 1] = 1;
339339
while (count2--)
340-
env->xdf2.rchg[line2++ - 1] = 1;
340+
env->xdf2.changed[line2++ - 1] = 1;
341341
result = 0;
342342
} else {
343343
result = histogram_diff(xpp, env,

xdiff/xpatience.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@ static int patience_diff(xpparam_t const *xpp, xdfenv_t *env,
331331
/* trivial case: one side is empty */
332332
if (!count1) {
333333
while(count2--)
334-
env->xdf2.rchg[line2++ - 1] = 1;
334+
env->xdf2.changed[line2++ - 1] = 1;
335335
return 0;
336336
} else if (!count2) {
337337
while(count1--)
338-
env->xdf1.rchg[line1++ - 1] = 1;
338+
env->xdf1.changed[line1++ - 1] = 1;
339339
return 0;
340340
}
341341

@@ -347,9 +347,9 @@ static int patience_diff(xpparam_t const *xpp, xdfenv_t *env,
347347
/* are there any matching lines at all? */
348348
if (!map.has_matches) {
349349
while(count1--)
350-
env->xdf1.rchg[line1++ - 1] = 1;
350+
env->xdf1.changed[line1++ - 1] = 1;
351351
while(count2--)
352-
env->xdf2.rchg[line2++ - 1] = 1;
352+
env->xdf2.changed[line2++ - 1] = 1;
353353
xdl_free(map.entries);
354354
return 0;
355355
}

xdiff/xprepare.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
126126
static void xdl_free_ctx(xdfile_t *xdf)
127127
{
128128
xdl_free(xdf->rindex);
129-
xdl_free(xdf->rchg - 1);
129+
xdl_free(xdf->changed - 1);
130130
xdl_free(xdf->recs);
131131
}
132132

@@ -139,7 +139,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
139139
xrecord_t *crec;
140140

141141
xdf->rindex = NULL;
142-
xdf->rchg = NULL;
142+
xdf->changed = NULL;
143143
xdf->recs = NULL;
144144

145145
if (!XDL_ALLOC_ARRAY(xdf->recs, narec))
@@ -161,7 +161,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
161161
}
162162
}
163163

164-
if (!XDL_CALLOC_ARRAY(xdf->rchg, xdf->nrec + 2))
164+
if (!XDL_CALLOC_ARRAY(xdf->changed, xdf->nrec + 2))
165165
goto abort;
166166

167167
if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
@@ -170,7 +170,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
170170
goto abort;
171171
}
172172

173-
xdf->rchg += 1;
173+
xdf->changed += 1;
174174
xdf->nreff = 0;
175175
xdf->dstart = 0;
176176
xdf->dend = xdf->nrec - 1;
@@ -287,7 +287,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
287287
(dis1[i] == 2 && !xdl_clean_mmatch(dis1, i, xdf1->dstart, xdf1->dend))) {
288288
xdf1->rindex[nreff++] = i;
289289
} else
290-
xdf1->rchg[i] = 1;
290+
xdf1->changed[i] = 1;
291291
}
292292
xdf1->nreff = nreff;
293293

@@ -297,7 +297,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
297297
(dis2[i] == 2 && !xdl_clean_mmatch(dis2, i, xdf2->dstart, xdf2->dend))) {
298298
xdf2->rindex[nreff++] = i;
299299
} else
300-
xdf2->rchg[i] = 1;
300+
xdf2->changed[i] = 1;
301301
}
302302
xdf2->nreff = nreff;
303303

xdiff/xtypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef struct s_xdfile {
4848
xrecord_t *recs;
4949
long nrec;
5050
long dstart, dend;
51-
char *rchg;
51+
char *changed;
5252
long *rindex;
5353
long nreff;
5454
} xdfile_t;

xdiff/xutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ int xdl_fall_back_diff(xdfenv_t *diff_env, xpparam_t const *xpp,
425425
if (xdl_do_diff(&subfile1, &subfile2, xpp, &env) < 0)
426426
return -1;
427427

428-
memcpy(diff_env->xdf1.rchg + line1 - 1, env.xdf1.rchg, count1);
429-
memcpy(diff_env->xdf2.rchg + line2 - 1, env.xdf2.rchg, count2);
428+
memcpy(diff_env->xdf1.changed + line1 - 1, env.xdf1.changed, count1);
429+
memcpy(diff_env->xdf2.changed + line2 - 1, env.xdf2.changed, count2);
430430

431431
xdl_free_env(&env);
432432

0 commit comments

Comments
 (0)