rundiff (6115:7c6971582cd4) rundiff (6668:e0f3287fc680)
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
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();
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 }
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
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
294 $postcontext--;
295 print ' ', $l1;
296 $lineno1++;
297 $lineno2++;
298 print ' ', $l1;
299 $lineno1++;
300 $lineno2++;
301 if (--$postcontext == 0) {
302 STDOUT->flush();
303 }
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}
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}