extensions.st
changeset 2582 85a5ed52fc7b
parent 2435 9f8b350002db
child 2679 cfab54d30fcc
--- a/extensions.st	Sun Jul 24 08:48:50 2011 +0200
+++ b/extensions.st	Sun Jul 24 08:56:05 2011 +0200
@@ -279,11 +279,11 @@
     |nextArg ljust plus pound width precision pad char arg argString|
 
     nextArg := [
-		    argStream atEnd ifTrue:[
-			self error:'not enough arguments for format string'
-		    ].
-		    argStream next
-	       ].
+                    argStream atEnd ifTrue:[
+                        self error:'not enough arguments for format string'
+                    ].
+                    argStream next
+               ].
 
     ljust := plus := pound := false.
     width := 0.
@@ -291,155 +291,156 @@
     pad := $ .
     char := inStream peek.
     char == $% ifTrue:[
-	^ outStream nextPut:inStream next
+        ^ outStream nextPut:inStream next
     ].
     char == $- ifTrue:[
-	ljust := true.
-	inStream next.
-	char := inStream peek
+        ljust := true.
+        inStream next.
+        char := inStream peek
     ].
     char == $  ifTrue:[
-	outStream space.
-	inStream next.
-	char := inStream peek
+        outStream space.
+        inStream next.
+        char := inStream peek
     ].
     char == $+ ifTrue:[
-	plus := true.
-	inStream next.
-	char := inStream peek
+        plus := true.
+        inStream next.
+        char := inStream peek
     ].
     char == $# ifTrue:[
-	pound := true.
-	inStream next.
-	char := inStream peek
+        pound := true.
+        inStream next.
+        char := inStream peek
     ].
     char == $* ifTrue:[
-	width := nextArg value.
-	inStream next.
-	char := inStream peek
+        width := nextArg value.
+        inStream next.
+        char := inStream peek
     ].
     char isDigit ifTrue:[
-	char == $0 ifTrue:[
-	    pad := $0
-	].
-	width := Integer readFrom:inStream.
-	char := inStream peek
+        char == $0 ifTrue:[
+            pad := $0
+        ].
+        width := Integer readFrom:inStream.
+        char := inStream peek
     ].
     char == $. ifTrue:[
-	inStream next.
-	char := inStream peek.
-	char == $* ifTrue:[
-	    precision := nextArg value.
-	    inStream next.
-	    char := inStream peek
-	] ifFalse:[
-	    precision := Integer readFrom:inStream.
-	    char := inStream peek
-	]
+        inStream next.
+        char := inStream peek.
+        char == $* ifTrue:[
+            precision := nextArg value.
+            inStream next.
+        ] ifFalse:[
+            precision := Integer readFrom:inStream.
+        ].
+        char := inStream peek
     ].
     char == $l "Ignore long specifier." ifTrue:[
-	inStream next.
-	char := inStream peek
+        inStream next.
+        char := inStream peek
     ].
     ('feg' includes:char) ifTrue:[
-	arg := nextArg value asFloat.
-	precision := precision min:6.
-	argString := WriteStream on:String new.
-	char == $g ifTrue:[
-	    arg absPrintOn:argString digits:precision + 1
-	].
-	char == $f ifTrue:[
-	    arg absDecimalPrintOn:argString digits:precision + arg abs log + 1
-	].
-	char == $e ifTrue:[
-	    arg absScientificPrintOn:argString digits:precision + 1
-	].
-	argString := argString contents.
-	arg < 0 ifTrue:[
-	    argString := '-' , argString
-	] ifFalse:[
-	    plus ifTrue:[
-		argString := '+' , argString
-	    ]
-	].
-	(precision = 0 and:[ pound not ]) ifTrue:[
-	    (argString includes:$e) ifTrue:[
-		"self halt"
-	    ] ifFalse:[
-		argString := arg truncated printString
-	    ]
-	].
-	pound ifTrue:[
-	    (argString includes:$e) ifTrue:[
-		"self halt"
-	    ] ifFalse:[
-		precision - (argString size - (argString indexOf:$.)) timesRepeat:[
-		    argString := argString , '0'
-		]
-	    ]
-	].
-	ljust ifTrue:[
-	    outStream nextPutAll:argString
-	].
-	width - argString size timesRepeat:[
-	    outStream space
-	].
-	ljust ifFalse:[
-	    outStream nextPutAll:argString
-	].
-	^ inStream next
+        arg := nextArg value asFloat.
+        precision := precision min:6.
+        argString := WriteStream on:String new.
+        char == $g ifTrue:[
+            arg absPrintOn:argString digits:precision + 1
+        ].
+        char == $f ifTrue:[
+            arg absDecimalPrintOn:argString digits:precision + arg abs log + 1
+        ].
+        char == $e ifTrue:[
+            arg absScientificPrintOn:argString digits:precision + 1
+        ].
+        argString := argString contents.
+        arg < 0 ifTrue:[
+            argString := '-' , argString
+        ] ifFalse:[
+            plus ifTrue:[
+                argString := '+' , argString
+            ]
+        ].
+        (precision = 0 and:[ pound not ]) ifTrue:[
+            (argString includes:$e) ifTrue:[
+                "self halt"
+            ] ifFalse:[
+                argString := arg truncated printString
+            ]
+        ].
+        pound ifTrue:[
+            (argString includes:$e) ifTrue:[
+                "self halt"
+            ] ifFalse:[
+                precision - (argString size - (argString indexOf:$.)) timesRepeat:[
+                    argString := argString , '0'
+                ]
+            ]
+        ].
+        ljust ifTrue:[
+            outStream nextPutAll:argString
+        ].
+        width - argString size timesRepeat:[
+            outStream space
+        ].
+        ljust ifFalse:[
+            outStream nextPutAll:argString
+        ].
+        ^ inStream next
     ].
     char == $c ifTrue:[
-	arg := String with:nextArg value asCharacter
+        arg := String with:nextArg value asCharacter
     ].
     char == $s "Assume the arg is a String or Symbol." ifTrue:[
-	arg := nextArg value asString
+        arg := nextArg value asString
     ].
     char == $d ifTrue:[
-	arg := nextArg value asInteger printString.
-	plus ifTrue:[
-	    arg := '+' , arg
-	]
+        arg := nextArg value asInteger printString.
+        plus ifTrue:[
+            arg := '+' , arg
+        ]
     ].
     char == $u ifTrue:[
-	arg := nextArg value asInteger abs printString
+        arg := nextArg value asInteger abs printString
     ].
     char == $o ifTrue:[
-	arg := nextArg value asInteger abs printStringRadix:8.
-	pound ifTrue:[
-	    arg := '0' , arg
-	]
+        arg := nextArg value asInteger abs printStringRadix:8.
+        pound ifTrue:[
+            arg := '0' , arg
+        ]
     ].
     char == $b ifTrue:[
-	arg := nextArg value asInteger abs printStringRadix:2.
-	pound ifTrue:[
-	    arg := '0' , arg
-	]
+        arg := nextArg value asInteger abs printStringRadix:2.
+        pound ifTrue:[
+            arg := '0' , arg
+        ]
     ].
     ('xX' includes:char) ifTrue:[
-	arg := nextArg value asInteger abs printStringRadix:16.
-	pound ifTrue:[
-	    arg := '0x' , arg
-	]
+        arg := nextArg value asInteger abs printStringRadix:16.
+        pound ifTrue:[
+            arg := '0x' , arg
+        ]
     ].
     char == $x ifTrue:[
-	1 to:arg size do:[:i |
-	    ('ABCDEF' includes:(arg at:i)) ifTrue:[
-		arg at:i put:((arg at:i) asciiValue + 16r20) asCharacter
-	    ]
-	]
+        1 to:arg size do:[:i |
+            ('ABCDEF' includes:(arg at:i)) ifTrue:[
+                arg at:i put:((arg at:i) asciiValue + 16r20) asCharacter
+            ]
+        ]
     ].
     precision := precision min:arg size.
     ljust ifTrue:[
-	outStream nextPutAll:(arg copyFrom:1 to:precision)
+        outStream nextPutAll:(arg copyFrom:1 to:precision)
     ].
     width - precision timesRepeat:[
-	outStream nextPut:pad
+        outStream nextPut:pad
     ].
     ljust ifFalse:[
-	outStream nextPutAll:(arg copyFrom:1 to:precision)
+        outStream nextPutAll:(arg copyFrom:1 to:precision)
     ].
     ^ inStream next
+
+    "Modified: / 24-07-2011 / 07:16:42 / cg"
 ! !
 
 !CharacterArray methodsFor:'printing & storing'!
@@ -1163,5 +1164,5 @@
 !stx_libbasic2 class methodsFor:'documentation'!
 
 extensionsVersion_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/extensions.st,v 1.18 2010-03-19 11:48:52 cg Exp $'
-! !
+    ^ '$Header: /cvs/stx/stx/libbasic2/extensions.st,v 1.19 2011-07-24 06:56:05 cg Exp $'
+! !
\ No newline at end of file