forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatchtext.livecodescript
More file actions
38 lines (29 loc) · 1018 Bytes
/
Copy pathmatchtext.livecodescript
File metadata and controls
38 lines (29 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
script "CoreStringsMatchText"
-- Bug 16: Ensure that very deeply recursive regular expressions do
-- not cause a stack overflow in libpcre
constant kRecursionExpr = "x(?R)?"
constant kRecursionLength = 16384
on TestMatchTextRecursion
-- Build a suitably long string
local tTarget
put "x" into tTarget
repeat
if length(tTarget) >= kRecursionLength then
delete char (1+kRecursionLength) to -1 of tTarget
exit repeat
end if
put tTarget after tTarget
end repeat
get matchText(tTarget, kRecursionExpr)
end TestMatchTextRecursion
on TestMatchTextMultipleMatches
local tFound
repeat for each item tItem in "a1,b1,a2,a3,a4,a5,a0"
get matchText(tItem, "a([0-9])", tFound)
end repeat
TestAssert "check that tFound is not empty", tFound is 0
repeat for each item tItem in "c1,c2,c3,c4"
get matchText(tItem, "a([0-9])", tFound)
end repeat
TestAssert "check that tFound is empty", tFound is 0
end TestMatchTextMultipleMatches