diff --git a/Compiler.ahk b/Compiler.ahk index 940e097..25d832c 100644 --- a/Compiler.ahk +++ b/Compiler.ahk @@ -7,7 +7,7 @@ AhkCompile(AhkFile, ExeFile, ResourceID, CustomIcon, BinFile, UseMPRESS, fileCP) { - global ExeFileTmp, ExeFileG, SilentMode + global ExeFileTmp, ExeFileG, SilentMode, MjrVn tempWD := new CTempWD(AhkWorkingDir) ; Original Ahk2Exe starting directory SplitPath AhkFile,, Ahk_Dir,, Ahk_Name @@ -48,13 +48,13 @@ AhkCompile(AhkFile, ExeFile, ResourceID, CustomIcon, BinFile, UseMPRESS, fileCP) Util_Error("Ahk2Exe must be compiled with a Unicode 32-bit .exe Base file." , 0x2) + MjrVn := SubStr(BinType.Version,1,1) DerefIncludeVars.A_AhkVersion := BinType.Version DerefIncludeVars.A_PtrSize := BinType.PtrSize DerefIncludeVars.A_IsUnicode := BinType.IsUnicode DerefIncludeVars.A_BasePath := BinFile global AhkPath := UseAhkPath ; = any /ahk parameter - ; V2 alphas and betas expected to match as breaking changes between versions if (AhkPath = "") ; Later v2 versions will have base as .exe, so should match if !(AhkPath := ExeFiles[BinType.Version BinType.Summary]) ; .exe vs base? @@ -120,7 +120,7 @@ AhkCompile(AhkFile, ExeFile, ResourceID, CustomIcon, BinFile, UseMPRESS, fileCP) Reload := 1 } } } if Reload - run "%ExeFileG%", %ExeFileG%\.. + Run "%ExeFileG%", %ExeFileG%\.. Util_HideHourglass() Util_Status("") return ExeFileG @@ -129,10 +129,10 @@ AhkCompile(AhkFile, ExeFile, ResourceID, CustomIcon, BinFile, UseMPRESS, fileCP) BundleAhkScript(ExeFile, ResourceID, AhkFile, UseMPRESS, IcoFile , fileCP, BinFile, VerInfo) -{ +{ global MjrVn if fileCP is space - if SubStr(DerefIncludeVars.A_AhkVersion,1,1) = 2 - fileCP := "UTF-8" ; Default for v2 is UTF-8 + if (MjrVn != 1) + fileCP := "UTF-8" ; Default for v2+ is UTF-8 else fileCP := A_FileEncoding try FileEncoding, %fileCP% diff --git a/ScriptParser.ahk b/ScriptParser.ahk index 0abb7e7..46aa9f4 100644 --- a/ScriptParser.ahk +++ b/ScriptParser.ahk @@ -3,7 +3,7 @@ ; PreprocessScript(ByRef ScriptText, AhkScript, Directives, PriorLines , FileList := "", FirstScriptDir := "", Options := "", iOption := 0) -{ global DirDoneG, PriorLine +{ global DirDoneG, PriorLine, MjrVn SplitPath, AhkScript, ScriptName, ScriptDir if !IsObject(FileList) { @@ -18,7 +18,7 @@ PreprocessScript(ByRef ScriptText, AhkScript, Directives, PriorLines oldLineFile := DerefIncludeVars.A_LineFile DerefIncludeVars.A_LineFile := AhkScript - if SubStr(DerefIncludeVars.A_AhkVersion,1,1)=2 ; Handle v2 default folder + if (MjrVn != 1) ; Handle v2+ default folder { OldWorkingDirv2 := A_WorkingDir SetWorkingDir %ScriptDir% } @@ -54,7 +54,7 @@ PreprocessScript(ByRef ScriptText, AhkScript, Directives, PriorLines else if StrStartsWith(tline, "/*") { if StrStartsWith(tline, "/*@Ahk2Exe-Keep") cmtBlock := 2 - else if !(SubStr(DerefIncludeVars.A_AhkVersion,1,1)=2 &&tline~="\*/$") + else if !(MjrVn != 1 && tline ~= "\*/$") cmtBlock := 1 continue } else if (cmtBlock = 2 && StrStartsWith(tline, "*/")) @@ -144,8 +144,7 @@ PreprocessScript(ByRef ScriptText, AhkScript, Directives, PriorLines Util_Error("Error: #Delimiter is not supported.", 0x22) else ScriptText .= (contSection ? A_LoopReadLine : tline) "`n" - } else if (tline~="^\*/" - || SubStr(DerefIncludeVars.A_AhkVersion,1,1)=2 && tline~="\*/$") + } else if (tline~="^\*/" || MjrVn != 1 && tline~="\*/$") cmtBlock := 0 ; End block comment } ; End file-read loop Loop, % !!IsFirstScript ; Like "if IsFirstScript" but can "break" from block @@ -191,7 +190,7 @@ PreprocessScript(ByRef ScriptText, AhkScript, Directives, PriorLines IfExist, %ilib% { FileGetSize wk, %ilib% if wk > 3 - { if SubStr(DerefIncludeVars.A_AhkVersion,1,1)=1 + { if (MjrVn != 1) { Loop 4 ; v1 - Generate random label prefix { Random wk, 97, 122 ScriptText .= Chr(wk) ; Prevent possible '#Warn Unreachable' @@ -210,7 +209,7 @@ PreprocessScript(ByRef ScriptText, AhkScript, Directives, PriorLines if OldWorkingDir SetWorkingDir, %OldWorkingDir% - if SubStr(DerefIncludeVars.A_AhkVersion,1,1)=2 ; Handle v2 default folder + if (MjrVn != 1) ; Handle v2+ default folder SetWorkingDir %OldWorkingDirv2% } ; --------------------------- End PreprocessScript -----------------------------