diff options
author | 2001-09-28 22:45:35 +0000 | |
---|---|---|
committer | 2001-09-28 22:45:35 +0000 | |
commit | 43c1707e6f6829177cb1974ee6615ce6c1307689 (patch) | |
tree | 233c059b44960ac679320e3e905b66e024ba011f /gnu/usr.bin/cvs/diff/diff3.c | |
parent | Hack to work around bootpaths like: (diff) | |
download | wireguard-openbsd-43c1707e6f6829177cb1974ee6615ce6c1307689.tar.xz wireguard-openbsd-43c1707e6f6829177cb1974ee6615ce6c1307689.zip |
Latest from Cyclic Software
Diffstat (limited to 'gnu/usr.bin/cvs/diff/diff3.c')
-rw-r--r-- | gnu/usr.bin/cvs/diff/diff3.c | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/gnu/usr.bin/cvs/diff/diff3.c b/gnu/usr.bin/cvs/diff/diff3.c index 2f05d165fc9..4a6fba618c2 100644 --- a/gnu/usr.bin/cvs/diff/diff3.c +++ b/gnu/usr.bin/cvs/diff/diff3.c @@ -171,7 +171,7 @@ static int edscript; static int flagging; /* Number of lines to keep in identical prefix and suffix. */ -static int horizon_lines = 10; +static int const horizon_lines = 10; /* Use a tab to align output lines (-T). */ static int tab_align_flag; @@ -370,28 +370,44 @@ diff3_run (argc, argv, out, callbacks_arg) file0-file1 diffs didn't line up with the file0-file2 diffs (which is entirely possible since we don't use diff's -n option), diff3 might report phantom changes from file1 to file2. */ + /* Also try to compare file0 to file1 because this is the where + changes are expected to come from. Diffing between these pairs + of files is is most likely to return the intended changes. There + can also be the same problem with phantom changes from file0 to + file1. */ + /* Historically, the default common file was file2. Ediff for emacs + and possibly other applications, have therefore made file2 the + ancestor. So, for compatibility, if this is simply a three + way diff (not a merge or edscript) then use the old way with + file2 as the common file. */ + + { + int common; + if (edscript || merge ) + { + common = 1; + } + else + { + common = 2; + } + if (strcmp (file[common], "-") == 0) + { + /* Sigh. We've got standard input as the arg corresponding to + the desired common file. We can't call diff twice on + stdin. Use another arg as the common file instead. */ + common = 3 - common; + if (strcmp (file[0], "-") == 0 || strcmp (file[common], "-") == 0) + { + diff_error ("%s", "`-' specified for more than one input file", 0); + return 2; + } + } - if (strcmp (file[2], "-") == 0) - { - /* Sigh. We've got standard input as the last arg. We can't - call diff twice on stdin. Use the middle arg as the common - file instead. */ - if (strcmp (file[0], "-") == 0 || strcmp (file[1], "-") == 0) - { - diff_error ("%s", "`-' specified for more than one input file", 0); - return 2; - } - mapping[0] = 0; - mapping[1] = 2; - mapping[2] = 1; - } - else - { - /* Normal, what you'd expect */ - mapping[0] = 0; - mapping[1] = 1; - mapping[2] = 2; - } + mapping[0] = 0; + mapping[1] = 3 - common; + mapping[2] = common; + } for (i = 0; i < 3; i++) rev_mapping[mapping[i]] = i; @@ -444,12 +460,18 @@ diff3_run (argc, argv, out, callbacks_arg) commonname = file[rev_mapping[FILEC]]; thread1 = process_diff (file[rev_mapping[FILE1]], commonname, &last_block, &content1); + /* What is the intention behind determining horizon_lines from first + diff? I think it is better to use the same parameters for each + diff so that equal differences in each diff will appear the + same. */ + /* if (thread1) for (i = 0; i < 2; i++) { horizon_lines = max (horizon_lines, D_NUMLINES (thread1, i)); horizon_lines = max (horizon_lines, D_NUMLINES (last_block, i)); } + */ thread0 = process_diff (file[rev_mapping[FILE0]], commonname, &last_block, &content0); diff3 = make_3way_diff (thread0, thread1); @@ -1855,7 +1877,6 @@ initialize_main (argcp, argvp) always_text = 0; edscript = 0; flagging = 0; - horizon_lines = 10; tab_align_flag = 0; simple_only = 0; overlap_only = 0; |