Skip to content

Commit

Permalink
fix assignment issue
Browse files Browse the repository at this point in the history
see #296 comments for info
  • Loading branch information
Banaanae committed Nov 5, 2024
1 parent 43a1172 commit 998e7b5
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 57 deletions.
37 changes: 21 additions & 16 deletions ConvertFuncs.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
5 changes: 0 additions & 5 deletions tests/Test_Folder/Failed conversions/Assignment_ex10.ah2

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DllCall("Func"
, "Str", "ABC" ; Comment
, "Str", "123" ; Comment
, "Str", "DEF") ; Comment
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DllCall("Func"
, "Str", "ABC" ; Comment
, "Str", "123" ; Comment
, "Str", "DEF") ; Comment
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Var := "Comment should be on this line" ; Comment
. "Not this line"

; See also: Assignment_ex10
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Var := "Comment should be on this line" ; Comment
. "Not this line"

; See also: Assignment_ex10
18 changes: 0 additions & 18 deletions tests/Test_Folder/Failed conversions/DllCall_ex12.ah1

This file was deleted.

18 changes: 0 additions & 18 deletions tests/Test_Folder/Failed conversions/DllCall_ex12.ah2

This file was deleted.

5 changes: 5 additions & 0 deletions tests/Test_Folder/String/Assignment_ex10.ah2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Var := ""
. "Multi line "
. "String concat" ; Works if this line isn't blank

MsgBox(Var)

0 comments on commit 998e7b5

Please sign in to comment.