From 11a6302c2d3a39843a839894d4646fd78e13b944 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat, 25 Jul 2026 09:53:37 -0500 Subject: [PATCH] Delegate pfUI.api.strsplit to ClassicAPI's strsplit Replace the Lua pattern-based implementation with a thin wrapper around ClassicAPI's C-level strsplit. Keeps the pfUI.api.strsplit entry point for backwards compatibility with addons that call it, while dropping the redundant reimplementation. Behavioral note: the old version used ([^delim]+) which silently collapsed empty fields; delegating to real strsplit now preserves them ("a,,b" -> "a", "", "b"). All in-repo callers split numeric color tuples, version strings, or build name-keyed lookup tables, none of which are affected by empty-field preservation. --- api/api.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/api/api.lua b/api/api.lua index b98a4e0b..9669b520 100644 --- a/api/api.lua +++ b/api/api.lua @@ -84,17 +84,18 @@ gfind = string.gmatch or string.gfind mod = math.mod or mod -- [ strsplit ] --- Splits a string using a delimiter. +-- Splits a string using a delimiter. Thin wrapper that delegates to +-- ClassicAPI's C-level strsplit, kept as a pfUI.api entry point for +-- backwards compatibility with addons that call pfUI.api.strsplit. +-- Note: unlike the old Lua implementation, empty fields are preserved +-- (e.g. "a,,b" -> "a", "", "b"), matching real strsplit semantics. -- 'delimiter' [string] characters that will be interpreted as delimiter -- characters (bytes) in the string. -- 'subject' [string] String to split. -- return: [list] a list of strings. function pfUI.api.strsplit(delimiter, subject) if not subject then return nil end - local delimiter, fields = delimiter or ":", {} - local pattern = string.format("([^%s]+)", delimiter) - string.gsub(subject, pattern, function(c) fields[table.getn(fields)+1] = c end) - return unpack(fields) + return _G.strsplit(delimiter or ":", subject) end -- [ isempty ]