From 2ce259304dcaac2649ecc0910d703ac820e82d55 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 1 Jan 2023 12:42:37 -0800 Subject: [PATCH] fix double-consume, add %! I discovered your tostring function for debugging, might as well make it reachable from fmt. I also realized I forgot to convert to using "p" when I introduced it so I fixed that --- chameleonic.p8 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index 8d8196c..ea33d55 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -41,6 +41,8 @@ end -- fake sprintf function -- %~ for literal "%" -- %v for param +-- %! for tostring(param) +-- which dumps tables function fmt(f, ...) local out, i = "", 1 for s in all(split(f,"%")) do @@ -51,9 +53,11 @@ function fmt(f, ...) local p = select(i,...) i+=1 if m == "v" then - out ..= select(i,...) + out ..= p + elseif m == "!" then + out ..= tostring(p) else - out ..= "(?!:"..m..":"..tostr(p)..")" + out ..= "(?!:"..m..":"..tostring(p)..")" end end out ..=sub(s,2)