3 * A PHP diff engine for phpwiki. (Taken from phpwiki-1.3.3)
5 * Copyright © 2000, 2001 Geoffrey T. Dairiki <dairiki@dairiki.org>
6 * You may copy this code freely under the conditions of the GPL.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
24 * @ingroup DifferenceEngine
25 * @defgroup DifferenceEngine DifferenceEngine
31 * @ingroup DifferenceEngine
33 abstract class DiffOp
{
38 public abstract function reverse();
44 return $this->orig ?
count( $this->orig
) : 0;
51 return $this->closing ?
count( $this->closing
) : 0;
58 * @ingroup DifferenceEngine
60 class DiffOp_Copy
extends DiffOp
{
61 public $type = 'copy';
63 function __construct( $orig, $closing = false ) {
64 if ( !is_array( $closing ) ) {
68 $this->closing
= $closing;
75 return new DiffOp_Copy( $this->closing
, $this->orig
);
82 * @ingroup DifferenceEngine
84 class DiffOp_Delete
extends DiffOp
{
85 public $type = 'delete';
87 function __construct( $lines ) {
89 $this->closing
= false;
96 return new DiffOp_Add( $this->orig
);
103 * @ingroup DifferenceEngine
105 class DiffOp_Add
extends DiffOp
{
106 public $type = 'add';
108 function __construct( $lines ) {
109 $this->closing
= $lines;
114 * @return DiffOp_Delete
117 return new DiffOp_Delete( $this->closing
);
124 * @ingroup DifferenceEngine
126 class DiffOp_Change
extends DiffOp
{
127 public $type = 'change';
129 function __construct( $orig, $closing ) {
131 $this->closing
= $closing;
135 * @return DiffOp_Change
138 return new DiffOp_Change( $this->closing
, $this->orig
);
143 * Class used internally by Diff to actually compute the diffs.
145 * The algorithm used here is mostly lifted from the perl module
146 * Algorithm::Diff (version 1.06) by Ned Konz, which is available at:
147 * http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip
149 * More ideas are taken from:
150 * http://www.ics.uci.edu/~eppstein/161/960229.html
152 * Some ideas are (and a bit of code) are from from analyze.c, from GNU
153 * diffutils-2.7, which can be found at:
154 * ftp://gnudist.gnu.org/pub/gnu/diffutils/diffutils-2.7.tar.gz
156 * closingly, some ideas (subdivision by NCHUNKS > 2, and some optimizations)
159 * Line length limits for robustness added by Tim Starling, 2005-08-31
160 * Alternative implementation added by Guy Van den Broeck, 2008-07-30
162 * @author Geoffrey T. Dairiki, Tim Starling, Guy Van den Broeck
164 * @ingroup DifferenceEngine
167 const MAX_XREF_LENGTH
= 10000;
169 protected $xchanged, $ychanged;
171 protected $xv = array(), $yv = array();
172 protected $xind = array(), $yind = array();
174 protected $seq = array(), $in_seq = array();
183 function diff( $from_lines, $to_lines ) {
184 wfProfileIn( __METHOD__
);
186 // Diff and store locally
187 $this->diffLocal( $from_lines, $to_lines );
189 // Merge edits when possible
190 $this->shiftBoundaries( $from_lines, $this->xchanged
, $this->ychanged
);
191 $this->shiftBoundaries( $to_lines, $this->ychanged
, $this->xchanged
);
193 // Compute the edit operations.
194 $n_from = count( $from_lines );
195 $n_to = count( $to_lines );
199 while ( $xi < $n_from ||
$yi < $n_to ) {
200 assert( '$yi < $n_to || $this->xchanged[$xi]' );
201 assert( '$xi < $n_from || $this->ychanged[$yi]' );
203 // Skip matching "snake".
205 while ( $xi < $n_from && $yi < $n_to
206 && !$this->xchanged
[$xi] && !$this->ychanged
[$yi]
208 $copy[] = $from_lines[$xi++
];
212 $edits[] = new DiffOp_Copy( $copy );
215 // Find deletes & adds.
217 while ( $xi < $n_from && $this->xchanged
[$xi] ) {
218 $delete[] = $from_lines[$xi++
];
222 while ( $yi < $n_to && $this->ychanged
[$yi] ) {
223 $add[] = $to_lines[$yi++
];
226 if ( $delete && $add ) {
227 $edits[] = new DiffOp_Change( $delete, $add );
228 } elseif ( $delete ) {
229 $edits[] = new DiffOp_Delete( $delete );
231 $edits[] = new DiffOp_Add( $add );
234 wfProfileOut( __METHOD__
);
243 private function diffLocal( $from_lines, $to_lines ) {
244 global $wgExternalDiffEngine;
245 wfProfileIn( __METHOD__
);
247 if ( $wgExternalDiffEngine == 'wikidiff3' ) {
249 $wikidiff3 = new WikiDiff3();
250 $wikidiff3->diff( $from_lines, $to_lines );
251 $this->xchanged
= $wikidiff3->removed
;
252 $this->ychanged
= $wikidiff3->added
;
256 $n_from = count( $from_lines );
257 $n_to = count( $to_lines );
258 $this->xchanged
= $this->ychanged
= array();
259 $this->xv
= $this->yv
= array();
260 $this->xind
= $this->yind
= array();
262 unset( $this->in_seq
);
265 // Skip leading common lines.
266 for ( $skip = 0; $skip < $n_from && $skip < $n_to; $skip++
) {
267 if ( $from_lines[$skip] !== $to_lines[$skip] ) {
270 $this->xchanged
[$skip] = $this->ychanged
[$skip] = false;
272 // Skip trailing common lines.
275 for ( $endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++
) {
276 if ( $from_lines[$xi] !== $to_lines[$yi] ) {
279 $this->xchanged
[$xi] = $this->ychanged
[$yi] = false;
282 // Ignore lines which do not exist in both files.
283 for ( $xi = $skip; $xi < $n_from - $endskip; $xi++
) {
284 $xhash[$this->lineHash( $from_lines[$xi] )] = 1;
287 for ( $yi = $skip; $yi < $n_to - $endskip; $yi++
) {
288 $line = $to_lines[$yi];
289 if ( ( $this->ychanged
[$yi] = empty( $xhash[$this->lineHash( $line )] ) ) ) {
292 $yhash[$this->lineHash( $line )] = 1;
296 for ( $xi = $skip; $xi < $n_from - $endskip; $xi++
) {
297 $line = $from_lines[$xi];
298 if ( ( $this->xchanged
[$xi] = empty( $yhash[$this->lineHash( $line )] ) ) ) {
306 $this->compareSeq( 0, count( $this->xv
), 0, count( $this->yv
) );
308 wfProfileOut( __METHOD__
);
312 * Returns the whole line if it's small enough, or the MD5 hash otherwise
313 * @param $line string
316 private function lineHash( $line ) {
317 if ( strlen( $line ) > self
::MAX_XREF_LENGTH
) {
325 * Divide the Largest Common Subsequence (LCS) of the sequences
326 * [XOFF, XLIM) and [YOFF, YLIM) into NCHUNKS approximately equally
329 * Returns (LCS, PTS). LCS is the length of the LCS. PTS is an
330 * array of NCHUNKS+1 (X, Y) indexes giving the diving points between
331 * sub sequences. The first sub-sequence is contained in [X0, X1),
332 * [Y0, Y1), the second in [X1, X2), [Y1, Y2) and so on. Note
333 * that (X0, Y0) == (XOFF, YOFF) and
334 * (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM).
336 * This function assumes that the first lines of the specified portions
337 * of the two files do not match, and likewise that the last lines do not
338 * match. The caller must trim matching lines from the beginning and end
339 * of the portions it is going to specify.
347 private function diag( $xoff, $xlim, $yoff, $ylim, $nchunks ) {
350 if ( $xlim - $xoff > $ylim - $yoff ) {
351 // Things seems faster (I'm not sure I understand why)
352 // when the shortest sequence in X.
354 list( $xoff, $xlim, $yoff, $ylim ) = array( $yoff, $ylim, $xoff, $xlim );
358 for ( $i = $ylim - 1; $i >= $yoff; $i-- ) {
359 $ymatches[$this->xv
[$i]][] = $i;
362 for ( $i = $ylim - 1; $i >= $yoff; $i-- ) {
363 $ymatches[$this->yv
[$i]][] = $i;
368 $this->seq
[0] = $yoff - 1;
369 $this->in_seq
= array();
372 $numer = $xlim - $xoff +
$nchunks - 1;
374 for ( $chunk = 0; $chunk < $nchunks; $chunk++
) {
376 for ( $i = 0; $i <= $this->lcs
; $i++
) {
377 $ymids[$i][$chunk - 1] = $this->seq
[$i];
381 $x1 = $xoff +
(int)( ( $numer +
( $xlim - $xoff ) * $chunk ) / $nchunks );
382 for ( ; $x < $x1; $x++
) {
383 $line = $flip ?
$this->yv
[$x] : $this->xv
[$x];
384 if ( empty( $ymatches[$line] ) ) {
387 $matches = $ymatches[$line];
389 while ( list( , $y ) = each( $matches ) ) {
390 if ( empty( $this->in_seq
[$y] ) ) {
391 $k = $this->lcsPos( $y );
393 $ymids[$k] = $ymids[$k - 1];
397 while ( list( , $y ) = each( $matches ) ) {
398 if ( $y > $this->seq
[$k - 1] ) {
399 assert( '$y < $this->seq[$k]' );
400 // Optimization: this is a common case:
401 // next match is just replacing previous match.
402 $this->in_seq
[$this->seq
[$k]] = false;
404 $this->in_seq
[$y] = 1;
405 } elseif ( empty( $this->in_seq
[$y] ) ) {
406 $k = $this->lcsPos( $y );
408 $ymids[$k] = $ymids[$k - 1];
414 $seps[] = $flip ?
array( $yoff, $xoff ) : array( $xoff, $yoff );
415 $ymid = $ymids[$this->lcs
];
416 for ( $n = 0; $n < $nchunks - 1; $n++
) {
417 $x1 = $xoff +
(int)( ( $numer +
( $xlim - $xoff ) * $n ) / $nchunks );
419 $seps[] = $flip ?
array( $y1, $x1 ) : array( $x1, $y1 );
421 $seps[] = $flip ?
array( $ylim, $xlim ) : array( $xlim, $ylim );
423 return array( $this->lcs
, $seps );
430 private function lcsPos( $ypos ) {
432 if ( $end == 0 ||
$ypos > $this->seq
[$end] ) {
433 $this->seq
[++
$this->lcs
] = $ypos;
434 $this->in_seq
[$ypos] = 1;
440 while ( $beg < $end ) {
441 $mid = (int)( ( $beg +
$end ) / 2 );
442 if ( $ypos > $this->seq
[$mid] ) {
449 assert( '$ypos != $this->seq[$end]' );
451 $this->in_seq
[$this->seq
[$end]] = false;
452 $this->seq
[$end] = $ypos;
453 $this->in_seq
[$ypos] = 1;
459 * Find LCS of two sequences.
461 * The results are recorded in the vectors $this->{x,y}changed[], by
462 * storing a 1 in the element for each line that is an insertion
463 * or deletion (ie. is not in the LCS).
465 * The subsequence of file 0 is [XOFF, XLIM) and likewise for file 1.
467 * Note that XLIM, YLIM are exclusive bounds.
468 * All line numbers are origin-0 and discarded lines are not counted.
474 private function compareSeq( $xoff, $xlim, $yoff, $ylim ) {
475 // Slide down the bottom initial diagonal.
476 while ( $xoff < $xlim && $yoff < $ylim && $this->xv
[$xoff] == $this->yv
[$yoff] ) {
481 // Slide up the top initial diagonal.
482 while ( $xlim > $xoff && $ylim > $yoff
483 && $this->xv
[$xlim - 1] == $this->yv
[$ylim - 1]
489 if ( $xoff == $xlim ||
$yoff == $ylim ) {
492 // This is ad hoc but seems to work well.
493 // $nchunks = sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5);
494 // $nchunks = max(2,min(8,(int)$nchunks));
495 $nchunks = min( 7, $xlim - $xoff, $ylim - $yoff ) +
1;
496 list( $lcs, $seps ) = $this->diag( $xoff, $xlim, $yoff, $ylim, $nchunks );
500 // X and Y sequences have no common subsequence:
502 while ( $yoff < $ylim ) {
503 $this->ychanged
[$this->yind
[$yoff++
]] = 1;
505 while ( $xoff < $xlim ) {
506 $this->xchanged
[$this->xind
[$xoff++
]] = 1;
509 // Use the partitions to split this problem into subproblems.
512 while ( $pt2 = next( $seps ) ) {
513 $this->compareSeq( $pt1[0], $pt2[0], $pt1[1], $pt2[1] );
520 * Adjust inserts/deletes of identical lines to join changes
521 * as much as possible.
523 * We do something when a run of changed lines include a
524 * line at one end and has an excluded, identical line at the other.
525 * We are free to choose which identical line is included.
526 * `compareseq' usually chooses the one at the beginning,
527 * but usually it is cleaner to consider the following identical line
528 * to be the "change".
530 * This is extracted verbatim from analyze.c (GNU diffutils-2.7).
532 private function shiftBoundaries( $lines, &$changed, $other_changed ) {
533 wfProfileIn( __METHOD__
);
537 assert( 'count($lines) == count($changed)' );
538 $len = count( $lines );
539 $other_len = count( $other_changed );
543 * Scan forwards to find beginning of another run of changes.
544 * Also keep track of the corresponding point in the other file.
546 * Throughout this code, $i and $j are adjusted together so that
547 * the first $i elements of $changed and the first $j elements
548 * of $other_changed both contain the same number of zeros
550 * Furthermore, $j is always kept so that $j == $other_len or
551 * $other_changed[$j] == false.
553 while ( $j < $other_len && $other_changed[$j] ) {
557 while ( $i < $len && !$changed[$i] ) {
558 assert( '$j < $other_len && ! $other_changed[$j]' );
561 while ( $j < $other_len && $other_changed[$j] ) {
572 // Find the end of this run of changes.
573 while ( ++
$i < $len && $changed[$i] ) {
579 * Record the length of this run of changes, so that
580 * we can later determine whether the run has grown.
582 $runlength = $i - $start;
585 * Move the changed region back, so long as the
586 * previous unchanged line matches the last changed one.
587 * This merges with previous changed regions.
589 while ( $start > 0 && $lines[$start - 1] == $lines[$i - 1] ) {
590 $changed[--$start] = 1;
591 $changed[--$i] = false;
592 while ( $start > 0 && $changed[$start - 1] ) {
596 while ( $other_changed[--$j] ) {
599 assert( '$j >= 0 && !$other_changed[$j]' );
603 * Set CORRESPONDING to the end of the changed run, at the last
604 * point where it corresponds to a changed run in the other file.
605 * CORRESPONDING == LEN means no such point has been found.
607 $corresponding = $j < $other_len ?
$i : $len;
610 * Move the changed region forward, so long as the
611 * first changed line matches the following unchanged one.
612 * This merges with following changed regions.
613 * Do this second, so that if there are no merges,
614 * the changed region is moved forward as far as possible.
616 while ( $i < $len && $lines[$start] == $lines[$i] ) {
617 $changed[$start++
] = false;
619 while ( $i < $len && $changed[$i] ) {
623 assert( '$j < $other_len && ! $other_changed[$j]' );
625 if ( $j < $other_len && $other_changed[$j] ) {
627 while ( $j < $other_len && $other_changed[$j] ) {
632 } while ( $runlength != $i - $start );
635 * If possible, move the fully-merged run of changes
636 * back to a corresponding run in the other file.
638 while ( $corresponding < $i ) {
639 $changed[--$start] = 1;
642 while ( $other_changed[--$j] ) {
645 assert( '$j >= 0 && !$other_changed[$j]' );
648 wfProfileOut( __METHOD__
);
653 * Class representing a 'diff' between two sequences of strings.
656 * @ingroup DifferenceEngine
663 * Computes diff between sequences of strings.
665 * @param $from_lines array An array of strings.
666 * Typically these are lines from a file.
667 * @param $to_lines array An array of strings.
669 function __construct( $from_lines, $to_lines ) {
670 $eng = new DiffEngine
;
671 $this->edits
= $eng->diff( $from_lines, $to_lines );
672 // $this->check($from_lines, $to_lines);
676 * Compute reversed Diff.
680 * $diff = new Diff($lines1, $lines2);
681 * $rev = $diff->reverse();
682 * @return Object A Diff object representing the inverse of the
687 $rev->edits
= array();
688 /** @var DiffOp $edit */
689 foreach ( $this->edits
as $edit ) {
690 $rev->edits
[] = $edit->reverse();
697 * Check for empty diff.
699 * @return bool True if two sequences were identical.
702 foreach ( $this->edits
as $edit ) {
703 if ( $edit->type
!= 'copy' ) {
712 * Compute the length of the Longest Common Subsequence (LCS).
714 * This is mostly for diagnostic purposed.
716 * @return int The length of the LCS.
720 foreach ( $this->edits
as $edit ) {
721 if ( $edit->type
== 'copy' ) {
722 $lcs +
= count( $edit->orig
);
730 * Get the original set of lines.
732 * This reconstructs the $from_lines parameter passed to the
735 * @return array The original sequence of strings.
740 foreach ( $this->edits
as $edit ) {
742 array_splice( $lines, count( $lines ), 0, $edit->orig
);
750 * Get the closing set of lines.
752 * This reconstructs the $to_lines parameter passed to the
755 * @return array The sequence of strings.
760 foreach ( $this->edits
as $edit ) {
761 if ( $edit->closing
) {
762 array_splice( $lines, count( $lines ), 0, $edit->closing
);
770 * Check a Diff for validity.
772 * This is here only for debugging purposes.
776 private function check( $from_lines, $to_lines ) {
777 wfProfileIn( __METHOD__
);
778 if ( serialize( $from_lines ) != serialize( $this->orig() ) ) {
779 trigger_error( "Reconstructed original doesn't match", E_USER_ERROR
);
781 if ( serialize( $to_lines ) != serialize( $this->closing() ) ) {
782 trigger_error( "Reconstructed closing doesn't match", E_USER_ERROR
);
785 $rev = $this->reverse();
786 if ( serialize( $to_lines ) != serialize( $rev->orig() ) ) {
787 trigger_error( "Reversed original doesn't match", E_USER_ERROR
);
789 if ( serialize( $from_lines ) != serialize( $rev->closing() ) ) {
790 trigger_error( "Reversed closing doesn't match", E_USER_ERROR
);
794 foreach ( $this->edits
as $edit ) {
795 if ( $prevtype == $edit->type
) {
796 trigger_error( 'Edit sequence is non-optimal', E_USER_ERROR
);
798 $prevtype = $edit->type
;
802 trigger_error( 'Diff okay: LCS = ' . $lcs, E_USER_NOTICE
);
803 wfProfileOut( __METHOD__
);
808 * @todo document, bad name.
810 * @ingroup DifferenceEngine
812 class MappedDiff
extends Diff
{
816 * Computes diff between sequences of strings.
818 * This can be used to compute things like
819 * case-insensitve diffs, or diffs which ignore
820 * changes in white-space.
822 * @param $from_lines array An array of strings.
823 * Typically these are lines from a file.
825 * @param $to_lines array An array of strings.
827 * @param $mapped_from_lines array This array should
828 * have the same size number of elements as $from_lines.
829 * The elements in $mapped_from_lines and
830 * $mapped_to_lines are what is actually compared
831 * when computing the diff.
833 * @param $mapped_to_lines array This array should
834 * have the same number of elements as $to_lines.
836 function __construct( $from_lines, $to_lines,
837 $mapped_from_lines, $mapped_to_lines ) {
838 wfProfileIn( __METHOD__
);
840 assert( 'count( $from_lines ) == count( $mapped_from_lines )' );
841 assert( 'count( $to_lines ) == count( $mapped_to_lines )' );
843 parent
::__construct( $mapped_from_lines, $mapped_to_lines );
846 $editCount = count( $this->edits
);
847 for ( $i = 0; $i < $editCount; $i++
) {
848 $orig = &$this->edits
[$i]->orig
;
849 if ( is_array( $orig ) ) {
850 $orig = array_slice( $from_lines, $xi, count( $orig ) );
851 $xi +
= count( $orig );
854 $closing = &$this->edits
[$i]->closing
;
855 if ( is_array( $closing ) ) {
856 $closing = array_slice( $to_lines, $yi, count( $closing ) );
857 $yi +
= count( $closing );
860 wfProfileOut( __METHOD__
);
865 * Additions by Axel Boldt follow, partly taken from diff.php, phpwiki-1.3.3
871 * @ingroup DifferenceEngine
873 class HWLDF_WordAccumulator
{
874 private $lines = array();
882 private function flushGroup( $new_tag ) {
883 if ( $this->group
!== '' ) {
884 if ( $this->tag
== 'ins' ) {
885 $this->line
.= '<ins class="diffchange diffchange-inline">' .
886 htmlspecialchars( $this->group
) . '</ins>';
887 } elseif ( $this->tag
== 'del' ) {
888 $this->line
.= '<del class="diffchange diffchange-inline">' .
889 htmlspecialchars( $this->group
) . '</del>';
891 $this->line
.= htmlspecialchars( $this->group
);
895 $this->tag
= $new_tag;
901 private function flushLine( $new_tag ) {
902 $this->flushGroup( $new_tag );
903 if ( $this->line
!= '' ) {
904 array_push( $this->lines
, $this->line
);
906 # make empty lines visible by inserting an NBSP
907 array_push( $this->lines
, ' ' );
916 public function addWords( $words, $tag = '' ) {
917 if ( $tag != $this->tag
) {
918 $this->flushGroup( $tag );
921 foreach ( $words as $word ) {
922 // new-line should only come as first char of word.
926 if ( $word[0] == "\n" ) {
927 $this->flushLine( $tag );
928 $word = substr( $word, 1 );
930 assert( '!strstr( $word, "\n" )' );
931 $this->group
.= $word;
938 public function getLines() {
939 $this->flushLine( '~done' );
948 * @ingroup DifferenceEngine
950 class WordLevelDiff
extends MappedDiff
{
951 const MAX_LINE_LENGTH
= 10000;
955 * @param $closing_lines
957 function __construct( $orig_lines, $closing_lines ) {
958 wfProfileIn( __METHOD__
);
960 list( $orig_words, $orig_stripped ) = $this->split( $orig_lines );
961 list( $closing_words, $closing_stripped ) = $this->split( $closing_lines );
963 parent
::__construct( $orig_words, $closing_words,
964 $orig_stripped, $closing_stripped );
965 wfProfileOut( __METHOD__
);
972 private function split( $lines ) {
973 wfProfileIn( __METHOD__
);
978 foreach ( $lines as $line ) {
979 # If the line is too long, just pretend the entire line is one big word
980 # This prevents resource exhaustion problems
987 if ( strlen( $line ) > self
::MAX_LINE_LENGTH
) {
992 if ( preg_match_all( '/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs',
995 foreach ( $m[0] as $word ) {
998 foreach ( $m[1] as $stripped_word ) {
999 $stripped[] = $stripped_word;
1004 wfProfileOut( __METHOD__
);
1006 return array( $words, $stripped );
1012 public function orig() {
1013 wfProfileIn( __METHOD__
);
1014 $orig = new HWLDF_WordAccumulator
;
1016 foreach ( $this->edits
as $edit ) {
1017 if ( $edit->type
== 'copy' ) {
1018 $orig->addWords( $edit->orig
);
1019 } elseif ( $edit->orig
) {
1020 $orig->addWords( $edit->orig
, 'del' );
1023 $lines = $orig->getLines();
1024 wfProfileOut( __METHOD__
);
1032 public function closing() {
1033 wfProfileIn( __METHOD__
);
1034 $closing = new HWLDF_WordAccumulator
;
1036 foreach ( $this->edits
as $edit ) {
1037 if ( $edit->type
== 'copy' ) {
1038 $closing->addWords( $edit->closing
);
1039 } elseif ( $edit->closing
) {
1040 $closing->addWords( $edit->closing
, 'ins' );
1043 $lines = $closing->getLines();
1044 wfProfileOut( __METHOD__
);