--- a/ResourcePack.st Tue Feb 17 13:11:02 2004 +0100
+++ b/ResourcePack.st Wed Feb 18 12:13:46 2004 +0100
@@ -337,36 +337,51 @@
at:aKey ifAbsent:defaultValue
"translate a string"
- |val alternativeKey rest usedKey|
+ |val alternativeKey rest usedKey idx|
aKey notNil ifTrue:[
val := super at:aKey ifAbsent:nil.
val notNil ifTrue:[^ val].
- "/ try with case-first swapped...
- (aKey isString
- and:[aKey size > 0
- and:[aKey first isLetter]]) ifTrue:[
- alternativeKey := aKey first isUppercase
- ifTrue:[aKey asLowercaseFirst]
- ifFalse:[aKey asUppercaseFirst].
- val := super at:alternativeKey ifAbsent:nil.
- val notNil ifTrue:[
- aKey first isUppercase ifTrue:[
- ^ val asUppercaseFirst
+ aKey isString ifTrue:[
+ aKey size > 0 ifTrue:[
+ "/ try with case-first swapped...
+ (aKey first isLetter) ifTrue:[
+ alternativeKey := aKey first isUppercase
+ ifTrue:[aKey asLowercaseFirst]
+ ifFalse:[aKey asUppercaseFirst].
+ val := super at:alternativeKey ifAbsent:nil.
+ val notNil ifTrue:[
+ aKey first isUppercase ifTrue:[
+ ^ val asUppercaseFirst
+ ].
+ ^ val asLowercaseFirst.
+ ].
].
- ^ val asLowercaseFirst.
- ].
- ].
+
+ (':=' includes:aKey last) ifTrue:[
+ rest := aKey last.
+ usedKey := aKey copyWithoutLast:1.
+
+ val := self at:usedKey ifAbsent:nil. "/ recursion
+ val notNil ifTrue:[^ val , rest].
+ ].
+
+ (aKey endsWith:'...') ifTrue:[
+ usedKey := aKey copyWithoutLast:3.
- (aKey isString
- and:[aKey size > 0
- and:[':=' includes:aKey last]]) ifTrue:[
- rest := aKey last.
- usedKey := aKey copyWithoutLast:1.
+ val := self at:usedKey ifAbsent:nil. "/ recursion
+ val notNil ifTrue:[^ val , '...'].
+ ].
- val := self at:usedKey ifAbsent:nil.
- val notNil ifTrue:[^ val , rest].
+ (idx := aKey indexOf:$&) ~~ 0 ifTrue:[
+ (aKey at:idx+1 ifAbsent:nil) ~~ $& ifTrue:[
+ usedKey := (aKey copyTo:idx-1) , (aKey copyFrom:idx+1).
+ val := self at:usedKey ifAbsent:nil. "/ recursion
+ val notNil ifTrue:[^ val].
+ ].
+ ].
+ ].
].
superPack notNil ifTrue:[
@@ -602,11 +617,11 @@
"Created: 6.9.1997 / 11:38:53 / cg"
!
-processLine:aLine encoding:encoding file:fileName
+processLine:aLine encoding:encodingSymbolOrEncoder file:fileName
"process a single valid line (i.e. #ifdef & #include has already been processed)"
|lineString name stream l rest macroName value
- conditional hasError|
+ conditional hasError decoder|
lineString := aLine withoutSeparators.
name := nil.
@@ -683,9 +698,15 @@
('ResourcePack [warning]: error in line: "' , rest , '"') errorPrintCR.
('ResourcePack [warning]: in file: ' , fileName) errorPrintCR.
] ifFalse:[
- encoding notNil ifTrue:[
- value isString ifTrue:[
- value := value decodeFrom:encoding
+ value isString ifTrue:[
+ encodingSymbolOrEncoder notNil ifTrue:[
+ encodingSymbolOrEncoder isSymbol ifTrue:[
+ decoder := CharacterEncoder unicodeEncoderFor:encodingSymbolOrEncoder ifAbsent:nil.
+ decoder isNil ifTrue:[ decoder := CharacterEncoder::NullEncoder ].
+ ] ifFalse:[
+ decoder := encodingSymbolOrEncoder
+ ].
+ value := decoder decodeString:value
]
]
]
@@ -740,7 +761,7 @@
specify where #include files are searched for.
Return true, if the style sheet could be read without errors, false otherwise."
- |lineString l lNo rest value ifLevel skipping first ok encoding pack errorHandler|
+ |lineString l lNo rest value ifLevel skipping first ok encoding decoder pack errorHandler|
encoding := nil.
@@ -751,7 +772,7 @@
errorHandler := [:ex |
|con|
-
+self halt.
('ResourcePack [warning]: ''' , ex description , '''') errorPrintCR.
('ResourcePack [info]: file: ' , inStream pathName printString , ' line: ' , lNo printString , ': ''' , lineString , '''') errorPrintCR.
con := ex suspendedContext.
@@ -845,6 +866,7 @@
].
].
encoding := rest asSymbol.
+ decoder := CharacterEncoder unicodeEncoderFor:encoding ifAbsent:nil.
]
]
]
@@ -866,7 +888,7 @@
"/ process as resource
self
processLine:lineString
- encoding:encoding
+ encoding:decoder
file:(inStream isFileStream
ifTrue:[inStream pathName]
ifFalse:['---'])
@@ -885,7 +907,7 @@
!ResourcePack class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.83 2004-02-03 23:27:06 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.84 2004-02-18 11:13:46 cg Exp $'
! !
ResourcePack initialize!