commit - b6adedb6f92219b3795f616b46f18e752c5644be
commit + 0c9a7e9d9f2c0efc643a722ca46b8144fadf531f
blob - ff6ba3cd5842b83bb5c0d79e6b539956588d6cab
blob + 1bf72dd40864c6752c57ff4ca4ff782b973d8768
--- diff/diff.c
+++ diff/diff.c
usage(void)
{
fprintf(stderr,
- "usage: %s [-pw] [-C n] file1 file2\n"
+ "usage: %s [-pwe] [-U n] file1 file2\n"
"\n"
" -p Use Patience Diff (slower but often nicer)\n"
" -w Ignore Whitespace\n"
- " -C n Number of Context Lines\n"
+ " -U n Number of Context Lines\n"
+ " -e Produce ed script output\n"
, getprogname());
exit(1);
}
bool do_patience = false, ignore_whitespace = false;
int context_lines = 3;
- while ((ch = getopt(argc, argv, "pwC:")) != -1) {
+ while ((ch = getopt(argc, argv, "pwU:e")) != -1) {
switch (ch) {
case 'p':
do_patience = true;
case 'w':
ignore_whitespace = true;
break;
- case 'C':
+ case 'U':
context_lines = atoi(optarg);
break;
default:
blob - e3f7d395587ff642f388ff35f4d434f538f543aa
blob + 9cd69d81128309347f230ac1951e7c0fdeb4683d
--- test/verify_all.sh
+++ test/verify_all.sh
expected_diff="$4"
diff_opts="$5"
+ if echo -- $diff_opts | grep -q -- '-w'; then
+ ignore_whitespace="true"
+ else
+ ignore_whitespace=""
+ fi
verify_left="verify.$orig_left"
verify_right="verify.$orig_right"
return 1
fi
fi
- if [ -z "$diff_opts" -a "x$diff_type" = "xunidiff" ]; then
+ if [ -z "$ignore_whitespace" -a "x$diff_type" = "xunidiff" ]; then
cp "$orig_left" "$verify_right"
patch --quiet -u "$verify_right" "$the_diff"
if ! cmp "$orig_right" "$verify_right" ; then
echo "FAIL: $orig_left != $verify_left"
return 1
fi
- elif [ -z "$diff_opts" ]; then
+ elif [ -z "$ignore_whitespace" ]; then
tail -n +3 "$the_diff" | grep -v "^+" | sed 's/^.//' > "$verify_left"
tail -n +3 "$the_diff" | grep -v "^-" | sed 's/^.//' > "$verify_right"
for left in test*.left* ; do
right="$(echo "$left" | sed 's/\.left/\.right/')"
- diff_opts="$(echo "$left" | sed 's/test[0-9]*\.left\([-a-zA-Z]*\).txt/\1/')"
+ diff_opts="$(echo "$left" | sed 's/test[0-9]*\.left\([-a-zA-Z0-9]*\).txt/\1/')"
expected_diff="$(echo "$left" | sed 's/test\([-0-9a-zA-Z]*\)\..*/expect\1.diff/')"
got_diff="verify.$expected_diff"
blob - /dev/null
blob + e622c0db8bdfc3b14ba0744767d678c901ed6c3d (mode 644)
--- /dev/null
+++ test/test017.left-U0.txt
+a
+x
+x
+x
+x
+x
+x
+x
+x
+x
+x
+f
+g
+h
+j
blob - /dev/null
blob + 9495dcd762b8d50a725d011f44c48471a29146d4 (mode 644)
--- /dev/null
+++ test/test017.right-U0.txt
+a
+b
+c
+d
+x
+x
+x
+x
+x
+k
+x
+x
+x
+x
+x
+c
+v
+b
+n