[squeak-dev] The Inbox: System-ct.1189.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Nov 14 18:59:18 UTC 2020


A new version of System was added to project The Inbox:
http://source.squeak.org/inbox/System-ct.1189.mcz

==================== Summary ====================

Name: System-ct.1189
Author: ct
Time: 14 November 2020, 7:59:11.730394 pm
UUID: 5f2ed1b3-61eb-b746-bcd3-3d97f3b9e893
Ancestors: System-mt.1187

Fixes handling of Smalltalk first command line argument which can be a script or a project path. At least on Windows, absolute paths were not interpreted correctly at this point before and a nil MNU error was raised.

Still, I am not absolutely sure what was the original intent for HTTP encoding. Why should one pass a decoded URL to the smalltalk executable? Please review.

Requires Network-ct.245 for absolute file path support in Url class >> #absoluteFromFileNameOrUrlString:.

=============== Diff against System-mt.1187 ===============

Item was added:
+ ----- Method: ProjectLauncher>>parseScriptUrl (in category 'private') -----
+ parseScriptUrl
+ 
+ 	^ self parseScriptUrl: (Smalltalk documentPath ifNil: [^ nil])
+ 		convertFromSystemString!

Item was added:
+ ----- Method: ProjectLauncher>>parseScriptUrl: (in category 'private') -----
+ parseScriptUrl: scriptName
+ 
+ 	scriptName ifEmpty: [^ nil].
+ 	
+ 	"pathTokens := scriptName splitBy: FileDirectory slash.
+ 	pathTokens := pathTokens collect: [:s | s encodeForHTTP].
+ 	encodedPath := pathTokens joinSeparatedBy: FileDirectory slash."
+ 	
+ 	"Try to parse absolute Windows path"
+ 	(Smalltalk platformName = 'Win32'
+ 		and: [scriptName size >= 3])
+ 			ifTrue: [
+ 				((scriptName first isLetter
+ 					and: [scriptName second = $:]
+ 					and: [scriptName third = $\]) "Absolute path starting with a drive letter"
+ 					or: [(scriptName first: 2) = '\\' "UNC path"])
+ 						ifTrue: [
+ 							^ FileUrl absoluteFromText: scriptName]].
+ 	
+ 	^ Url absoluteFromFileNameOrUrlString: scriptName!

Item was changed:
  ----- Method: ProjectLauncher>>startUpAfterLogin (in category 'running') -----
  startUpAfterLogin
+ 
+ 	| scriptName loader |
- 	| scriptName loader isUrl |
  	self setupFlaps.
+ 	
+ 	scriptName := Preferences readDocumentAtStartup
+ 		ifTrue: [self parseScriptUrl asString].
+ 	
+ 	scriptName
+ 		ifNil: [^ Preferences eToyFriendly
+ 			ifTrue: [self currentWorld addGlobalFlaps]].
+ 	
- 	Preferences readDocumentAtStartup
- 		ifTrue: [scriptName := Smalltalk documentPath
- 						ifNil: [''].
- 			scriptName := scriptName convertFromSystemString.
- 			scriptName isEmpty
- 				ifFalse: ["figure out if script name is a URL by itself"
- 					isUrl := (scriptName asLowercase beginsWith: 'http://')
- 								or: [(scriptName asLowercase beginsWith: 'file://')
- 										or: [scriptName asLowercase beginsWith: 'ftp://']].
- 					isUrl
- 						ifFalse: [| encodedPath pathTokens |
- 							"Allow for ../dir/scriptName arguments"
- 							pathTokens := scriptName splitBy: FileDirectory slash.
- 							pathTokens := pathTokens
- 										collect: [:s | s encodeForHTTP].
- 							encodedPath := pathTokens
- 										reduce: [:acc :each | acc , FileDirectory slash , each].
- 							scriptName := (FileDirectory default uri resolveRelativeURI: encodedPath) asString]]]
- 		ifFalse: [scriptName := ''].
- 	scriptName isEmptyOrNil
- 		ifTrue: [^ Preferences eToyFriendly
- 				ifTrue: [self currentWorld addGlobalFlaps]].
  	loader := CodeLoader new.
  	loader
  		loadSourceFiles: (Array with: scriptName).
  	(scriptName asLowercase endsWith: '.pr')
  		ifTrue: [self installProjectFrom: loader]
  		ifFalse: [loader installSourceFiles]!

Item was changed:
  ----- Method: SmalltalkImage>>documentPath (in category 'command line') -----
  documentPath
  	"Answer the absolute path of the document passed to the VM or nil if none."
+ 	"Smalltalk documentPath"
- 	"Smalltalk commandLine documentPath"
  	^ (self getSystemAttribute: 2)
  		ifNotNil: [ :arg | arg = self imageArgumentsMarker
  			ifTrue: [nil] ifFalse: [arg]].
  
  !



More information about the Squeak-dev mailing list