Changeset 13211 for trunk/wp-includes/Text/Diff/Engine/string.php
- Timestamp:
- 02/19/2010 01:25:26 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/Text/Diff/Engine/string.php
r7747 r13211 11 11 * </code> 12 12 * 13 * $Horde: framework/Text_Diff/Diff/Engine/string.php,v 1.7 2008/01/04 10:07:50 jan Exp $14 *15 13 * Copyright 2005 Örjan Persson <o@42mm.org> 16 * Copyright 2005-20 08The Horde Project (http://www.horde.org/)14 * Copyright 2005-2010 The Horde Project (http://www.horde.org/) 17 15 * 18 16 * See the enclosed file COPYING for license information (LGPL). If you did … … 40 38 function diff($diff, $mode = 'autodetect') 41 39 { 40 // Detect line breaks. 41 $lnbr = "\n"; 42 if (strpos($diff, "\r\n") !== false) { 43 $lnbr = "\r\n"; 44 } elseif (strpos($diff, "\r") !== false) { 45 $lnbr = "\r"; 46 } 47 48 // Make sure we have a line break at the EOF. 49 if (substr($diff, -strlen($lnbr)) != $lnbr) { 50 $diff .= $lnbr; 51 } 52 42 53 if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') { 43 54 return PEAR::raiseError('Type of diff is unsupported'); … … 49 60 if ($context === $unified) { 50 61 return PEAR::raiseError('Type of diff could not be detected'); 51 } elseif ($context === false || $ context=== false) {62 } elseif ($context === false || $unified === false) { 52 63 $mode = $context !== false ? 'context' : 'unified'; 53 64 } else { … … 56 67 } 57 68 58 // split by new line and remove the diff header 59 $diff = explode("\n", $diff); 60 array_shift($diff); 61 array_shift($diff); 69 // Split by new line and remove the diff header, if there is one. 70 $diff = explode($lnbr, $diff); 71 if (($mode == 'context' && strpos($diff[0], '***') === 0) || 72 ($mode == 'unified' && strpos($diff[0], '---') === 0)) { 73 array_shift($diff); 74 array_shift($diff); 75 } 62 76 63 77 if ($mode == 'context') {
Note: See TracChangeset
for help on using the changeset viewer.