Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F154078224
D37676.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D37676.diff
View Options
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1247,7 +1247,8 @@
printf(" ");
}
col = 0;
- for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
+ for (j = 0, lastc = '\0'; j < nc && (hw == 0 || col < hw);
+ j++, lastc = c) {
c = getc(lb);
if (flags & D_STRIPCR && c == '\r') {
if ((c = getc(lb)) == '\n')
@@ -1274,19 +1275,16 @@
if (flags & D_EXPANDTABS) {
newcol = ((col / tabsize) + 1) * tabsize;
do {
- if (diff_format == D_SIDEBYSIDE)
- j++;
printf(" ");
- } while (++col < newcol && j < nc);
+ } while (++col < newcol && col < hw);
} else {
if (diff_format == D_SIDEBYSIDE) {
- if ((j + tabsize) > nc) {
- printf("%*s", nc - j, "");
- j = col = nc;
+ if ((col + tabsize) > hw) {
+ printf("%*s", hw - col, "");
+ col = hw;
} else {
printf("\t");
col += tabsize - 1;
- j += tabsize - 1;
}
} else {
printf("\t");
diff --git a/usr.bin/diff/tests/Makefile b/usr.bin/diff/tests/Makefile
--- a/usr.bin/diff/tests/Makefile
+++ b/usr.bin/diff/tests/Makefile
@@ -12,6 +12,8 @@
input2.in \
input_c1.in \
input_c2.in \
+ side_by_side_tabbed_a.in \
+ side_by_side_tabbed_b.in \
simple.out \
simple_e.out \
simple_n.out \
diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh
--- a/usr.bin/diff/tests/diff_test.sh
+++ b/usr.bin/diff/tests/diff_test.sh
@@ -7,6 +7,7 @@
atf_test_case ifdef
atf_test_case group_format
atf_test_case side_by_side
+atf_test_case side_by_side_tabbed
atf_test_case brief_format
atf_test_case b230049
atf_test_case stripcr_o
@@ -145,6 +146,23 @@
diff -W 65 -y --suppress-common-lines A B
}
+side_by_side_tabbed_body()
+{
+ file_a=$(atf_get_srcdir)/side_by_side_tabbed_a.in
+ file_b=$(atf_get_srcdir)/side_by_side_tabbed_b.in
+
+ atf_check -o save:diffout -s not-exit:0 \
+ diff -y ${file_a} ${file_b}
+ atf_check -o save:diffout_expanded -s not-exit:0 \
+ diff -yt ${file_a} ${file_b}
+
+ atf_check -o not-empty grep -Ee 'file A.+file B' diffout
+ atf_check -o not-empty grep -Ee 'file A.+file B' diffout_expanded
+
+ atf_check -o not-empty grep -Ee 'tabs.+tabs' diffout
+ atf_check -o not-empty grep -Ee 'tabs.+tabs' diffout_expanded
+}
+
brief_format_body()
{
atf_check mkdir A B
@@ -343,6 +361,7 @@
atf_add_test_case ifdef
atf_add_test_case group_format
atf_add_test_case side_by_side
+ atf_add_test_case side_by_side_tabbed
atf_add_test_case brief_format
atf_add_test_case b230049
atf_add_test_case stripcr_o
diff --git a/usr.bin/diff/tests/side_by_side_tabbed_a.in b/usr.bin/diff/tests/side_by_side_tabbed_a.in
new file mode 100644
--- /dev/null
+++ b/usr.bin/diff/tests/side_by_side_tabbed_a.in
@@ -0,0 +1,4 @@
+This
+ is my test file A
+ it has tabs
+Thanks
diff --git a/usr.bin/diff/tests/side_by_side_tabbed_b.in b/usr.bin/diff/tests/side_by_side_tabbed_b.in
new file mode 100644
--- /dev/null
+++ b/usr.bin/diff/tests/side_by_side_tabbed_b.in
@@ -0,0 +1,4 @@
+This
+ is my test file B
+ it has tabs
+Thanks
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 27, 12:23 AM (14 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32202148
Default Alt Text
D37676.diff (3 KB)
Attached To
Mode
D37676: diff: fix side-by-side output with tabbed input
Attached
Detach File
Event Timeline
Log In to Comment