diff -r 05e9d62867a6 -r e5a95e26ed83 ChangesBrowser.st --- a/ChangesBrowser.st Wed Oct 21 15:42:38 2009 +0200 +++ b/ChangesBrowser.st Wed Oct 21 16:22:00 2009 +0200 @@ -2552,96 +2552,101 @@ ] ]. - tempfile := Filename newTemporaryIn:nil. - tempfile exists ifTrue:[tempfile remove]. - [ - outStream := tempfile writeStream. - ] on:FileStream openErrorSignal do:[:ex| - self warn:'Cannot create temp file in current directory.'. - ^ false - ]. [ inStream := changeFileName asFilename readStream. ] on:FileStream openErrorSignal do:[:ex| self warn:'Cannot open old changesFile.'. ^ false ]. - - outStream nextPutLine:'"{ Encoding: utf8 }" !!'. - outStream := EncodedStream stream:outStream encoder:(CharacterEncoder encoderForUTF8). - - encoding := CharacterEncoder guessEncodingOfStream:inStream. - encoding notNil ifTrue:[ - decoder := CharacterEncoder encoderFor:encoding. - inStream := EncodedStream stream:inStream encoder:decoder. - ]. - - self withCursor:(Cursor write) do:[ - |excla sawExcla done first chunk - nChanges "{Class:SmallInteger}" | - - Stream writeErrorSignal handle:[:ex | - self warn:('Could not update the changes file.\\' , ex description) withCRs. - tempfile exists ifTrue:[tempfile remove]. + [ + tempfile := Filename newTemporaryIn:nil. + tempfile exists ifTrue:[tempfile remove]. + [ + outStream := tempfile writeStream. + ] on:FileStream openErrorSignal do:[:ex| + self warn:'Cannot create temp file in current directory.'. ^ false - ] do:[ - excla := inStream class chunkSeparator. - nChanges := self numberOfChanges. - - 1 to:nChanges do:[:index | - inStream position1Based:(changePositions at:index). - sawExcla := inStream peekFor:excla. - chunk := inStream nextChunk. - - (chunk notNil - and:[(chunk startsWith:'''---- snap') not]) ifTrue:[ - (stamp := changeTimeStamps at:index) notNil ifTrue:[ - outStream nextPutAll:'''---- timestamp ' , stamp , ' ----'''. - outStream nextPut:excla; cr. + ]. + + outStream nextPutLine:'"{ Encoding: utf8 }" !!'. + outStream := EncodedStream stream:outStream encoder:(CharacterEncoder encoderForUTF8). + + encoding := CharacterEncoder guessEncodingOfStream:inStream. + encoding notNil ifTrue:[ + decoder := CharacterEncoder encoderFor:encoding. + inStream := EncodedStream stream:inStream encoder:decoder. + ]. + + self withCursor:(Cursor write) do:[ + |excla sawExcla done first chunk + nChanges "{Class:SmallInteger}" | + + Stream writeErrorSignal handle:[:ex | + self warn:('Could not update the changes file.\\' , ex description) withCRs. + tempfile exists ifTrue:[tempfile remove]. + ^ false + ] do:[ + excla := inStream class chunkSeparator. + nChanges := self numberOfChanges. + + 1 to:nChanges do:[:index | + inStream position1Based:(changePositions at:index). + sawExcla := inStream peekFor:excla. + chunk := inStream nextChunk. + + (chunk notNil + and:[(chunk startsWith:'''---- snap') not]) ifTrue:[ + (stamp := changeTimeStamps at:index) notNil ifTrue:[ + outStream nextPutAll:'''---- timestamp ' , stamp , ' ----'''. + outStream nextPut:excla; cr. + ]. ]. + + sawExcla ifTrue:[ + outStream nextPut:excla. + outStream nextChunkPut:chunk. + outStream cr; cr. + " + a method-definition chunk - output followups + " + done := false. + first := true. + [done] whileFalse:[ + chunk := inStream nextChunk. + chunk isNil ifTrue:[ + outStream cr; cr. + done := true + ] ifFalse:[ + chunk isEmpty ifTrue:[ + outStream space; nextChunkPut:chunk; cr; cr. + done := true. + ] ifFalse:[ + first ifFalse:[ + outStream cr; cr. + ]. + outStream nextChunkPut:chunk. + ]. + ]. + first := false. + ]. + ] ifFalse:[ + outStream nextChunkPut:chunk. + outStream cr + ] ]. - - sawExcla ifTrue:[ - outStream nextPut:excla. - outStream nextChunkPut:chunk. - outStream cr; cr. - " - a method-definition chunk - output followups - " - done := false. - first := true. - [done] whileFalse:[ - chunk := inStream nextChunk. - chunk isNil ifTrue:[ - outStream cr; cr. - done := true - ] ifFalse:[ - chunk isEmpty ifTrue:[ - outStream space; nextChunkPut:chunk; cr; cr. - done := true. - ] ifFalse:[ - first ifFalse:[ - outStream cr; cr. - ]. - outStream nextChunkPut:chunk. - ]. - ]. - first := false. - ]. - ] ifFalse:[ - outStream nextChunkPut:chunk. - outStream cr - ] + outStream syncData; close. ]. - outStream syncData; close. inStream close. + + f := changeFileName asFilename. + f renameTo:(f withSuffix:'bak'). + tempfile renameOrCopyTo:changeFileName. + anyChanges := false ]. - - f := changeFileName asFilename. - f renameTo:(f withSuffix:'bak'). - tempfile renameOrCopyTo:changeFileName. - anyChanges := false - ]. + ] ensure:[ + inStream close. + ]. + ^ true "Modified: / 2.12.1996 / 22:29:15 / stefan" @@ -6084,9 +6089,9 @@ !ChangesBrowser class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.396 2009-10-21 13:42:38 cg Exp $' + ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.397 2009-10-21 14:22:00 cg Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.396 2009-10-21 13:42:38 cg Exp $' + ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.397 2009-10-21 14:22:00 cg Exp $' ! !