ID:2519783
 
Resolved
Regression: The non-regex version of splittext() broke in 513.1493 as a result of changes made to accommodate splittext_char(). The result of this was that it left off the last item in the list.
BYOND Version:513.1493
Operating System:Windows 10 Home 64-bit
Web Browser:Firefox 69.0
Applies to:Dream Daemon
Status: Resolved (513.1495)

This issue has been resolved.
Descriptive Problem Summary:
Give splittext a string that would be split into three elements, but the function now does only return two.
Numbered Steps to Reproduce Problem:
1. Give splittext a string and delimiter
2. Determine how many elements you expect
3. Get one less
Code Snippet (if applicable) to Reproduce Problem:
// Substitutional function to temporarily fix the issue
/proc/split_text(var/string,var/delimiter,var/start=1,var/end=0,include_delimiters=0)
var/list/result = list()

var/previous = start
var/position = start

while(position = findtext(string, delimiter, previous))
result.Add(copytext(string, previous, position + include_delimiters ? 1 : 0))
previous = position + 1

result.Add(copytext(string, previous))

return result

world/New()
var/str = "blah,hah,heh,hoh"
var/delimit = ","
world.log << "splittext"
for (var/v in splittext(str, delimit))
world.log << v
world.log << "split_text"
for (var/v in split_text(str, delimit))
world.log << v


Expected Results:
blah
hah
heh
hoh


Actual Results:
blah
hah
heh


Does the problem occur:
Every time? Or how often?
Affects all projects I've touched with 513
In other games?
Yes
In other user accounts?
N/A
On other computers?
Unknown

When does the problem NOT occur?
By not using 513

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Anything earlier than 513 so far

Workarounds:
Using the split_text function as provided

// Substitutional function to temporarily fix the issue
/proc/split_text(var/string,var/delimiter,var/start=1,var/end=0,include_delimiters=0)
var/list/result = list()

var/previous = start
var/position = start

while(position = findtext(string, delimiter, previous))
result.Add(copytext(string, previous, position + include_delimiters ? 1 : 0))
previous = position + 1

result.Add(copytext(string, previous))

return result
Please edit your report to use the exact build number. "513" alone isn't valid in Beta Bugs.

One important reason I ask this is because I want to know if the behavior changed between 513.1492 and 513.1493.
Fair enough. My apologizes, the build I was using when this occurred was 513.1493.
Lummox JR resolved issue with message:
Regression: The non-regex version of splittext() broke in 513.1493 as a result of changes made to accommodate splittext_char(). The result of this was that it left off the last item in the list.