aboutsummaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-08-06 12:40:17 +0100
committerRon Yorston <rmy@pobox.com>2023-08-06 12:40:17 +0100
commit0342f258f74bde329cc98733a3b22196ca1b1bdb (patch)
tree73a58db17072aef8d3ef26b32d50e45c58dd5167 /testsuite
parent16a2532c519bac11d456f7c71f06d64385f66ed3 (diff)
downloadbusybox-w32-0342f258f74bde329cc98733a3b22196ca1b1bdb.tar.gz
busybox-w32-0342f258f74bde329cc98733a3b22196ca1b1bdb.tar.bz2
busybox-w32-0342f258f74bde329cc98733a3b22196ca1b1bdb.zip
diff: more changes to --binary
The changes introduced to support the --binary option gave incorrect results when comparing files with CRLF line endings *without* the --binary option present. The code needs to keep track of the position within the file and is confused by text mode. As an alternative solution, always use binary mode but skip the CR of a CRLF pair when the --binary option isn't used. This gives results matching GNU diff when comparing files with matching line endings, with or without --binary. When line endings differ the results aren't always the same. Costs 32 bytes in the 32-bit build, saves 16 in 64-bit. (GitHub issue #348)
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/diff.tests63
1 files changed, 63 insertions, 0 deletions
diff --git a/testsuite/diff.tests b/testsuite/diff.tests
index 0ced0f248..ee0567a80 100755
--- a/testsuite/diff.tests
+++ b/testsuite/diff.tests
@@ -123,6 +123,69 @@ testing "diff always takes context from old file" \
123 "abc\na c\ndef\n" \ 123 "abc\na c\ndef\n" \
124 "a c\n" 124 "a c\n"
125 125
126optional PLATFORM_MINGW32 LONG_OPTS
127testing "diff LF line endings" \
128 'diff -u - input' \
129"\
130--- -
131+++ input
132@@ -1,4 +1,4 @@
133 a
134 b
135+c
136 d
137-e
138" \
139 "a\nb\nc\nd\n" \
140 "a\nb\nd\ne\n"
141
142testing "diff --binary LF line endings" \
143 'diff --binary -u - input' \
144"\
145--- -
146+++ input
147@@ -1,4 +1,4 @@
148 a
149 b
150+c
151 d
152-e
153" \
154 "a\nb\nc\nd\n" \
155 "a\nb\nd\ne\n"
156
157testing "diff CRLF line endings" \
158 'diff -u - input' \
159"\
160--- -
161+++ input
162@@ -1,4 +1,4 @@
163 a
164 b
165+c
166 d
167-e
168" \
169 "a\r\nb\r\nc\r\nd\r\n" \
170 "a\r\nb\r\nd\r\ne\r\n"
171
172testing "diff --binary CRLF line endings" \
173 'diff --binary -u - input' \
174"\
175--- -
176+++ input
177@@ -1,4 +1,4 @@
178 a
179 b
180+c
181 d
182-e
183" \
184 "a\r\nb\r\nc\r\nd\r\n" \
185 "a\r\nb\r\nd\r\ne\r\n"
186
187SKIP=
188
126# testing "test name" "commands" "expected result" "file input" "stdin" 189# testing "test name" "commands" "expected result" "file input" "stdin"
127 190
128# clean up 191# clean up