Deleted Added
sdiff udiff text old ( 6115:7c6971582cd4 ) new ( 6668:e0f3287fc680 )
full compact
1#! /usr/bin/env perl
2
3# Copyright (c) 2003 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 152 unchanged lines hidden (view full) ---

161 printlines(\@lines1, $n1, '-');
162 printlines(\@lines2, $n2, '+');
163 $lineno1 += $n1;
164 $lineno2 += $n2;
165
166 # Set $postcontext to print the next $postcontext_lines matching lines.
167 $postcontext = $postcontext_lines;
168
169 STDOUT->flush();
170}
171
172
173########################
174#
175# Complex diff algorithm
176#
177########################

--- 108 unchanged lines hidden (view full) ---

286
287 if ($l1 eq $l2) {
288 # matching lines: delete from lookahead buffer
289 shift @lines1;
290 shift @lines2;
291 # figure out what to do with this line
292 if ($postcontext > 0) {
293 # we're in the post-context of a diff: print it
294 $postcontext--;
295 print ' ', $l1;
296 $lineno1++;
297 $lineno2++;
298 }
299 else {
300 # we're in the middle of a matching region... save this
301 # line for precontext in case we run into a difference.
302 push @precontext, $l1;
303 # don't let precontext buffer get bigger than needed
304 while (@precontext > $precontext_lines) {
305 shift @precontext;
306 $lineno1++;
307 $lineno2++;
308 }
309 }
310 }
311 else {
312 # Mismatch. Deal with it.
313 &$find_diff();
314 }
315}