--- a/PrintfScanf.st Thu Dec 05 15:39:27 2019 +0100
+++ b/PrintfScanf.st Fri Dec 06 17:33:44 2019 +0100
@@ -545,72 +545,75 @@
char == $s ifTrue:[
"Assume the arg is a String or Symbol."
arg := nextArg value asString
- ].
-
- ((char == $d) or:[char == $D or:[char == $i]]) ifTrue:[
- intVal := nextArg value asInteger.
- arg := intVal abs printString.
- ].
+ ] ifFalse:[
+ ((char == $d) or:[char == $D or:[char == $i]]) ifTrue:[
+ intVal := nextArg value asInteger.
+ arg := intVal abs printString.
+ ] ifFalse:[
+ ((char == $o) or:[char == $O]) ifTrue:[
+ "/ incompatibility here: printf prints it as an unsigned in 16/32/64 bits
+ "/ Q: how many bits should we use for LargeIntegers,
+ "/ or should we print a sign here???
+ "/ For now, the code prints a sign
+ intVal := nextArg value asInteger.
+ arg := intVal abs printStringRadix: 8.
+ pound ifTrue: [
+ intVal ~~ 0 ifTrue:[
+ poundPrefix := '0'
+ ]
+ ].
+ ] ifFalse:[
+ ((char == $x) or:[char == $X]) ifTrue:[
+ intVal := nextArg value asInteger.
+ arg := intVal abs printStringRadix: 16.
+ pound ifTrue: [
+ intVal ~~ 0 ifTrue:[
+ poundPrefix := ((char == $x) ifTrue:['0x'] ifFalse:['0X']).
+ ]
+ ].
- ((char == $o) or:[char == $O]) ifTrue:[
- "/ incompatibility here: printf prints it as an unsigned in 16/32/64 bits
- "/ Q: how many bits should we use for LargeIntegers,
- "/ or should we print a sign here???
- "/ For now, the code prints a sign
- intVal := nextArg value asInteger.
- arg := intVal abs printStringRadix: 8.
- pound ifTrue: [
- intVal ~~ 0 ifTrue:[
- poundPrefix := '0'
- ]
- ].
- ].
-
- ((char == $x) or:[char == $X]) ifTrue:[
- intVal := nextArg value asInteger.
- arg := intVal abs printStringRadix: 16.
- pound ifTrue: [
- intVal ~~ 0 ifTrue:[
- poundPrefix := ((char == $x) ifTrue:['0x'] ifFalse:['0X']).
- ]
+ char == $x ifTrue:[
+ "/ make it lowercase
+ arg := arg asLowercase.
+"/ 1 to: arg size do: [:i |
+"/ ('ABCDEF' includes: (arg at: i)) ifTrue:[
+"/ arg at: i put: (arg at: i) asLowercase
+"/ ]
+"/ ]
+ ].
+ ] ifFalse:[
+ ((char == $b) or:[char == $B]) ifTrue:[
+ intVal := nextArg value asInteger.
+ arg := intVal abs printStringRadix: 2.
+ pound ifTrue: [
+ intVal ~~ 0 ifTrue:[
+ poundPrefix := '0b'
+ ]
+ ].
+ ] ifFalse:[
+ char == $u ifTrue:[
+ "/ should we convert unsigned numbers here???
+ "/ (negatives: maybe to the next power-of-2)
+ intVal := nextArg value asInteger.
+ arg := intVal abs printString.
+ ] ifFalse:[
+ (char == $p) ifTrue:[
+ arg := nextArg value identityHash printString.
+ precisionisMin := true.
+ ] ifFalse:[
+ (char == $P) ifTrue:[
+ arg := nextArg value printString.
+ ] ifFalse:[
+ (char == $S) ifTrue:[
+ arg := nextArg value storeString.
+ ].
+ ].
+ ].
+ ].
+ ].
+ ].
+ ].
].
-
- char == $x ifTrue:[
- "/ make it lowercase
- 1 to: arg size do: [:i |
- ('ABCDEF' includes: (arg at: i)) ifTrue:[
- arg at: i put: (arg at: i) asLowercase
- ]
- ]
- ].
- ].
-
- ((char == $b) or:[char == $B]) ifTrue:[
- intVal := nextArg value asInteger.
- arg := intVal abs printStringRadix: 2.
- pound ifTrue: [
- intVal ~~ 0 ifTrue:[
- poundPrefix := '0b'
- ]
- ].
- ].
-
- char == $u ifTrue:[
- "/ should we convert unsigned numbers here???
- "/ (negatives: maybe to the next power-of-2)
- intVal := nextArg value asInteger.
- arg := intVal abs printString.
- ].
-
- (char == $p) ifTrue:[
- arg := nextArg value identityHash printString.
- precisionisMin := true.
- ].
- (char == $P) ifTrue:[
- arg := nextArg value printString.
- ].
- (char == $S) ifTrue:[
- arg := nextArg value storeString.
].
arg isNil ifTrue:[