Prevent crash when using numbers as labels

Closes https://gitlab.com/luk3yx/minetest-flow/-/merge_requests/1
This commit is contained in:
luk3yx 2024-09-14 20:17:03 +12:00
parent e0626bdb42
commit 4563382551

View File

@ -29,14 +29,14 @@ local ceil, floor, min, max = math.ceil, math.floor, math.min, math.max
-- Estimates the width of a valid UTF-8 string, ignoring any escape sequences.
-- This function hopefully works with most (but not all) scripts, maybe it
-- could still be improved.
local byte = string.byte
local byte, strlen = string.byte, string.len
local LPAREN = byte("(")
local function naive_str_width(str)
local w = 0
local prev_w = 0
local line_count = 1
local i = 1
local str_length = #str
local str_length = strlen(str)
while i <= str_length do
local char = byte(str, i)
if char == 0x1b then