Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137467721
D34912.id105037.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D34912.id105037.diff
View Options
diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c
--- a/usr.bin/diff3/diff3.c
+++ b/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);
}
diff --git a/usr.bin/diff3/tests/Makefile b/usr.bin/diff3/tests/Makefile
--- a/usr.bin/diff3/tests/Makefile
+++ b/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 <bsd.test.mk>
diff --git a/usr.bin/diff3/tests/diff3_test.sh b/usr.bin/diff3/tests/diff3_test.sh
--- a/usr.bin/diff3/tests/diff3_test.sh
+++ b/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
}
diff --git a/usr.bin/diff3/tests/long-ed.out b/usr.bin/diff3/tests/long-ed.out
new file mode 100644
--- /dev/null
+++ b/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
+.
diff --git a/usr.bin/diff3/tests/long-m.txt b/usr.bin/diff3/tests/long-m.txt
new file mode 100644
--- /dev/null
+++ b/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
diff --git a/usr.bin/diff3/tests/long-o.txt b/usr.bin/diff3/tests/long-o.txt
new file mode 100644
--- /dev/null
+++ b/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
diff --git a/usr.bin/diff3/tests/long-y.txt b/usr.bin/diff3/tests/long-y.txt
new file mode 100644
--- /dev/null
+++ b/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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 24, 6:16 PM (1 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26068820
Default Alt Text
D34912.id105037.diff (7 KB)
Attached To
Mode
D34912: diff3: allow diff3 ed scripts to generate deletions
Attached
Detach File
Event Timeline
Log In to Comment