[squeak-dev] The Trunk: Collections-bp.765.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Oct 22 19:52:40 UTC 2017


Bernhard Pieber uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-bp.765.mcz

==================== Summary ====================

Name: Collections-bp.765
Author: bp
Time: 22 October 2017, 9:52:05.334068 pm
UUID: 5207defa-6a76-4177-93d0-b5a6806b805e
Ancestors: Collections-topa.764

Bring back String>>#replaceHtmlCharRefs from Squeak3.4 to make HtmlParser work again.

=============== Diff against Collections-topa.764 ===============

Item was added:
+ ----- Method: String>>replaceHtmlCharRefs (in category 'internet') -----
+ replaceHtmlCharRefs
+ 
+         | pos ampIndex scIndex special specialValue outString outPos newOutPos |
+ 
+         outString := String new: self size.
+         outPos := 0.
+ 
+         pos := 1.
+         
+         [ pos <= self size ] whileTrue: [ 
+                 "read up to the next ampersand"
+                 ampIndex := self indexOf: $& startingAt: pos ifAbsent: [0].
+                 
+                 ampIndex = 0 ifTrue: [
+                         pos = 1 ifTrue: [ ^self ] ifFalse: [ ampIndex := self size+1 ] ].
+ 
+                 newOutPos := outPos + ampIndex - pos.
+                 outString
+                         replaceFrom: outPos + 1
+                         to: newOutPos
+                         with: self
+                         startingAt: pos.
+                 outPos := newOutPos.
+                 pos := ampIndex.
+ 
+                 ampIndex <= self size ifTrue: [
+                         "find the $;"
+                         scIndex := self indexOf: $; startingAt: ampIndex ifAbsent: [ self size + 1 ].
+ 
+                         special := self copyFrom: ampIndex+1 to: scIndex-1.       
+                         specialValue := HtmlEntity valueOfHtmlEntity: special. 
+ 
+                         specialValue
+                                 ifNil: [
+                                         "not a recognized entity.  wite it back"
+ 								  scIndex > self size ifTrue: [ scIndex := self size ].
+ 
+                                         newOutPos := outPos + scIndex - ampIndex + 1.
+                                         outString
+                                                 replaceFrom: outPos+1
+                                                 to: newOutPos
+                                                 with: self
+                                                 startingAt: ampIndex.
+                                         outPos := newOutPos.]
+                                 ifNotNil: [
+                                         outPos := outPos + 1.
+                                         outString at: outPos put: specialValue isoToSqueak.].
+                         
+                         pos := scIndex + 1. ]. ].
+ 
+ 
+         ^outString copyFrom: 1 to: outPos!



More information about the Squeak-dev mailing list