[Pkg] The Trunk: Collections-ul.407.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Nov 16 05:44:39 UTC 2010
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.407.mcz
==================== Summary ====================
Name: Collections-ul.407
Author: ul
Time: 16 November 2010, 6:40:10.433 am
UUID: c66d6765-ca57-cc4c-b08b-0582949ce71a
Ancestors: Collections-ul.406
- fix: http://bugs.squeak.org/view.php?id=6841
- fix: http://bugs.squeak.org/view.php?id=6665
=============== Diff against Collections-ul.406 ===============
Item was changed:
----- Method: String>>startingAt:match:startingAt: (in category 'comparing') -----
startingAt: keyStart match: text startingAt: textStart
"Answer whether text matches the pattern in this string.
Matching ignores upper/lower case differences.
Where this string contains #, text may contain any character.
Where this string contains *, text may contain any sequence of characters."
| anyMatch matchStart matchEnd i matchStr j ii jj |
i := keyStart.
j := textStart.
"Check for any #'s"
[i > self size ifTrue: [^ j > text size "Empty key matches only empty string"].
(self at: i) = $#] whileTrue:
["# consumes one char of key and one char of text"
j > text size ifTrue: [^ false "no more text"].
i := i+1. j := j+1].
"Then check for *"
(self at: i) = $*
ifTrue: [i = self size ifTrue:
[^ true "Terminal * matches all"].
"* means next match string can occur anywhere"
anyMatch := true.
matchStart := i + 1]
ifFalse: ["Otherwise match string must occur immediately"
anyMatch := false.
matchStart := i].
"Now determine the match string"
matchEnd := self size.
(ii := self indexOf: $* startingAt: matchStart) > 0 ifTrue:
+ [ii = matchStart ifTrue: [self error: '** not valid -- use * instead'].
- [ii = 1 ifTrue: [self error: '** not valid -- use * instead'].
matchEnd := ii-1].
(ii := self indexOf: $# startingAt: matchStart) > 0 ifTrue:
+ [ii = matchStart ifTrue: [self error: '*# not valid -- use #* instead'].
- [ii = 1 ifTrue: [self error: '*# not valid -- use #* instead'].
matchEnd := matchEnd min: ii-1].
matchStr := self copyFrom: matchStart to: matchEnd.
"Now look for the match string"
[jj := text findString: matchStr startingAt: j caseSensitive: false.
anyMatch ifTrue: [jj > 0] ifFalse: [jj = j]]
whileTrue:
["Found matchStr at jj. See if the rest matches..."
(self startingAt: matchEnd+1 match: text startingAt: jj + matchStr size) ifTrue:
[^ true "the rest matches -- success"].
"The rest did not match."
anyMatch ifFalse: [^ false].
"Preceded by * -- try for a later match"
j := j+1].
^ false "Failed to find the match string"!
Item was changed:
----- Method: String>>withoutQuoting (in category 'internet') -----
withoutQuoting
"remove the initial and final quote marks, if present"
"'''h''' withoutQuoting"
| quote |
self size < 2 ifTrue: [ ^self ].
quote := self first.
+ (quote = self last and: [ quote = $' or: [ quote = $" ] ])
- (quote = $' or: [ quote = $" ])
ifTrue: [ ^self copyFrom: 2 to: self size - 1 ]
ifFalse: [ ^self ].!
More information about the Packages
mailing list