diff --git a/ConvertFuncs.ahk b/ConvertFuncs.ahk index 4123de58..d14b9030 100644 --- a/ConvertFuncs.ahk +++ b/ConvertFuncs.ahk @@ -4242,7 +4242,7 @@ FixByRefParams(ScriptString) { Line := A_LoopField replacement := false for func, v in gmByRefParamMap { - if RegExMatch(Line, "(^|.*\W)\Q" func "\E\((.*)\)", &match) ; Nested functions break and cont. sections this + if RegExMatch(Line, "(^|.*\W)\Q" func "\E\((.*)\)(.*?)$", &match) ; Nested functions break and cont. sections this && !InStr(Line, "&") { ; Not defining a function retLine := match[1] func "(" params := match[2] @@ -4254,7 +4254,7 @@ FixByRefParams(ScriptString) { } params := StrReplace(params, MatchFuncParams[],,,, 1) } - retLine := RTrim(retLine, ", ") ")" + retLine := RTrim(retLine, ", ") ")" match[3] replacement := true } } diff --git a/tests/Failed conversions/ByRef_ex3.ah1 b/tests/Failed conversions/ByRef_ex3.ah1 new file mode 100644 index 00000000..d9161d7a --- /dev/null +++ b/tests/Failed conversions/ByRef_ex3.ah1 @@ -0,0 +1,8 @@ +MyFunc(ByRef a, ByRef b) {} + +MyFunc(a, b) +MyFunc(a, b), a = b ; Stripped +MyFunc(a, b) ; Stripped + +; MyFunc(a, b), Ord(1) +; MyFunc(a, b), MyFunc(a, b) \ No newline at end of file diff --git a/tests/Failed conversions/ByRef_ex3.ah2 b/tests/Failed conversions/ByRef_ex3.ah2 new file mode 100644 index 00000000..8da36a24 --- /dev/null +++ b/tests/Failed conversions/ByRef_ex3.ah2 @@ -0,0 +1,8 @@ +MyFunc(&a, &b) {} + +MyFunc(&a, &b) +MyFunc(&a, &b), a = b ; Stripped +MyFunc(&a, &b) ; Stripped + +; MyFunc(a, b), Ord(1) +; MyFunc(a, b), MyFunc(a, b) \ No newline at end of file diff --git a/tests/Failed conversions/DblQuoteMsgBox_ex1.ah1 b/tests/Failed conversions/DblQuoteMsgBox_ex1.ah1 new file mode 100644 index 00000000..07dd2311 --- /dev/null +++ b/tests/Failed conversions/DblQuoteMsgBox_ex1.ah1 @@ -0,0 +1,7 @@ +F1:: MsgBox % """" ; " +F2:: MsgBox % "abc""123" ; abc"123 +F3:: MsgBox % "abc""123" MyFunc("", "123""abc") "" ; abc"123123"abc + +MyFunc(a, b) { + return a b +} \ No newline at end of file diff --git a/tests/Failed conversions/DblQuoteMsgBox_ex1.ah2 b/tests/Failed conversions/DblQuoteMsgBox_ex1.ah2 new file mode 100644 index 00000000..8b0c0bce --- /dev/null +++ b/tests/Failed conversions/DblQuoteMsgBox_ex1.ah2 @@ -0,0 +1,7 @@ +F1::MsgBox("`"") ; " +F2::MsgBox("abc`"123") ; abc"123 +F3::MsgBox("abc`"123" MyFunc("", "123`"abc") "") ; abc"123123"abc + +MyFunc(a, b) { + return a b +} \ No newline at end of file diff --git a/tests/Failed conversions/DllCall_ex12.ah1 b/tests/Failed conversions/DllCall_ex12.ah1 new file mode 100644 index 00000000..1ae6b6fa --- /dev/null +++ b/tests/Failed conversions/DllCall_ex12.ah1 @@ -0,0 +1,18 @@ +var := DllCall("Func" + , "Str", "ABC" ; Comment + , "Str, "123" ; Comment + , "Str", "DEF") ;Comment + +hCtrl := DllCall("CreateWindowEx" + , "Uint", 0x200 ; WS_EX_CLIENTEDGE + , "str", "HiEdit" ; ClassName + , "str", "" ; This line causes the issue + , "Uint", WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE | hStyle + , "int", X ; Left + , "int", Y ; Top + , "int", W ; Width + , "int", H ; Height + , "Uint", HParent ; hWndParent + , "Uint", MODULEID ; hMenu + , "Uint", 0 ; hInstance + , "Uint", 0, "Uint") \ No newline at end of file diff --git a/tests/Failed conversions/DllCall_ex12.ah2 b/tests/Failed conversions/DllCall_ex12.ah2 new file mode 100644 index 00000000..1ae6b6fa --- /dev/null +++ b/tests/Failed conversions/DllCall_ex12.ah2 @@ -0,0 +1,18 @@ +var := DllCall("Func" + , "Str", "ABC" ; Comment + , "Str, "123" ; Comment + , "Str", "DEF") ;Comment + +hCtrl := DllCall("CreateWindowEx" + , "Uint", 0x200 ; WS_EX_CLIENTEDGE + , "str", "HiEdit" ; ClassName + , "str", "" ; This line causes the issue + , "Uint", WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE | hStyle + , "int", X ; Left + , "int", Y ; Top + , "int", W ; Width + , "int", H ; Height + , "Uint", HParent ; hWndParent + , "Uint", MODULEID ; hMenu + , "Uint", 0 ; hInstance + , "Uint", 0, "Uint") \ No newline at end of file diff --git a/tests/Failed conversions/GlobalGui_ex1.ah1 b/tests/Failed conversions/GlobalGui_ex1.ah1 new file mode 100644 index 00000000..831648f3 --- /dev/null +++ b/tests/Failed conversions/GlobalGui_ex1.ah1 @@ -0,0 +1,7 @@ +MyFunc() { + Gui, Add, Text,, Gui + Gui, Show, w150 +} +MyFunc() + +F1::Gui, Destroy \ No newline at end of file diff --git a/tests/Failed conversions/GlobalGui_ex1.ah2 b/tests/Failed conversions/GlobalGui_ex1.ah2 new file mode 100644 index 00000000..9185ca8a --- /dev/null +++ b/tests/Failed conversions/GlobalGui_ex1.ah2 @@ -0,0 +1,9 @@ +MyFunc() { + global ; V1toV2: Made function global + myGui := Gui() + myGui.Add("Text", , "Gui") + myGui.Show("w150") +} +MyFunc() + +F1::myGui.Destroy() \ No newline at end of file diff --git a/tests/Failed conversions/MsgBox_ex7.ah1 b/tests/Failed conversions/MsgBox_ex7.ah1 new file mode 100644 index 00000000..a11b8607 --- /dev/null +++ b/tests/Failed conversions/MsgBox_ex7.ah1 @@ -0,0 +1,18 @@ +Switch Var +{ +Case 1: MsgBox Test1 +Case 2: +MsgBox Test2 +} +IfMsgBox, Ok + MsgBox + +Switch Var +{ +Case 1: +MsgBox Test1 +Case 2: +MsgBox Test2 +} +IfMsgBox, Ok + MsgBox \ No newline at end of file diff --git a/tests/Failed conversions/MsgBox_ex7.ah2 b/tests/Failed conversions/MsgBox_ex7.ah2 new file mode 100644 index 00000000..7a5c45d5 --- /dev/null +++ b/tests/Failed conversions/MsgBox_ex7.ah2 @@ -0,0 +1,18 @@ +Switch Var +{ +Case 1: msgResult := MsgBox("Test1") +Case 2: +msgResult := MsgBox("Test2") +} +if (msgResult = "Ok") + MsgBox() + +Switch Var +{ +Case 1: +msgResult := MsgBox("Test1") +Case 2: +msgResult := MsgBox("Test2") +} +if (msgResult = "Ok") + MsgBox() \ No newline at end of file diff --git a/tests/Failed conversions/TernaryDblQuote_ex1.ah1 b/tests/Failed conversions/TernaryDblQuote_ex1.ah1 new file mode 100644 index 00000000..14a29fc8 --- /dev/null +++ b/tests/Failed conversions/TernaryDblQuote_ex1.ah1 @@ -0,0 +1 @@ +x := x = "" ? 0 : "" \ No newline at end of file diff --git a/tests/Failed conversions/TernaryDblQuote_ex1.ah2 b/tests/Failed conversions/TernaryDblQuote_ex1.ah2 new file mode 100644 index 00000000..14a29fc8 --- /dev/null +++ b/tests/Failed conversions/TernaryDblQuote_ex1.ah2 @@ -0,0 +1 @@ +x := x = "" ? 0 : "" \ No newline at end of file diff --git a/tests/Failed conversions/static_ex1.ah1 b/tests/Failed conversions/static_ex1.ah1 new file mode 100644 index 00000000..baa97fbe --- /dev/null +++ b/tests/Failed conversions/static_ex1.ah1 @@ -0,0 +1,6 @@ +MyFunc() { + static var = 1 + static var1=1,var2,var3=3 + MsgBox % var +} +MyFunc() \ No newline at end of file diff --git a/tests/Failed conversions/static_ex1.ah2 b/tests/Failed conversions/static_ex1.ah2 new file mode 100644 index 00000000..d818c57c --- /dev/null +++ b/tests/Failed conversions/static_ex1.ah2 @@ -0,0 +1,6 @@ +MyFunc() { + static var := 1 + static var1:=1,var2,var3:=3 + MsgBox(var) +} +MyFunc() \ No newline at end of file diff --git a/tests/Test_Folder/Flow of Control/ByRef_ex2.ah1 b/tests/Test_Folder/Flow of Control/ByRef_ex2.ah1 new file mode 100644 index 00000000..746afb57 --- /dev/null +++ b/tests/Test_Folder/Flow of Control/ByRef_ex2.ah1 @@ -0,0 +1,5 @@ +MyFunc(ByRef a, ByRef b) {} + +MyFunc(a, b) +MyFunc(a, b), a = b ; Stripped +MyFunc(a, b) ; Stripped \ No newline at end of file diff --git a/tests/Test_Folder/Flow of Control/ByRef_ex2.ah2 b/tests/Test_Folder/Flow of Control/ByRef_ex2.ah2 new file mode 100644 index 00000000..9883a748 --- /dev/null +++ b/tests/Test_Folder/Flow of Control/ByRef_ex2.ah2 @@ -0,0 +1,5 @@ +MyFunc(&a, &b) {} + +MyFunc(&a, &b) +MyFunc(&a, &b), a = b ; Stripped +MyFunc(&a, &b) ; Stripped \ No newline at end of file diff --git a/tests/Test_Folder/Flow of Control/Return_ex1.ah1 b/tests/Test_Folder/Flow of Control/Return_ex1-2.ah1 similarity index 63% rename from tests/Test_Folder/Flow of Control/Return_ex1.ah1 rename to tests/Test_Folder/Flow of Control/Return_ex1-2.ah1 index a8f2bb1c..4ca6860d 100644 --- a/tests/Test_Folder/Flow of Control/Return_ex1.ah1 +++ b/tests/Test_Folder/Flow of Control/Return_ex1-2.ah1 @@ -3,4 +3,6 @@ MyFunc() { Return, Trim(ToReturn, "Error") } -MsgBox % MyFunc() \ No newline at end of file +MsgBox % MyFunc() + +MsgBox("Return, Test") \ No newline at end of file diff --git a/tests/Test_Folder/Flow of Control/Return_ex1.ah2 b/tests/Test_Folder/Flow of Control/Return_ex1-2.ah2 similarity index 63% rename from tests/Test_Folder/Flow of Control/Return_ex1.ah2 rename to tests/Test_Folder/Flow of Control/Return_ex1-2.ah2 index ceb29260..f21d5914 100644 --- a/tests/Test_Folder/Flow of Control/Return_ex1.ah2 +++ b/tests/Test_Folder/Flow of Control/Return_ex1-2.ah2 @@ -3,4 +3,6 @@ MyFunc() { Return Trim(ToReturn, "Error") } -MsgBox(MyFunc()) \ No newline at end of file +MsgBox(MyFunc()) + +MsgBox("Return, Test") \ No newline at end of file diff --git a/tests/Test_Folder/Flow of Control/Return_ex2.ah1 b/tests/Test_Folder/Flow of Control/Return_ex2.ah1 deleted file mode 100644 index a37a9d23..00000000 --- a/tests/Test_Folder/Flow of Control/Return_ex2.ah1 +++ /dev/null @@ -1 +0,0 @@ -MsgBox("Return, Test") \ No newline at end of file diff --git a/tests/Test_Folder/Flow of Control/Return_ex2.ah2 b/tests/Test_Folder/Flow of Control/Return_ex2.ah2 deleted file mode 100644 index a37a9d23..00000000 --- a/tests/Test_Folder/Flow of Control/Return_ex2.ah2 +++ /dev/null @@ -1 +0,0 @@ -MsgBox("Return, Test") \ No newline at end of file