MDL-72871 cleanup: Remove incorrect whitespace from codebase

Differences can be checked with git diff --ignore-all-space and
that will show that the only non-whitespace change is in a test
in the git lib/tests/html2text_test.php file. In that case the
whitespace has been replaced by a quoted string (of whitespaces)
keeping the test 100% equivalent and workarrounding the whitespace.
This commit is contained in:
Eloy Lafuente (stronk7)
2021-10-26 17:19:11 +02:00
parent 2b2897bf10
commit fdc2dcf264
10 changed files with 898 additions and 898 deletions
+7 -7
View File
@@ -2,15 +2,15 @@
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="moodle_database" type="databaseType" /> <xs:element name="moodle_database" type="databaseType" />
<xs:complexType name="databaseType"> <xs:complexType name="databaseType">
<xs:sequence> <xs:sequence>
<xs:element maxOccurs="unbounded" name="table" <xs:element maxOccurs="unbounded" name="table"
type="tableType" /> type="tableType" />
</xs:sequence> </xs:sequence>
<xs:attribute name="version" type="xs:float" use="required" /> <xs:attribute name="version" type="xs:float" use="required" />
<xs:attribute name="release" type="xs:string"></xs:attribute> <xs:attribute name="release" type="xs:string"></xs:attribute>
<xs:attribute name="timestamp" type="xs:dateTime" <xs:attribute name="timestamp" type="xs:dateTime"
use="required" /> use="required" />
<xs:attribute name="comment" type="xs:string" /> <xs:attribute name="comment" type="xs:string" />
</xs:complexType> </xs:complexType>
<xs:complexType name="tableType"> <xs:complexType name="tableType">
<xs:sequence> <xs:sequence>
+2 -2
View File
@@ -78,9 +78,9 @@ class core_html2text_testcase extends basic_testcase {
*/ */
public function test_build_link_list() { public function test_build_link_list() {
// Note the trailing whitespace left intentionally in the text. // Note the trailing whitespace left intentionally in the text after first link.
$text = 'Total of <a title="List of integrated issues" $text = 'Total of <a title="List of integrated issues"
href="http://tr.mdl.org/sh.jspa?r=1&j=p+%3D+%22I+d%22+%3D"> href="http://tr.mdl.org/sh.jspa?r=1&j=p+%3D+%22I+d%22+%3D"> ' . '
<strong>27 issues</strong></a> and <a href="http://another.url/?f=a&amp;b=2">some</a> other <strong>27 issues</strong></a> and <a href="http://another.url/?f=a&amp;b=2">some</a> other
have been fixed <strong><a href="http://third.url/view.php">last week</a></strong>'; have been fixed <strong><a href="http://third.url/view.php">last week</a></strong>';
File diff suppressed because it is too large Load Diff
+138 -138
View File
@@ -25,9 +25,9 @@
* file 1, with its corresponding position in file 2 or 0 if it isn't there. * file 1, with its corresponding position in file 2 or 0 if it isn't there.
*/ */
function ouwiki_diff_internal($file1,$file2) { function ouwiki_diff_internal($file1,$file2) {
// Basic variables // Basic variables
$n=count($file2); $n=count($file2);
$m=count($file1); $m=count($file1);
// Special-case for empty file2 which otherwise causes error // Special-case for empty file2 which otherwise causes error
if($n==0) if($n==0)
@@ -40,122 +40,122 @@ function ouwiki_diff_internal($file1,$file2) {
return $result; return $result;
} }
// Step 1 Build list of elements // Step 1 Build list of elements
///////// /////////
$V=array(); $V=array();
for($j=1;$j<=$n;$j++) { for($j=1;$j<=$n;$j++) {
$V[$j]=new StdClass; $V[$j]=new StdClass;
$V[$j]->serial=$j; $V[$j]->serial=$j;
$V[$j]->hash=crc32($file2[$j]); $V[$j]->hash=crc32($file2[$j]);
} }
// Step 2 Sort by hash,serial // Step 2 Sort by hash,serial
///////// /////////
usort($V,"ouwiki_diff_sort_v"); usort($V,"ouwiki_diff_sort_v");
// Make it start from 1 again // Make it start from 1 again
array_unshift($V,'bogus'); array_unshift($V,'bogus');
unset($V[0]); unset($V[0]);
// $V is now an array including the line number 'serial' and hash // $V is now an array including the line number 'serial' and hash
// of each line in file 2, sorted by hash and then serial. // of each line in file 2, sorted by hash and then serial.
// Step 3 Equivalence classes // Step 3 Equivalence classes
///////// /////////
$E=array(); $E=array();
$E[0]=new StdClass; $E[0]=new StdClass;
$E[0]->serial=0; $E[0]->serial=0;
$E[0]->last=true; $E[0]->last=true;
for($j=1;$j<=$n;$j++) { for($j=1;$j<=$n;$j++) {
$E[$j]=new StdClass; $E[$j]=new StdClass;
$E[$j]->serial=$V[$j]->serial; $E[$j]->serial=$V[$j]->serial;
$E[$j]->last=$j===$n || $V[$j]->hash!==$V[$j+1]->hash; $E[$j]->last=$j===$n || $V[$j]->hash!==$V[$j+1]->hash;
} }
// E is now an array sorted the same way as $V which includes // E is now an array sorted the same way as $V which includes
// the line number 'serial' and whether or not that is the 'last' // the line number 'serial' and whether or not that is the 'last'
// line in the given equivalence class, i.e. set of identical lines // line in the given equivalence class, i.e. set of identical lines
// Step 4 For each line in file1, finds start of equivalence class // Step 4 For each line in file1, finds start of equivalence class
///////// /////////
$P=array(); $P=array();
for($i=1;$i<=$m;$i++) { for($i=1;$i<=$m;$i++) {
// Find matching last entry from equivalence list // Find matching last entry from equivalence list
$P[$i]=ouwiki_diff_find_last($V,$E,crc32($file1[$i])); $P[$i]=ouwiki_diff_find_last($V,$E,crc32($file1[$i]));
} }
// P is now an array that finds the index (within $V) of the *first* // P is now an array that finds the index (within $V) of the *first*
// matching line in $V (referencing file 2, but not a line number, // matching line in $V (referencing file 2, but not a line number,
// because sorted in $V order) for each line in file 1. In other words // because sorted in $V order) for each line in file 1. In other words
// if you were to start at the P-value in $V and continue through, you // if you were to start at the P-value in $V and continue through, you
// would find all the lines from file 2 that are equal to the given line // would find all the lines from file 2 that are equal to the given line
// from file 1. // from file 1.
// Step 5 Initialise vector of candidates // Step 5 Initialise vector of candidates
///////// /////////
// I do not trust PHP references further than I can throw them (preferably // I do not trust PHP references further than I can throw them (preferably
// at the idiot who came up with the idea) so I am using a separate array // at the idiot who came up with the idea) so I am using a separate array
// to store candidates and all references are integers into that. // to store candidates and all references are integers into that.
$candidates=array(); $candidates=array();
$candidates[0]=new StdClass; $candidates[0]=new StdClass;
$candidates[0]->a=0; $candidates[0]->a=0;
$candidates[0]->b=0; $candidates[0]->b=0;
$candidates[0]->previous=null; $candidates[0]->previous=null;
$candidates[1]=new StdClass; $candidates[1]=new StdClass;
$candidates[1]->a=$m+1; $candidates[1]->a=$m+1;
$candidates[1]->b=$n+1; $candidates[1]->b=$n+1;
$candidates[1]->previous=null; $candidates[1]->previous=null;
$K=array(); $K=array();
$K[0]=0; // Ref to candidate 0 $K[0]=0; // Ref to candidate 0
$K[1]=1; // Ref to candidate 1 $K[1]=1; // Ref to candidate 1
$k=0; $k=0;
// Step 6 Merge stage // Step 6 Merge stage
///////// /////////
for($i=1;$i<=$m;$i++) { for($i=1;$i<=$m;$i++) {
if($P[$i]!==0) { if($P[$i]!==0) {
ouwiki_diff_merge($K,$k,$i,$E,$P[$i],$candidates); ouwiki_diff_merge($K,$k,$i,$E,$P[$i],$candidates);
} }
} }
// Step 7 // Step 7
///////// /////////
$J=array(); $J=array();
for($i=1;$i<=$m;$i++) { for($i=1;$i<=$m;$i++) {
$J[$i]=0; $J[$i]=0;
} }
// Step 8 Follow candidate chain to make nice representation // Step 8 Follow candidate chain to make nice representation
///////// /////////
$index=$K[$k]; $index=$K[$k];
while(!is_null($index)) { while(!is_null($index)) {
// Stop when we reach the first, dummy candidate // Stop when we reach the first, dummy candidate
if($candidates[$index]->a!=0) { if($candidates[$index]->a!=0) {
$J[$candidates[$index]->a]=$candidates[$index]->b; $J[$candidates[$index]->a]=$candidates[$index]->b;
} }
$index=$candidates[$index]->previous; $index=$candidates[$index]->previous;
} }
// Step 9 Get rid of 'jackpots' (hash collisions) // Step 9 Get rid of 'jackpots' (hash collisions)
///////// /////////
for($i=1;$i<=$m;$i++) { for($i=1;$i<=$m;$i++) {
if($J[$i]!=0 && $file1[$i]!=$file2[$J[$i]]) { if($J[$i]!=0 && $file1[$i]!=$file2[$J[$i]]) {
$J[$i]=0; $J[$i]=0;
} }
} }
// Done! (Maybe.) // Done! (Maybe.)
return $J; return $J;
} }
// Functions needed by parts of the algorithm // Functions needed by parts of the algorithm
@@ -163,66 +163,66 @@ function ouwiki_diff_internal($file1,$file2) {
// Merge, from step 7 (Appendix A.3) // Merge, from step 7 (Appendix A.3)
function ouwiki_diff_merge(&$K,&$k,$i,&$E,$p,&$candidates) { function ouwiki_diff_merge(&$K,&$k,$i,&$E,$p,&$candidates) {
$r=0; $r=0;
$c=$K[0]; $c=$K[0];
while(true) { while(true) {
$j=$E[$p]->serial; // Paper says 'i' but this is wrong (OCR) $j=$E[$p]->serial; // Paper says 'i' but this is wrong (OCR)
// Binary search in $K from $r to $k // Binary search in $K from $r to $k
$min=$r; $min=$r;
$max=$k+1; $max=$k+1;
while(true) { while(true) {
$try = (int)(($min+$max)/2); $try = (int)(($min+$max)/2);
if($candidates[$K[$try]]->b >= $j) { if($candidates[$K[$try]]->b >= $j) {
$max=$try; $max=$try;
} else if($candidates[$K[$try+1]]->b <= $j) { } else if($candidates[$K[$try+1]]->b <= $j) {
$min=$try+1; $min=$try+1;
} else { // $try is less and $try+1 is more } else { // $try is less and $try+1 is more
$s=$try; $s=$try;
break; break;
} }
if($max<=$min) { if($max<=$min) {
$s=-1; $s=-1;
break; break;
} }
} }
if($s>-1) { if($s>-1) {
if($candidates[$K[$s+1]]->b > $j) { if($candidates[$K[$s+1]]->b > $j) {
// Create new candidate // Create new candidate
$index=count($candidates); $index=count($candidates);
$candidates[$index]=new StdClass; $candidates[$index]=new StdClass;
$candidates[$index]->a=$i; $candidates[$index]->a=$i;
$candidates[$index]->b=$j; $candidates[$index]->b=$j;
$candidates[$index]->previous=$K[$s]; $candidates[$index]->previous=$K[$s];
$K[$r]=$c; $K[$r]=$c;
$r=$s+1; $r=$s+1;
$c=$index; // Or should this go before? $c=$index; // Or should this go before?
} }
if($s===$k) { if($s===$k) {
$K[$k+2]=$K[$k+1]; $K[$k+2]=$K[$k+1];
$k++; $k++;
break; break;
} }
} }
if($E[$p]->last) { if($E[$p]->last) {
break; break;
} }
$p++; $p++;
} }
$K[$r]=$c; $K[$r]=$c;
} }
// From Step 2 // From Step 2
function ouwiki_diff_sort_v($a,$b) { function ouwiki_diff_sort_v($a,$b) {
if($a->hash < $b->hash) { if($a->hash < $b->hash) {
return -1; return -1;
} else if($a->hash > $b->hash) { } else if($a->hash > $b->hash) {
return 1; return 1;
} else if($a->serial < $b->serial) { } else if($a->serial < $b->serial) {
@@ -253,14 +253,14 @@ function ouwiki_diff_find_last(&$V,&$E,$hash) {
break; break;
} }
if($max<=$min) { if($max<=$min) {
// No matching line // No matching line
return 0; return 0;
} }
} }
// Now check back in $E to find the first line of that equivalence class // Now check back in $E to find the first line of that equivalence class
for($j=$try;!$E[$j-1]->last;$j--) ; for($j=$try;!$E[$j-1]->last;$j--) ;
return $j; return $j;
} }
/////////////////////////// ///////////////////////////
+45 -45
View File
@@ -24,58 +24,58 @@ function insertTags(tagOpen, tagClose, sampleText) {
// IE // IE
if(document.selection && !is_gecko) { if(document.selection && !is_gecko) {
var theSelection = document.selection.createRange().text; var theSelection = document.selection.createRange().text;
if(!theSelection) { theSelection=sampleText;} if(!theSelection) { theSelection=sampleText;}
txtarea.focus(); txtarea.focus();
if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
theSelection = theSelection.substring(0, theSelection.length - 1); theSelection = theSelection.substring(0, theSelection.length - 1);
document.selection.createRange().text = tagOpen + theSelection + tagClose + " "; document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
} else { } else {
document.selection.createRange().text = tagOpen + theSelection + tagClose; document.selection.createRange().text = tagOpen + theSelection + tagClose;
} }
// Mozilla // Mozilla
} else if(txtarea.selectionStart || txtarea.selectionStart == '0') { } else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
var startPos = txtarea.selectionStart; var startPos = txtarea.selectionStart;
var endPos = txtarea.selectionEnd; var endPos = txtarea.selectionEnd;
var scrollTop=txtarea.scrollTop; var scrollTop=txtarea.scrollTop;
var myText = (txtarea.value).substring(startPos, endPos); var myText = (txtarea.value).substring(startPos, endPos);
if(!myText) { myText=sampleText;} if(!myText) { myText=sampleText;}
if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any
subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " "; subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
} else { } else {
subst = tagOpen + myText + tagClose; subst = tagOpen + myText + tagClose;
} }
txtarea.value = txtarea.value.substring(0, startPos) + subst + txtarea.value = txtarea.value.substring(0, startPos) + subst +
txtarea.value.substring(endPos, txtarea.value.length); txtarea.value.substring(endPos, txtarea.value.length);
txtarea.focus(); txtarea.focus();
var cPos=startPos+(tagOpen.length+myText.length+tagClose.length); var cPos=startPos+(tagOpen.length+myText.length+tagClose.length);
txtarea.selectionStart=cPos; txtarea.selectionStart=cPos;
txtarea.selectionEnd=cPos; txtarea.selectionEnd=cPos;
txtarea.scrollTop=scrollTop; txtarea.scrollTop=scrollTop;
// All others // All others
} else { } else {
var copy_alertText=alertText; var copy_alertText=alertText;
var re1=new RegExp("\\$1","g"); var re1=new RegExp("\\$1","g");
var re2=new RegExp("\\$2","g"); var re2=new RegExp("\\$2","g");
copy_alertText=copy_alertText.replace(re1,sampleText); copy_alertText=copy_alertText.replace(re1,sampleText);
copy_alertText=copy_alertText.replace(re2,tagOpen+sampleText+tagClose); copy_alertText=copy_alertText.replace(re2,tagOpen+sampleText+tagClose);
var text; var text;
if (sampleText) { if (sampleText) {
text=prompt(copy_alertText); text=prompt(copy_alertText);
} else { } else {
text=""; text="";
} }
if(!text) { text=sampleText;} if(!text) { text=sampleText;}
text=tagOpen+text+tagClose; text=tagOpen+text+tagClose;
document.infoform.infobox.value=text; document.infoform.infobox.value=text;
// in Safari this causes scrolling // in Safari this causes scrolling
if(!is_safari) { if(!is_safari) {
txtarea.focus(); txtarea.focus();
} }
noOverwrite=true; noOverwrite=true;
} }
// reposition cursor if possible // reposition cursor if possible
if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate(); if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();