Index: usr.bin/diff3/diff3.c =================================================================== --- usr.bin/diff3/diff3.c +++ usr.bin/diff3/diff3.c @@ -139,7 +139,7 @@ static void change(int, struct range *, bool); static void keep(int, struct range *); static void merge(int, int); -static void prange(struct range *); +static void prange(struct range *, bool); static void repos(int); static void edscript(int) __dead2; static void increase(void); @@ -382,7 +382,7 @@ printf("%d:", i); last[i] = rold->to; - prange(rold); + prange(rold, false); if (dup) return; i--; @@ -395,7 +395,7 @@ * n1. */ static void -prange(struct range *rold) +prange(struct range *rold, bool delete) { if (rold->to <= rold->from) @@ -404,7 +404,10 @@ printf("%d", rold->from); if (rold->to > rold->from + 1) printf(",%d", rold->to - 1); - printf("c\n"); + if (delete) + printf("d\n"); + else + printf("c\n"); } } @@ -514,12 +517,14 @@ edscript(int n) { int k; + bool delete; size_t j; char block[BUFSIZ]; for (; n > 0; n--) { + delete = (de[n].new.from == de[n].new.to); if (!oflag || !overlap[n]) { - prange(&de[n].old); + prange(&de[n].old, delete); } else { printf("%da\n", de[n].old.to - 1); if (Aflag) { @@ -550,9 +555,10 @@ j = r; (void)fwrite(block, 1, j, stdout); } - if (!oflag || !overlap[n]) - printf(".\n"); - else { + if (!oflag || !overlap[n]) { + if (!delete) + printf(".\n"); + } else { printf("%s\n.\n", f3mark); printf("%da\n%s\n.\n", de[n].old.from - 1, f1mark); } Index: usr.bin/diff3/tests/Makefile =================================================================== --- usr.bin/diff3/tests/Makefile +++ usr.bin/diff3/tests/Makefile @@ -3,12 +3,14 @@ PACKAGE= tests ATF_TESTS_SH= diff3_test - ${PACKAGE}FILES+= \ 1.txt \ 1cr.txt \ 2.txt \ 3.txt \ + long-m.txt \ + long-o.txt \ + long-y.txt \ 1.out \ 1t.out \ 2.out \ @@ -18,6 +20,7 @@ 6.out \ 7.out \ 8.out \ - 9.out + 9.out \ + long-ed.out .include Index: usr.bin/diff3/tests/diff3_test.sh =================================================================== --- usr.bin/diff3/tests/diff3_test.sh +++ usr.bin/diff3/tests/diff3_test.sh @@ -2,6 +2,7 @@ atf_test_case diff3 atf_test_case diff3_lesssimple +atf_test_case diff3_ed diff3_body() { @@ -31,12 +32,6 @@ atf_check -o file:$(atf_get_srcdir)/7.out \ diff3 -i $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt - -# atf_check -o file:$(atf_get_srcdir)/8.out \ -# diff3 -A -L 1 -L 2 -L 3 $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt - -# atf_check -s exit:1 -o file:$(atf_get_srcdir)/9.out \ -# diff3 -m -L 1 -L 2 -L 3 $(atf_get_srcdir)/1.txt $(atf_get_srcdir)/2.txt $(atf_get_srcdir)/3.txt } diff3_lesssimple_body() @@ -45,8 +40,15 @@ diff3 -m -L 1 -L 2 -L 3 $(atf_get_srcdir)/4.txt $(atf_get_srcdir)/5.txt $(atf_get_srcdir)/6.txt } +diff3_ed_body() +{ + atf_check -s exit:0 -o file:$(atf_get_srcdir)/long-ed.out \ + diff3 -e $(atf_get_srcdir)/long-m.txt $(atf_get_srcdir)/long-o.txt $(atf_get_srcdir)/long-y.txt +} + atf_init_test_cases() { atf_add_test_case diff3 # atf_add_test_case diff3_lesssimple + atf_add_test_case diff3_ed } Index: usr.bin/diff3/tests/long-ed.out =================================================================== --- /dev/null +++ usr.bin/diff3/tests/long-ed.out @@ -0,0 +1,7 @@ +24d +16c +This line is different in yours and mine, but the best in yours +. +8c +This line is different in yours, much butter +. Index: usr.bin/diff3/tests/long-m.txt =================================================================== --- /dev/null +++ usr.bin/diff3/tests/long-m.txt @@ -0,0 +1,26 @@ +This is a long file +These lines are the same in all three files +These lines are the same in all three files +This line is different in mine, not better +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +This line is different in yours +These lines are the same in all three files +These lines are the same in all three files +This line is different in yours and mine, the same is in both +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +This line is different in yours and mine, best change in mine +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +This line is deleted in yours +These lines are the same in all three files +These lines are the same in all three files Index: usr.bin/diff3/tests/long-o.txt =================================================================== --- /dev/null +++ usr.bin/diff3/tests/long-o.txt @@ -0,0 +1,27 @@ +This is a long file +These lines are the same in all three files +These lines are the same in all three files +This line is different in mine +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +This line is different in yours +These lines are the same in all three files +These lines are the same in all three files +This line is different in yours and mine, but the same +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +This line is different in yours and mine, but the different in each +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +This line is deleted in mine +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +This line is deleted in yours +These lines are the same in all three files +These lines are the same in all three files Index: usr.bin/diff3/tests/long-y.txt =================================================================== --- /dev/null +++ usr.bin/diff3/tests/long-y.txt @@ -0,0 +1,26 @@ +This is a long file +These lines are the same in all three files +These lines are the same in all three files +This line is different in mine +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +This line is different in yours, much butter +These lines are the same in all three files +These lines are the same in all three files +This line is different in yours and mine, the same is in both +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +This line is different in yours and mine, but the best in yours +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +This line is deleted in mine +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files +These lines are the same in all three files