feat: add length parameters to wrenStringConcat and implement Boyer-Moore-Horspool string search
Add explicit length parameters to wrenStringConcat to support binary-safe string concatenation, with -1 sentinel for automatic strlen calculation. Implement wrenStringFind using Boyer-Moore-Horspool algorithm for efficient substring search, returning UINT32_MAX when needle not found. Update all callers in wren_core.c validation functions and wren_value.c metaclass creation to pass length arguments. Extend string/index_of.wren tests with edge cases including empty needle, full match, and complex overlapping patterns.
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
IO.print("abcd".indexOf("")) // expect: 0
|
||||
IO.print("abcd".indexOf("cd")) // expect: 2
|
||||
IO.print("abcd".indexOf("a")) // expect: 0
|
||||
IO.print("abcd".indexOf("abcd")) // expect: 0
|
||||
IO.print("abcd".indexOf("abcde")) // expect: -1
|
||||
IO.print("abab".indexOf("ab")) // expect: 0
|
||||
|
||||
// More complex cases.
|
||||
IO.print("abcdefabcdefg".indexOf("defg")) // expect: 9
|
||||
IO.print("abcdabcdabcd".indexOf("dab")) // expect: 3
|
||||
IO.print("abcdabcdabcdabcd".indexOf("dabcdabc")) // expect: 3
|
||||
IO.print("abcdefg".indexOf("abcdef!")) // expect: -1
|
||||
|
||||
// Non-ASCII. Note that it returns byte indices, not code points.
|
||||
IO.print("søméஃthîng".indexOf("e")) // expect: -1
|
||||
IO.print("søméஃthîng".indexOf("m")) // expect: 3
|
||||
|
||||
Reference in New Issue
Block a user