changed:
authorClaus Gittinger <cg@exept.de>
Sun, 24 Jul 2011 08:55:24 +0200
changeset 13520 52597f7f6ff8
parent 13519 16c0afd67cae
child 13521 3faf9238433e
changed: #matchScan:from:to:with:from:to:ignoreCase: #printf_printArgFrom:to:withData:
CharacterArray.st
--- a/CharacterArray.st	Sun Jul 24 08:53:56 2011 +0200
+++ b/CharacterArray.st	Sun Jul 24 08:55:24 2011 +0200
@@ -363,161 +363,160 @@
 "/ Transcript showCR:('match: ''' , (aString copyFrom:sStart to:sStop) ,
 "/                    ''' against:' , (matchScanArray copyFrom:mStart to:mStop) printString).
 
-	mSize := mStop - mStart + 1.
-	sSize := sStop - sStart + 1.
-
-	"empty strings match"
-	(mSize == 0) ifTrue:[^ (sSize == 0)].
-
-	matchEntry := matchScanArray at:mStart.
-
-	"/ the most common case first:
-	(sSize ~~ 0
-	and:[(checkChar := (aString at:sStart)) = matchEntry]) ifTrue:[
-	    "advance by one and continue"
-	    mStart := mStart + 1.
-	    sStart := sStart + 1
-	] ifFalse:[
-	    (matchEntry == #any) ifTrue:[
-		"restString empty -> no match"
-		(sSize == 0) ifTrue:[^ false].
-		"# matches single character"
-		((sSize == 1) and:[mSize == 1]) ifTrue:[^ true].
-		"advance by one and continue"
-		mStart := mStart + 1.
-		sStart := sStart + 1
-	    ] ifFalse:[
-		(matchEntry == #anyString) ifTrue:[
-		    "* alone matches anything"
-		    (mSize == 1) ifTrue:[^ true].
-		    "restString empty & matchString not empty -> no match"
-		    (sSize == 0) ifTrue:[^ false].
-
-		    "
-		     try to avoid some of the recursion by checking last
-		     character and continue with shortened strings if possible
-		    "
-		    quickCheck := false.
-		    (mStop >= mStart) ifTrue:[
-			matchLast := matchScanArray at:mStop.
-			(matchLast ~~ #anyString) ifTrue:[
-			    (matchLast == #any) ifTrue:[
-				quickCheck := true
-			    ] ifFalse:[
-				matchLast == (aString at:sStop) ifTrue:[
-				    quickCheck := true
-				] ifFalse:[
-				    matchLast isString ifTrue:[
-					quickCheck := matchLast includes:(aString at:sStop)
-				    ]
-				]
-			    ]
-			]
-		    ].
-		    quickCheck ifTrue:[
-			"
-			 quickCheck ok, advance from the right
-			"
-			mStop := mStop - 1.
-			sStop := sStop - 1
-		    ] ifFalse:[
-			"/ no quick check;
-			"/ look for the next character(s)
-			"/ and try matching there
-			"/ (to avoid recursion)
-
-			mStart < mStop ifTrue:[
-			    nextMatchEntry := matchScanArray at:mStart+1.
-			    nextMatchEntry isCharacter ifTrue:[
-				sStart <= sStop ifTrue:[
-				    [true] whileTrue:[
-					ignoreCase ifFalse:[
-					    index := aString indexOf:nextMatchEntry startingAt:sStart
-					] ifTrue:[
-					    index := aString findFirst:[:c | c asLowercase = nextMatchEntry asLowercase]
-							   startingAt:sStart.
-					].
-					(index == 0 or:[index > sStop]) ifTrue:[
-					    ^ false
-					].
-					(self matchScan:matchScanArray
-					      from:(mStart + 1)
-					      to:mStop
-					      with:aString
-					      from:index
-					      to:sStop
-					      ignoreCase:ignoreCase
-					) ifTrue:[
-					    ^ true
-					].
-					sStart := index + 1.
-				    ]
-				]
-			    ]
-			].
-
-			"
-			 no quick check possible;
-			 loop over all possible substrings
-			"
-			index := sStart.
-			[index <= sStop] whileTrue:[
-			    (self matchScan:matchScanArray
-				  from:(mStart + 1)
-				  to:mStop
-				  with:aString
-				  from:index
-				  to:sStop
-				  ignoreCase:ignoreCase
-			    ) ifTrue:[
-				^ true
-			    ].
-			    index := index + 1
-			].
-			^ false
-		    ].
-		] ifFalse:[
-		    (matchEntry isString) ifTrue:[
-			"testString empty -> no match"
-			(sSize == 0) ifTrue:[^ false].
-
-			included := false.
-			"/ checkChar := aString at:sStart.
-			included := matchEntry includes:checkChar.
-			included ifFalse:[
-			    ignoreCase ifTrue:[
-				checkChar isUppercase ifTrue:[
-				    included := matchEntry includes:checkChar asLowercase.
-				] ifFalse:[
-				    included := matchEntry includes:checkChar asUppercase.
-				]
-			    ].
-			].
-			mStart := mStart + 1.
-			mSize := mSize - 1.
-			included ifFalse:[^ false].
-
-			((sSize == 1) and:[mSize == 0]) ifTrue:[^ true].
-			"cut off 1st char and continue"
-			sStart := sStart + 1
-		    ] ifFalse:[
-			"/ must be single character
-
-			"testString empty ?"
-			(sSize == 0) ifTrue:[^ false].
-
-			"first characters equal ?"
-			"/ checkChar := aString at:sStart.
-			ignoreCase ifFalse:[^ false].
-			(checkChar asUppercase ~= matchEntry asUppercase) ifTrue:[^ false].
-
-			"advance and continue"
-			mStart := mStart + 1.
-			sStart := sStart + 1
-		    ]
-		]
-	    ]
-	]
+        mSize := mStop - mStart + 1.
+        sSize := sStop - sStart + 1.
+
+        "empty strings match"
+        (mSize == 0) ifTrue:[^ (sSize == 0)].
+
+        matchEntry := matchScanArray at:mStart.
+
+        "/ the most common case first:
+        (sSize ~~ 0
+        and:[(checkChar := (aString at:sStart)) = matchEntry]) ifTrue:[
+            "advance by one and continue"
+            mStart := mStart + 1.
+            sStart := sStart + 1
+        ] ifFalse:[
+            (matchEntry == #any) ifTrue:[
+                "restString empty -> no match"
+                (sSize == 0) ifTrue:[^ false].
+                "# matches single character"
+                ((sSize == 1) and:[mSize == 1]) ifTrue:[^ true].
+                "advance by one and continue"
+                mStart := mStart + 1.
+                sStart := sStart + 1
+            ] ifFalse:[
+                (matchEntry == #anyString) ifTrue:[
+                    "* alone matches anything"
+                    (mSize == 1) ifTrue:[^ true].
+                    "restString empty & matchString not empty -> no match"
+                    (sSize == 0) ifTrue:[^ false].
+
+                    "
+                     try to avoid some of the recursion by checking last
+                     character and continue with shortened strings if possible
+                    "
+                    quickCheck := false.
+                    (mStop >= mStart) ifTrue:[
+                        matchLast := matchScanArray at:mStop.
+                        (matchLast ~~ #anyString) ifTrue:[
+                            (matchLast == #any) ifTrue:[
+                                quickCheck := true
+                            ] ifFalse:[
+                                matchLast == (aString at:sStop) ifTrue:[
+                                    quickCheck := true
+                                ] ifFalse:[
+                                    matchLast isString ifTrue:[
+                                        quickCheck := matchLast includes:(aString at:sStop)
+                                    ]
+                                ]
+                            ]
+                        ]
+                    ].
+                    quickCheck ifTrue:[
+                        "
+                         quickCheck ok, advance from the right
+                        "
+                        mStop := mStop - 1.
+                        sStop := sStop - 1
+                    ] ifFalse:[
+                        "/ no quick check;
+                        "/ look for the next character(s)
+                        "/ and try matching there
+                        "/ (to avoid recursion)
+
+                        mStart < mStop ifTrue:[
+                            nextMatchEntry := matchScanArray at:mStart+1.
+                            nextMatchEntry isCharacter ifTrue:[
+                                sStart <= sStop ifTrue:[
+                                    [true] whileTrue:[
+                                        ignoreCase ifFalse:[
+                                            index := aString indexOf:nextMatchEntry startingAt:sStart
+                                        ] ifTrue:[
+                                            index := aString findFirst:[:c | c asLowercase = nextMatchEntry asLowercase]
+                                                           startingAt:sStart.
+                                        ].
+                                        (index == 0 or:[index > sStop]) ifTrue:[
+                                            ^ false
+                                        ].
+                                        (self matchScan:matchScanArray
+                                              from:(mStart + 1)
+                                              to:mStop
+                                              with:aString
+                                              from:index
+                                              to:sStop
+                                              ignoreCase:ignoreCase
+                                        ) ifTrue:[
+                                            ^ true
+                                        ].
+                                        sStart := index + 1.
+                                    ]
+                                ]
+                            ]
+                        ].
+
+                        "
+                         no quick check possible;
+                         loop over all possible substrings
+                        "
+                        index := sStart.
+                        [index <= sStop] whileTrue:[
+                            (self matchScan:matchScanArray
+                                  from:(mStart + 1)
+                                  to:mStop
+                                  with:aString
+                                  from:index
+                                  to:sStop
+                                  ignoreCase:ignoreCase
+                            ) ifTrue:[
+                                ^ true
+                            ].
+                            index := index + 1
+                        ].
+                        ^ false
+                    ].
+                ] ifFalse:[
+                    (matchEntry isString) ifTrue:[
+                        "testString empty -> no match"
+                        (sSize == 0) ifTrue:[^ false].
+
+                        included := false.
+                        "/ checkChar := aString at:sStart.
+                        included := matchEntry includes:checkChar.
+                        included ifFalse:[
+                            ignoreCase ifTrue:[
+                                checkChar isUppercase ifTrue:[
+                                    included := matchEntry includes:checkChar asLowercase.
+                                ] ifFalse:[
+                                    included := matchEntry includes:checkChar asUppercase.
+                                ]
+                            ].
+                        ].
+                        mStart := mStart + 1.
+                        mSize := mSize - 1.
+                        included ifFalse:[^ false].
+
+                        ((sSize == 1) and:[mSize == 0]) ifTrue:[^ true].
+                    ] ifFalse:[
+                        "/ must be single character
+
+                        "testString empty ?"
+                        (sSize == 0) ifTrue:[^ false].
+
+                        "first characters equal ?"
+                        "/ checkChar := aString at:sStart.
+                        ignoreCase ifFalse:[^ false].
+                        (checkChar asUppercase ~= matchEntry asUppercase) ifTrue:[^ false].
+
+                        "advance and continue"
+                        mStart := mStart + 1.
+                    ].
+                    "cut off 1st char and continue"
+                    sStart := sStart + 1
+                ]
+            ]
+        ]
     ].
 
     "
@@ -526,13 +525,13 @@
      scanArray := self matchScanArrayFrom:'*hello'.
      s := 'foo bar hello world'.
      CharacterArray
-	 matchScan:scanArray
-	 from:1
-	 to:scanArray size
-	 with:s
-	 from:1
-	 to:s size
-	 ignoreCase:false
+         matchScan:scanArray
+         from:1
+         to:scanArray size
+         with:s
+         from:1
+         to:s size
+         ignoreCase:false
     "
     "
      |scanArray s|
@@ -540,16 +539,17 @@
      scanArray := self matchScanArrayFrom:'*hello*'.
      s := 'foo bar hello world'.
      CharacterArray
-	 matchScan:scanArray
-	 from:1
-	 to:scanArray size
-	 with:s
-	 from:1
-	 to:s size
-	 ignoreCase:false
-    "
-
-    "Modified: / 15.10.1998 / 13:39:25 / cg"
+         matchScan:scanArray
+         from:1
+         to:scanArray size
+         with:s
+         from:1
+         to:s size
+         ignoreCase:false
+    "
+
+    "Modified: / 24-07-2011 / 07:17:03 / cg"
+    "Modified (comment): / 24-07-2011 / 08:55:14 / cg"
 !
 
 matchScanArrayFrom:aString
@@ -3716,18 +3716,6 @@
     "Modified: / 11-05-2010 / 19:12:37 / cg"
 ! !
 
-!CharacterArray methodsFor:'inspecting'!
-
-inspector2TabBytes
-
-    ^self newInspector2Tab
-        label: 'Bytes';
-        priority: 75;
-        view: ((ScrollableView for:Inspector) inspect: self asByteArray; yourself)
-
-    "Created: / 17-02-2008 / 10:10:50 / janfrog"
-    "Created: / 12-07-2011 / 19:34:20 / cg"
-! !
 
 !CharacterArray methodsFor:'matching - glob expressions'!
 
@@ -5854,11 +5842,11 @@
 !CharacterArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.455 2011-07-18 13:51:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.456 2011-07-24 06:55:24 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.455 2011-07-18 13:51:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.456 2011-07-24 06:55:24 cg Exp $'
 ! !
 
 CharacterArray initialize!