Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit a2ae215

Browse files
committed
[[ Bug 20027 ]] Ensure UQL is cleared when setting container value
This patch ensures that undeclared variables are cleared of their UQL status when their value is set via `MCContainer::set_valueref`.
1 parent bed2f08 commit a2ae215

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

docs/notes/bugfix-20027.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix value assignment to undeclared variable in matchText

engine/src/variable.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,8 @@ bool MCContainer::remove(MCExecContext& ctxt)
11041104

11051105
bool MCContainer::set_valueref(MCValueRef p_value)
11061106
{
1107-
return m_variable -> setvalueref(getpath(), false, p_value);
1107+
m_variable -> clearuql();
1108+
return m_variable -> setvalueref(getpath(), false, p_value);
11081109
}
11091110

11101111
MCValueRef MCContainer::get_valueref()
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
script "CoreExecutionUQL"
2+
/*
3+
Copyright (C) 2018 LiveCode Ltd.
4+
5+
This file is part of LiveCode.
6+
7+
LiveCode is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License v3 as published by the Free
9+
Software Foundation.
10+
11+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+
on TestUQLPut
20+
put "foo" into tTest1
21+
TestAssert "unquoted literal put into", tTest1 is "foo"
22+
put "foo" after tTest2
23+
TestAssert "unquoted literal put after", tTest2 is "foo"
24+
put "foo" before tTest3
25+
TestAssert "unquoted literal put before", tTest3 is "foo"
26+
end TestUQLPut
27+
28+
on TestUQLValue
29+
TestAssert "unquoted literal value", tTest1 is "tTest1"
30+
end TestUQLValue
31+
32+
on TestUQLMatchText
33+
put "rangeInt={0,3}" into tVar
34+
get matchText(tVar,"(.*?)={(.*?)}", tOption, tValue)
35+
TestAssert "matchText assigns correct values to UQL", \
36+
tOption is "rangeInt" and tValue is "0,3"
37+
end TestUQLMatchText
38+
39+
on TestUQLBinaryDecode
40+
get binaryDecode("h*",sha1Digest("foobar"), tFoobar)
41+
TestAssert "binaryDecode assigns correct values to UQL", \
42+
tFoobar is "88347d9f426112d19ebe9b36ffc42e1852398287"
43+
end TestUQLBinaryDecode
44+
45+
on TestUQLQueryRegistry
46+
TestSkipIfNot "platform", "win32"
47+
get queryRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir", tType)
48+
TestAssert "queryRegistry assigns correct values to UQL", \
49+
tType is "string"
50+
end TestUQLQueryRegistry

0 commit comments

Comments
 (0)