--- a/ResourcePack.st Mon Feb 26 17:14:00 1996 +0100
+++ b/ResourcePack.st Mon Feb 26 19:32:16 1996 +0100
@@ -357,7 +357,7 @@
!ResourcePack methodsFor:'file reading'!
-processLine:aLine
+processLine:aLine encoding:encoding
"process a single valid line (i.e. #ifdef & #include has already been processed)"
|lineString name stream l rest macroName value|
@@ -365,12 +365,12 @@
lineString := aLine withoutSeparators.
name := nil.
(lineString at:1) == $' ifTrue:[
- stream := ReadStream on:lineString.
- name := String
- readFrom:stream
- onError:[('RESOURCEPACK: invalid line <',lineString,'>') errorPrintNL. nil].
+ stream := ReadStream on:lineString.
+ name := String
+ readFrom:stream
+ onError:[('RESOURCEPACK: invalid line <',lineString,'>') errorPrintNL. nil].
"/ OLD: l := stream position
- l := stream position + 1.
+ l := stream position + 1.
"/ l := lineString indexOf:$' startingAt:2.
"/ l ~~ 0 ifTrue:[
@@ -378,38 +378,47 @@
"/ l := l + 1
"/ ]
] ifFalse:[
- l := lineString indexOfSeparatorStartingAt:1.
- l ~~ 0 ifTrue:[
- name := lineString copyFrom:1 to:l-1.
- ]
+ l := lineString indexOfSeparatorStartingAt:1.
+ l ~~ 0 ifTrue:[
+ name := lineString copyFrom:1 to:l-1.
+ ]
].
name notNil ifTrue:[
- rest := (lineString copyFrom:l) withoutSeparators.
- "
- skip <type> if present
- "
- (rest startsWith:$<) ifTrue:[
- l := lineString indexOf:$> startingAt:l.
- rest := (lineString copyFrom:l+1) withoutSeparators.
- ].
- (rest startsWith:$=) ifTrue:[
- rest := rest copyFrom:2.
- stream := ReadStream on:rest.
- macroName := stream nextAlphaNumericWord.
- rest := stream upToEnd.
- value := self at:macroName.
- value := Compiler evaluate:('self ' , rest)
- receiver:value
- notifying:nil
- compile:false.
- ] ifFalse:[
- value := Compiler evaluate:rest compile:false.
- (value == #Error) ifTrue:[
- Transcript show:('error in resource:' , name).
- ]
- ].
- self at:name put:value.
+ rest := (lineString copyFrom:l) withoutSeparators.
+ "
+ skip <type> if present
+ "
+ (rest startsWith:$<) ifTrue:[
+ l := lineString indexOf:$> startingAt:l.
+ rest := (lineString copyFrom:l+1) withoutSeparators.
+ ].
+ (rest startsWith:$=) ifTrue:[
+ rest := rest copyFrom:2.
+ stream := ReadStream on:rest.
+ macroName := stream nextAlphaNumericWord.
+ rest := stream upToEnd.
+ value := self at:macroName.
+ value := Compiler evaluate:('self ' , rest)
+ receiver:value
+ notifying:nil
+ compile:false.
+ ] ifFalse:[
+ value := Compiler evaluate:rest compile:false.
+ (value == #Error) ifTrue:[
+ Transcript show:('error in resource:' , name).
+ ] ifFalse:[
+ encoding notNil ifTrue:[
+ value isString ifTrue:[
+ value := value decodeFrom:encoding
+ ]
+ ]
+ ]
+ ].
+ self at:name put:value.
]
+
+ "Created: 26.2.1996 / 19:17:07 / cg"
+ "Modified: 26.2.1996 / 19:18:07 / cg"
!
readFromFile:fileName directory:dirName
@@ -442,7 +451,9 @@
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|
+ |lineString l lNo rest value ifLevel skipping first ok encoding|
+
+ encoding := nil.
ok := true.
ifLevel := 0.
@@ -494,6 +505,11 @@
rest := lineString copyFrom:8.
value := Compiler evaluate:rest compile:false.
self readFromFile:value directory:dirName
+ ] ifFalse:[
+ (lineString startsWith:'encoding') ifTrue:[
+ rest := lineString copyFrom:9.
+ encoding := Compiler evaluate:rest compile:false.
+ ]
]
]
]
@@ -506,7 +522,7 @@
('RESOURCEPACK: line ' , lNo printString , ': ''' , lineString , '''') errorPrintNL.
ok := false.
] do:[
- self processLine:lineString
+ self processLine:lineString encoding:encoding
]
]
]
@@ -516,7 +532,7 @@
^ ok
"Modified: 31.8.1995 / 02:33:45 / claus"
- "Modified: 23.2.1996 / 22:06:46 / cg"
+ "Modified: 26.2.1996 / 19:22:36 / cg"
! !
!ResourcePack methodsFor:'merging'!
@@ -532,6 +548,6 @@
!ResourcePack class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.26 1996-02-23 21:07:22 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.27 1996-02-26 18:32:16 cg Exp $'
! !
ResourcePack initialize!