Chris Muller uploaded a new version of System to project The Trunk: http://source.squeak.org/trunk/System-cmm.1447.mcz
==================== Summary ====================
Name: System-cmm.1447 Author: cmm Time: 12 February 2024, 3:06:16.671515 pm UUID: 03b7d234-da01-4b78-94c0-f78c01d4afe0 Ancestors: System-codefrau.1446
FileStream's stdout and stderr are for Linux, so use Linux line-endings when writing to them.
=============== Diff against System-codefrau.1446 ===============
Item was changed: ----- Method: CodeLoader>>installSourceFile: (in category 'installing') ----- installSourceFile: aStream "Install the previously loaded source file" | contents trusted | aStream ifNil:[^self error:'No content to install']. trusted := SecurityManager default positionToSecureContentsOf: aStream. trusted ifFalse:[(SecurityManager default enterRestrictedMode) ifFalse:[ aStream close. ^ self error:'Insecure content encountered']]. contents := self allButShebangLine: aStream upToEnd unzipped asString. (aStream respondsTo: #close) ifTrue:[aStream close]. ^[contents readStream fileIn] on: SyntaxErrorNotification do: [ : err | Smalltalk isHeadless ifTrue: + [FileStream stdout nextPutAll: err errorCode; lf; flush. - [FileStream stdout nextPutAll: err errorCode; cr; flush. Smalltalk snapshot: false andQuit: true ] ifFalse: [err pass] ]!
Item was changed: ----- Method: Exception>>printVerboseOn: (in category '*system') ----- printVerboseOn: aStream aStream nextPutAll: 'vvvvvvvvvvvvvvvvvv ' , self description , ' vvvvvvvvvvvvvvvvvv' ; + lf ; - cr ; nextPutAll: 'The time is ', DateAndTime now asString ; + lf. - cr. "Allow applications to optionally print extra details without overriding a base package." self printDetailsOn: aStream. aStream nextPutAll: self signalerContext longStack ; + lf ; - cr ; nextPutAll: '^^^^^^^^^^^^^^^^^^ ' , self description , ' ^^^^^^^^^^^^^^^^^^' ; + lf ; - cr ; flush!
Item was changed: ----- Method: SmalltalkImage>>run: (in category 'command line') ----- run: aBlock [ [ self patchSystem. (aBlock numArgs = 1 and: [ self arguments size > 1 ]) ifTrue: [ "Allow a large, variable number of arguments to be passed as an Array to aBlock." aBlock value: self arguments ] ifFalse: [ aBlock valueWithEnoughArguments: self arguments ] ] on: SyntaxErrorNotification do: [ : err | FileStream stdout nextPutAll: err errorCode ; + lf; flush. - cr; flush. self isHeadless ifTrue: [ self snapshot: false andQuit: true ] ifFalse: [ err pass ] ] on: Error , ProvideAnswerNotification do: [ : err | err printVerboseOn: FileStream stderr. FileStream stderr flush. self isHeadless ifTrue: [ self snapshot: false andQuit: true ] ifFalse: [ err pass ] ] on: ProgressInitiationException do: [ : pie | "Don't want to log this Notification." pie defaultAction ] ] on: Notification , Warning do: [ : noti | FileStream stdout nextPutAll: DateAndTime now asString ; space ; nextPutAll: noti description ; + lf. - cr. noti resume ] !
Hi Chris,
My understanding is that all platforms support these streams, not just Linux. FileStream's #stdout and #stderr are special streams (see #newForStdio) whose lineEndConvention is set according to the platform's default, which means that #cr sent to these streams produces the platform's new line character on the stream[1]. So, changing #cr to #lf in those methods does nothing but breaks line endings on non-unix platforms (Windows and older Macs).
Best, Levente
[1] #newForStdio forces #lf even if the platform's line-end convention is #cr. That should probably be changed as #guessDefaultLineEndConvention does a good job determining the correct value.
On 2024. 02. 19. 0:05, commits@source.squeak.org wrote:
Chris Muller uploaded a new version of System to project The Trunk: http://source.squeak.org/trunk/System-cmm.1447.mcz
==================== Summary ====================
Name: System-cmm.1447 Author: cmm Time: 12 February 2024, 3:06:16.671515 pm UUID: 03b7d234-da01-4b78-94c0-f78c01d4afe0 Ancestors: System-codefrau.1446
FileStream's stdout and stderr are for Linux, so use Linux line-endings when writing to them.
=============== Diff against System-codefrau.1446 ===============
Item was changed: ----- Method: CodeLoader>>installSourceFile: (in category 'installing') ----- installSourceFile: aStream "Install the previously loaded source file" | contents trusted | aStream ifNil:[^self error:'No content to install']. trusted := SecurityManager default positionToSecureContentsOf: aStream. trusted ifFalse:[(SecurityManager default enterRestrictedMode) ifFalse:[ aStream close. ^ self error:'Insecure content encountered']]. contents := self allButShebangLine: aStream upToEnd unzipped asString. (aStream respondsTo: #close) ifTrue:[aStream close]. ^[contents readStream fileIn] on: SyntaxErrorNotification do: [ : err | Smalltalk isHeadless ifTrue:
[FileStream stdout nextPutAll: err errorCode; lf; flush.
[FileStream stdout nextPutAll: err errorCode; cr; flush. Smalltalk snapshot: false andQuit: true ] ifFalse: [err pass] ]!
Item was changed: ----- Method: Exception>>printVerboseOn: (in category '*system') ----- printVerboseOn: aStream aStream nextPutAll: 'vvvvvvvvvvvvvvvvvv ' , self description , ' vvvvvvvvvvvvvvvvvv' ;
lf ;
cr ; nextPutAll: 'The time is ', DateAndTime now asString ;
lf.
"Allow applications to optionally print extra details without overriding a base package." self printDetailsOn: aStream. aStream nextPutAll: self signalerContext longStack ;cr.
lf ;
cr ; nextPutAll: '^^^^^^^^^^^^^^^^^^ ' , self description , ' ^^^^^^^^^^^^^^^^^^' ;
lf ;
cr ; flush!
Item was changed: ----- Method: SmalltalkImage>>run: (in category 'command line') ----- run: aBlock [ [ self patchSystem. (aBlock numArgs = 1 and: [ self arguments size > 1 ]) ifTrue: [ "Allow a large, variable number of arguments to be passed as an Array to aBlock." aBlock value: self arguments ] ifFalse: [ aBlock valueWithEnoughArguments: self arguments ] ] on: SyntaxErrorNotification do: [ : err | FileStream stdout nextPutAll: err errorCode ;
lf; flush.
cr; flush. self isHeadless ifTrue: [ self snapshot: false andQuit: true ] ifFalse: [ err pass ] ] on: Error , ProvideAnswerNotification do: [ : err | err printVerboseOn: FileStream stderr. FileStream stderr flush. self isHeadless ifTrue: [ self snapshot: false andQuit: true ] ifFalse: [ err pass ] ] on: ProgressInitiationException do: [ : pie | "Don't want to log this Notification." pie defaultAction ] ] on: Notification , Warning do: [ : noti | FileStream stdout nextPutAll: DateAndTime now asString ; space ; nextPutAll: noti description ;
lf.
!cr. noti resume ]
Hi Levente,
My understanding is that all platforms support these streams, not just
Linux.
Agreed.
FileStream's #stdout and #stderr are special streams (see #newForStdio) whose lineEndConvention is set according to the platform's default, which means that #cr sent to these streams produces the platform's new line character on the stream[1]. So, changing #cr to #lf in those methods does nothing but breaks line endings on non-unix platforms (Windows and older Macs).
My understanding is that, regardless whether you write #lf, #cr, or #crlf, if MultiByteFileStream's #wantsLineEndConversion is true, it will write out whatever the correct line-ending for the running platform. I only changed the code for "semantics" when reading the code based on the historical origin of "stdout".
[1] #newForStdio forces #lf even if the platform's line-end convention is #cr. That should probably be changed as #guessDefaultLineEndConvention does a good job determining the correct value.
I'm not sure about that. I think #wantsLineEndConversion: true is all that's needed.
I don't have any Windows machines handy. If I'm wrong, I will certainly undo this.
Best, Chris
On 2024. 02. 19. 0:05, commits@source.squeak.org wrote:
Chris Muller uploaded a new version of System to project The Trunk: http://source.squeak.org/trunk/System-cmm.1447.mcz
==================== Summary ====================
Name: System-cmm.1447 Author: cmm Time: 12 February 2024, 3:06:16.671515 pm UUID: 03b7d234-da01-4b78-94c0-f78c01d4afe0 Ancestors: System-codefrau.1446
FileStream's stdout and stderr are for Linux, so use Linux line-endings
when writing to them.
=============== Diff against System-codefrau.1446 ===============
Item was changed: ----- Method: CodeLoader>>installSourceFile: (in category
'installing') -----
installSourceFile: aStream "Install the previously loaded source file" | contents trusted | aStream ifNil:[^self error:'No content to install']. trusted := SecurityManager default positionToSecureContentsOf:
aStream.
trusted ifFalse:[(SecurityManager default enterRestrictedMode) ifFalse:[ aStream close. ^ self
error:'Insecure content encountered']].
contents := self allButShebangLine: aStream upToEnd unzipped
asString.
(aStream respondsTo: #close) ifTrue:[aStream close]. ^[contents readStream fileIn] on: SyntaxErrorNotification do: [ : err | Smalltalk isHeadless ifTrue:
[FileStream stdout nextPutAll: err
errorCode; lf; flush.
[FileStream stdout nextPutAll: err
errorCode; cr; flush.
Smalltalk snapshot: false andQuit: true ] ifFalse: [err pass] ]!
Item was changed: ----- Method: Exception>>printVerboseOn: (in category '*system') ----- printVerboseOn: aStream aStream nextPutAll: 'vvvvvvvvvvvvvvvvvv ' , self description , '
vvvvvvvvvvvvvvvvvv' ;
lf ;
cr ; nextPutAll: 'The time is ', DateAndTime now asString ;
lf.
cr. "Allow applications to optionally print extra details without
overriding a base package."
self printDetailsOn: aStream. aStream nextPutAll: self signalerContext longStack ;
lf ;
cr ; nextPutAll: '^^^^^^^^^^^^^^^^^^ ' , self description , '
^^^^^^^^^^^^^^^^^^' ;
lf ;
cr ; flush!
Item was changed: ----- Method: SmalltalkImage>>run: (in category 'command line') ----- run: aBlock [ [ self patchSystem. (aBlock numArgs = 1 and: [ self arguments size > 1 ]) ifTrue: [ "Allow a large, variable number of arguments to
be passed as an Array to aBlock."
aBlock value: self arguments ] ifFalse: [ aBlock valueWithEnoughArguments: self arguments
] ]
on: SyntaxErrorNotification do: [ : err | FileStream stdout nextPutAll: err errorCode ;
lf; flush.
cr; flush. self isHeadless ifTrue: [ self snapshot: false andQuit:
true ]
ifFalse: [ err pass ] ] on: Error , ProvideAnswerNotification do: [ : err | err printVerboseOn: FileStream stderr. FileStream stderr flush. self isHeadless ifTrue: [ self snapshot: false andQuit:
true ]
ifFalse: [ err pass ] ] on: ProgressInitiationException do: [ : pie | "Don't want to log this Notification." pie defaultAction ] ] on: Notification , Warning do: [ : noti | FileStream stdout nextPutAll: DateAndTime now asString ; space ; nextPutAll: noti description ;
lf.
!cr. noti resume ]
Hi Chris,
On 2024. 02. 24. 22:27, Chris Muller wrote:
Hi Levente,
My understanding is that all platforms support these streams, not just Linux.
Agreed.
FileStream's #stdout and #stderr are special streams (see #newForStdio) whose lineEndConvention is set according to the platform's default, which means that #cr sent to these streams produces the platform's new line character on the stream[1]. So, changing #cr to #lf in those methods does nothing but breaks line endings on non-unix platforms (Windows and older Macs).
My understanding is that, regardless whether you write #lf, #cr, or #crlf, if MultiByteFileStream's #wantsLineEndConversion is true, it will write out whatever the correct line-ending for the running platform. I
See TextConverter >> #installLineEndConvention:. It will explicitly map the platform's line end string only to #cr.
Best, Levente
squeak-dev@lists.squeakfoundation.org