diff --git a/ConvertFuncs.ahk b/ConvertFuncs.ahk index 76a72059..ee8a2a37 100644 --- a/ConvertFuncs.ahk +++ b/ConvertFuncs.ahk @@ -449,27 +449,32 @@ _convertLines(ScriptString, finalize:=!gUseMasking) ; 2024-06-26 RENAMED to ac { Line := RTrim(Equation[1]) . ' := ""' . Equation[2] } - else if (RegexMatch(Line, "(?i)^(\h*[a-z_][a-z_0-9]*\h*[:*\.]=\h*)(.*)", &Equation) && InStr(Line, '""')) ; Line is var assignment, and has "" + else if (RegexMatch(Line, "(?i)^(\h*[a-z_][a-z_0-9]*\h*[:*\.]=\h*)(.*)") && InStr(Line, '""')) ; Line is var assignment, and has "" { - ; 2024-08-02 AMB, Fix 272 - maskStrings(&line), Line := Equation[1], val := Equation[2] - if (!RegexMatch(Line, "\h*\w+(\((?>[^)(]+|(?-1))*\))")) ; not a func - { - ConvertDblQuotes2(&Line, val) - } - else if (InStr(RegExReplace(Line, "\w*(\((?>[^)(]+|(?-1))*\))"), '""')) - { - funcArray := [] - while (pos := RegexMatch(val, "\w+(\((?>[^)(]+|(?-1))*\))", &match)) + ; Fixes issues with continuation sections + Line := RegExReplace(Line, '""(\h*)\r\n', '"' Chr(0x2700) '"$1`r`n') + if (RegexMatch(Line, "(?i)^(\h*[a-z_][a-z_0-9]*\h*[:*\.]=\h*)(.*)", &Equation) && InStr(Line, '""')) { + ; 2024-08-02 AMB, Fix 272 + maskStrings(&line), Line := Equation[1], val := Equation[2] + if (!RegexMatch(Line, "\h*\w+(\((?>[^)(]+|(?-1))*\))")) ; not a func { - funcArray.push(match[]) - val := StrReplace(val, match[], Chr(1000) "FUNC_" funcArray.Length Chr(1000),,, 1) + ConvertDblQuotes2(&Line, val) } - ConvertDblQuotes2(&Line, val) - for i, v in funcArray { - Line := StrReplace(Line, Chr(1000) "FUNC_" i Chr(1000), v) + else if (InStr(RegExReplace(Line, "\w*(\((?>[^)(]+|(?-1))*\))"), '""')) + { + funcArray := [] + while (pos := RegexMatch(val, "\w+(\((?>[^)(]+|(?-1))*\))", &match)) + { + funcArray.push(match[]) + val := StrReplace(val, match[], Chr(1000) "FUNC_" funcArray.Length Chr(1000),,, 1) + } + ConvertDblQuotes2(&Line, val) + for i, v in funcArray { + Line := StrReplace(Line, Chr(1000) "FUNC_" i Chr(1000), v) + } } } + Line := RegExReplace(Line, Chr(0x2700)) restoreStrings(&line) } diff --git a/tests/Test_Folder/Failed conversions/Assignment_ex10.ah2 b/tests/Test_Folder/Failed conversions/Assignment_ex10.ah2 deleted file mode 100644 index 4b2909e4..00000000 --- a/tests/Test_Folder/Failed conversions/Assignment_ex10.ah2 +++ /dev/null @@ -1,5 +0,0 @@ -Var := "" ; Works if this line isn't blank - . "Multi line " - . "String concat" - -MsgBox(Var) \ No newline at end of file diff --git a/tests/Test_Folder/Failed conversions/ContinuationComments_ex1.ah1 b/tests/Test_Folder/Failed conversions/ContinuationComments_ex1.ah1 new file mode 100644 index 00000000..55abfb2a --- /dev/null +++ b/tests/Test_Folder/Failed conversions/ContinuationComments_ex1.ah1 @@ -0,0 +1,4 @@ +DllCall("Func" + , "Str", "ABC" ; Comment + , "Str", "123" ; Comment + , "Str", "DEF") ; Comment \ No newline at end of file diff --git a/tests/Test_Folder/Failed conversions/ContinuationComments_ex1.ah2 b/tests/Test_Folder/Failed conversions/ContinuationComments_ex1.ah2 new file mode 100644 index 00000000..55abfb2a --- /dev/null +++ b/tests/Test_Folder/Failed conversions/ContinuationComments_ex1.ah2 @@ -0,0 +1,4 @@ +DllCall("Func" + , "Str", "ABC" ; Comment + , "Str", "123" ; Comment + , "Str", "DEF") ; Comment \ No newline at end of file diff --git a/tests/Test_Folder/Failed conversions/ContinuationComments_ex2.ah1 b/tests/Test_Folder/Failed conversions/ContinuationComments_ex2.ah1 new file mode 100644 index 00000000..050806de --- /dev/null +++ b/tests/Test_Folder/Failed conversions/ContinuationComments_ex2.ah1 @@ -0,0 +1,4 @@ +Var := "Comment should be on this line" ; Comment + . "Not this line" + +; See also: Assignment_ex10 \ No newline at end of file diff --git a/tests/Test_Folder/Failed conversions/ContinuationComments_ex2.ah2 b/tests/Test_Folder/Failed conversions/ContinuationComments_ex2.ah2 new file mode 100644 index 00000000..050806de --- /dev/null +++ b/tests/Test_Folder/Failed conversions/ContinuationComments_ex2.ah2 @@ -0,0 +1,4 @@ +Var := "Comment should be on this line" ; Comment + . "Not this line" + +; See also: Assignment_ex10 \ No newline at end of file diff --git a/tests/Test_Folder/Failed conversions/DllCall_ex12.ah1 b/tests/Test_Folder/Failed conversions/DllCall_ex12.ah1 deleted file mode 100644 index 778f62c7..00000000 --- a/tests/Test_Folder/Failed conversions/DllCall_ex12.ah1 +++ /dev/null @@ -1,18 +0,0 @@ -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/Test_Folder/Failed conversions/DllCall_ex12.ah2 b/tests/Test_Folder/Failed conversions/DllCall_ex12.ah2 deleted file mode 100644 index 778f62c7..00000000 --- a/tests/Test_Folder/Failed conversions/DllCall_ex12.ah2 +++ /dev/null @@ -1,18 +0,0 @@ -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/Test_Folder/Failed conversions/Assignment_ex10.ah1 b/tests/Test_Folder/String/Assignment_ex10.ah1 similarity index 100% rename from tests/Test_Folder/Failed conversions/Assignment_ex10.ah1 rename to tests/Test_Folder/String/Assignment_ex10.ah1 diff --git a/tests/Test_Folder/String/Assignment_ex10.ah2 b/tests/Test_Folder/String/Assignment_ex10.ah2 new file mode 100644 index 00000000..d272f0d3 --- /dev/null +++ b/tests/Test_Folder/String/Assignment_ex10.ah2 @@ -0,0 +1,5 @@ +Var := "" + . "Multi line " + . "String concat" ; Works if this line isn't blank + +MsgBox(Var) \ No newline at end of file