expandMacros: added <?...:...> support.
--- a/CharacterArray.st Mon Jan 31 16:30:10 2000 +0100
+++ b/CharacterArray.st Mon Jan 31 19:59:25 2000 +0100
@@ -2175,12 +2175,13 @@
"/ supported expansions:
"/
- "/ <#p> # is arg Number; slice in the args printString
- "/ <#s> # is arg Number; slice in the arg itself (must be a String)
- "/ <n> replace by a newLine character
- "/ <t> replace by a tab character
-
- |in out c fmt nr|
+ "/ <#p> # is arg Number; slice in the args printString
+ "/ <#s> # is arg Number; slice in the arg itself (must be a String)
+ "/ <#?s1:s2> # is arg Number; slice in s1 if the arg is true, s2 otherwise
+ "/ <n> replace by a newLine character
+ "/ <t> replace by a tab character
+
+ |in out c fmt nr arg s1 s2|
in := self readStream.
out := '' writeStream.
@@ -2201,25 +2202,35 @@
"/ what does VW do here ?
self halt:'invalid format'.
^ self
+ ].
+ (nr between:1 and:argArray size) ifFalse:[
+ "/ what does VW do here ?
+ self halt:'invalid format - bad argNr'.
+ ^ self
+ ].
+ arg := argArray at:nr.
+
+ fmt := in next.
+ (fmt == $p) ifTrue:[
+ "/ expand with args printString
+ out nextPutAll:arg printString.
] ifFalse:[
- (nr between:1 and:argArray size) ifFalse:[
- "/ what does VW do here ?
- self halt:'invalid format'.
- ^ self
- ] ifTrue:[
- fmt := in next.
- (fmt == $p) ifTrue:[
- "/ expand with args printString
- out nextPutAll:(argArray at:nr) printString.
+ (fmt == $s) ifTrue:[
+ "/ expand with arg itself
+ out nextPutAll:arg.
+ ] ifFalse:[
+ (fmt == $?) ifTrue:[
+ s1 := in upTo:$:.
+ s2 := in nextUpTo:$>.
+ arg ifTrue:[
+ out nextPutAll:s1
+ ] ifFalse:[
+ out nextPutAll:s2
+ ].
] ifFalse:[
- (fmt == $s) ifTrue:[
- "/ expand with arg itself
- out nextPutAll:(argArray at:nr).
- ] ifFalse:[
- "/ what does VW do here ?
- self halt:'invalid format'.
- ^ self
- ]
+ "/ what does VW do here ?
+ self halt:'invalid format'.
+ ^ self
]
]
].
@@ -4342,7 +4353,6 @@
"Modified: 17.4.1997 / 12:50:23 / cg"
! !
-
!CharacterArray methodsFor:'special string converting'!
chopTo:maxLen
@@ -5470,6 +5480,6 @@
!CharacterArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.175 1999-12-29 11:26:18 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.176 2000-01-31 18:59:25 cg Exp $'
! !
CharacterArray initialize!