Skip to content

Commit 27a888f

Browse files
committed
diff: allow case of no more src but only + in diff
1 parent 84eb594 commit 27a888f

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

fixdiff.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,11 @@ fixdiff_find_original(dp_t *pdp, int *line_start)
381381

382382
while (!hit) {
383383
ls = fixdiff_get_line(&lb, in_src, sizeof(in_src));
384-
if (!ls) {
385-
elog("failed to match, best chunk %d lines at %s:%d\n", lmc, pdp->pf, lg_lis);
386-
mc = 0;
387-
break;
388-
}
384+
/*
385+
* We may be adding at end with original lines leading-in, in this
386+
* case it is normal we will not be able to fetch any more lines
387+
* from the original file before running out of diff
388+
*/
389389

390390
do {
391391
lt = fixdiff_get_line(&lb_temp, in_temp, sizeof(in_temp));
@@ -399,6 +399,13 @@ fixdiff_find_original(dp_t *pdp, int *line_start)
399399
if (hit)
400400
break;
401401

402+
if (!ls) {
403+
elog("failed to match, best chunk %d lines at %s:%d\n",
404+
lmc, pdp->pf, lg_lis);
405+
mc = 0;
406+
break;
407+
}
408+
402409
if (fixdiff_strcmp(in_temp + 1, lt - 1, &let, in_src, ls, &les)) {
403410
if (mc > pdp->pre + pdp->post)
404411
elog("match failed after %d: '%s' / '%s'", mc, in_temp + 1, in_src);

tools/concat.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ if [ $? -ne 0 ] ; then
2727
exit 0
2828
fi
2929
cat .concat.tmp | xsel
30-
30+
if [ $? -ne 0 ] ; then
31+
echo "xsel not available, dumping to stdout =============================================="
32+
cat .concat.tmp
33+
exit 0
34+
fi
3135
echo "Concatenated file contents in clipboard"
3236

3337
exit 0

0 commit comments

Comments
 (0)