From 4f8810a6936ca6cbfd6c4df593d19ade95284ed2 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Fri, 4 Sep 2020 20:19:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96splitS=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/file.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Zframework/file.lua b/Zframework/file.lua index 48ea3756..4ab6a06d 100644 --- a/Zframework/file.lua +++ b/Zframework/file.lua @@ -5,14 +5,14 @@ local toN,toS=tonumber,tostring local concat=table.concat local function splitS(s,sep) - local t,n={},1 - repeat - local p=find(s,sep)or #s+1 - t[n]=sub(s,1,p-1) - n=n+1 - s=sub(s,p+#sep) - until #s==0 - return t + local L={} + local p1,p2=1--start,target + while p1<=#s do + p2=find(s,sep,p1)or #s+1 + L[#L+1]=sub(s,p1,p2-1) + p1=p2+#sep + end + return L end local tabs={ [0]="", @@ -128,7 +128,6 @@ function FILE.saveUnlock() LOG.print(text.unlockSavingError..(mes or"unknown error"),color.red) end end - function FILE.loadData() local F=files.data if F:open("r")then