Commit 89df1bc1bf5eb8e6a3b633e5e5c8c656fa851036

Authored by Arthur Bikmullin
1 parent e291a9d8

Improved parsing args for transcc

Showing 1 changed file with 12 additions and 5 deletions
... ... @@ -196,7 +196,7 @@ Class TransCC
196 196 EnumTargets d
197 197 Next
198 198
199   - If args.Length<2
  199 + If Not opt_target Or Not opt_srcpath
200 200 Local valid:=""
201 201 For Local it:=Eachin _targets
202 202 valid+=" "+it.Key.Replace( " ","_" )
... ... @@ -252,9 +252,15 @@ Class TransCC
252 252
253 253 Method ParseArgs:Void()
254 254
255   - If args.Length>1 opt_srcpath=StripQuotes( args[args.Length-1].Trim() )
  255 + If args.Length > 1 opt_srcpath = StripQuotes( args[args.Length-1].Trim() )
  256 + Local argsLength:Int = args.Length-1
  257 +
  258 + If opt_srcpath.StartsWith("-") And ExtractExt(opt_srcpath) <> "monkey"
  259 + opt_srcpath = ""
  260 + argsLength += 1
  261 + End If
256 262
257   - For Local i:=1 Until args.Length-1
  263 + For Local i := 1 Until argsLength
258 264
259 265 Local arg:=args[i].Trim(),rhs:=""
260 266 Local j:=arg.Find( "=" )
... ... @@ -317,11 +323,12 @@ Class TransCC
317 323 Method LoadConfig:Void()
318 324
319 325 Local cfgpath:=monkeydir+"/bin/"
320   - If opt_cfgfile
  326 + If opt_cfgfile
321 327 cfgpath+=opt_cfgfile
322 328 Else
323   - cfgpath+="config."+HostOS+".txt"
  329 + cfgpath += "config."+HostOS+".txt"
324 330 Endif
  331 +
325 332 If FileType( cfgpath )<>FILETYPE_FILE Die "Failed to open config file"
326 333
327 334 Local cfg:=LoadString( cfgpath )
... ...