diff options
Diffstat (limited to 'contrib/cvs/diff/diff3.c')
-rw-r--r-- | contrib/cvs/diff/diff3.c | 70 |
1 files changed, 26 insertions, 44 deletions
diff --git a/contrib/cvs/diff/diff3.c b/contrib/cvs/diff/diff3.c index 4a6fba618c23..ab68eaf25ee9 100644 --- a/contrib/cvs/diff/diff3.c +++ b/contrib/cvs/diff/diff3.c @@ -12,6 +12,9 @@ GNU General Public License for more details. */ +/* + * $FreeBSD$ + */ /* Written by Randy Smith */ /* Librarification by Tim Pierce */ @@ -171,7 +174,7 @@ static int edscript; static int flagging; /* Number of lines to keep in identical prefix and suffix. */ -static int const horizon_lines = 10; +static int horizon_lines = 10; /* Use a tab to align output lines (-T). */ static int tab_align_flag; @@ -370,44 +373,28 @@ 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; - } - } - mapping[0] = 0; - mapping[1] = 3 - common; - mapping[2] = common; - } + 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; + } for (i = 0; i < 3; i++) rev_mapping[mapping[i]] = i; @@ -460,18 +447,12 @@ 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); @@ -1877,6 +1858,7 @@ initialize_main (argcp, argvp) always_text = 0; edscript = 0; flagging = 0; + horizon_lines = 10; tab_align_flag = 0; simple_only = 0; overlap_only = 0; |