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 # Normally we flush after the postcontext lines are printed, but if
170 # the user has decreed that there aren't any we need to flush now
171 if ($postcontext == 0) {
172 STDOUT->flush();
173 }
174}
175
176
177########################
178#
179# Complex diff algorithm
180#
181########################

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

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