Merge jv
authorMerge Script
Mon, 31 Aug 2015 06:47:47 +0200
branchjv
changeset 18723 f7d0ff0386cf
parent 18719 b2b24233d00b (current diff)
parent 18722 c5f338c2a6dc (diff)
child 18725 dd8e208b04d3
Merge
CharacterArray.st
Stream.st
--- a/CharacterArray.st	Sun Aug 30 06:37:05 2015 +0200
+++ b/CharacterArray.st	Mon Aug 31 06:47:47 2015 +0200
@@ -317,6 +317,7 @@
     "Created: 3.8.1997 / 18:16:40 / cg"
 ! !
 
+
 !CharacterArray class methodsFor:'cleanup'!
 
 lowSpaceCleanup
@@ -360,6 +361,7 @@
     "
 ! !
 
+
 !CharacterArray class methodsFor:'pattern matching'!
 
 matchEscapeCharacter
@@ -765,6 +767,7 @@
     ^ Unicode32String
 ! !
 
+
 !CharacterArray methodsFor:'Compatibility-ANSI'!
 
 addLineDelimiters
@@ -4407,6 +4410,8 @@
 ! !
 
 
+
+
 !CharacterArray methodsFor:'matching - glob expressions'!
 
 compoundMatch:aString
@@ -5090,6 +5095,27 @@
 ! !
 
 
+!CharacterArray methodsFor:'matching - regex'!
+
+matchesRegex:regexString caseSensitive:aBoolean
+    "Test if the receiver matches a regex.
+     May raise RxParser>>regexErrorSignal or child signals.
+     This is a part of the Regular Expression Matcher package,
+        (c) 1996, 1999 Vassili Bykov.
+     Refer to `documentation' protocol of RxParser class for details."
+
+    aBoolean ifFalse:[
+        ^ self matchesRegexIgnoringCase:regexString
+    ] ifTrue:[
+        ^ self matchesRegex:regexString
+    ].
+
+    "
+     'hello world' matchesRegex:'h.*d'.
+    "
+
+    "Created: / 13-12-2010 / 11:01:49 / cg"
+! !
 
 !CharacterArray methodsFor:'padded copying'!
 
@@ -5752,6 +5778,7 @@
     "Modified: 17.4.1997 / 12:50:23 / cg"
 ! !
 
+
 !CharacterArray methodsFor:'special string converting'!
 
 asUnixFilenameString
@@ -6794,6 +6821,7 @@
     "
 ! !
 
+
 !CharacterArray methodsFor:'substring searching'!
 
 findRangeOfString:subString
@@ -6916,6 +6944,21 @@
     ^ self indexOfSubCollection: aString startingAt: 1 ifAbsent:[0]
 !
 
+indexOfString:aString startingAt:startIndex 
+    "VSE and V'age compatibility"
+    "find a substring. If found, return the index; if not found, return 0."
+
+    ^ self indexOfSubCollection:aString startingAt:startIndex ifAbsent:[0]
+!
+
+indexOfString:aString startingAt:startIndex ifAbsent:exceptionalValue 
+    "VSE and V'age compatibility"
+    "find a substring. 
+     If found, return the index; if not found, the value from exceptionalValue."
+
+    ^ self indexOfSubCollection:aString startingAt:startIndex ifAbsent:exceptionalValue
+!
+
 indexOfSubCollection:subString caseSensitive:caseSensitive
     "find a substring, starting at index. if found, return the index;
      if not found, return the result of evaluating exceptionBlock.
@@ -7457,6 +7500,7 @@
     ^ aVisitor visitString:self with:aParameter
 ! !
 
+
 !CharacterArray class methodsFor:'documentation'!
 
 version
--- a/Stream.st	Sun Aug 30 06:37:05 2015 +0200
+++ b/Stream.st	Mon Aug 31 06:47:47 2015 +0200
@@ -2898,6 +2898,86 @@
     "Modified: 4.1.1997 / 23:38:05 / cg"
 ! !
 
+!Stream methodsFor:'reading-numbers'!
+
+nextDecimalInteger
+    "read and return the next integer from the receiver stream.
+     Leaves the stream positioned after the digits"
+
+    ^ Integer readFrom:self
+
+    "
+     |s|
+     s := '1234a' readStream.
+     Transcript showCR:(s nextDecimalInteger).
+     s peek                                -> $a
+    "
+    "
+     |s|
+     s := '1234.0a' readStream.
+     Transcript showCR:(s nextDecimalInteger).
+     s peek                                -> $.
+    "
+    "
+     |s|
+     s := '1234.0a' readStream.
+     Transcript showCR:(s nextDecimalNumber).
+     s peek                                -> $a
+    "
+!
+
+nextDecimalInteger:numChars
+    "read and return the next integer of numChars size from the receiver stream.
+     Does NOT skip separators.
+     Leaves the stream positioned after the digits"
+
+    |chars|
+
+    chars := self next:numChars.
+    ^ Integer readFrom:chars
+
+    "
+     |s|
+     s := '1234a' readStream.
+     Transcript showCR:(s nextDecimalInteger:2).
+     Transcript showCR:(s nextDecimalInteger).
+     s peek                                -> $a
+    "
+!
+
+nextDecimalNumber
+    "read and return the next number from the receiver stream.
+     Leaves the stream positioned after the digits"
+
+    ^ Number readFrom:self
+
+    "
+     |s|
+     s := '1234.0a' readStream.
+     Transcript showCR:(s nextDecimalNumber).
+     s peek                                -> $a
+    "
+!
+
+nextDecimalNumber:numChars
+    "read and return the next number of numChars size from the receiver stream.
+     Does NOT skip separators.
+     Leaves the stream positioned after the digits"
+
+    |chars|
+
+    chars := self next:numChars.
+    ^ Integer readFrom:chars
+
+    "
+     |s|
+     s := '12.34a' readStream.
+     Transcript showCR:(s nextDecimalNumber:4).
+     Transcript showCR:(s nextDecimalInteger).
+     s peek                                -> $a
+    "
+! !
+
 !Stream methodsFor:'reading-strings'!
 
 nextLine