WIP: sprintf #21
| @@ -39,14 +39,13 @@ function cycle(tbl,period) | |||||||
| end | end | ||||||
|  |  | ||||||
| -- fake sprintf function | -- fake sprintf function | ||||||
| -- %% for literal "%" | -- %~ for literal "%" | ||||||
| -- %v for param | -- %v for param | ||||||
|  | function fmt(f, ...) | ||||||
| function sprintf(fmt, ...) |  | ||||||
|  local out, i = "", 1 |  local out, i = "", 1 | ||||||
|  for s in all(split(fmt,"%")) do |  for s in all(split(f,"%")) do | ||||||
|   local m = s[1] |   local m = s[1] | ||||||
|   if m == "%" then |   if m == "~" then | ||||||
|    out ..= "%" |    out ..= "%" | ||||||
|   else |   else | ||||||
|    local p = select(i,...) |    local p = select(i,...) | ||||||
| @@ -56,6 +55,7 @@ function sprintf(fmt, ...) | |||||||
|    else |    else | ||||||
|     out ..= "(?!:"..m..":"..tostr(p)..")" |     out ..= "(?!:"..m..":"..tostr(p)..")" | ||||||
|    end |    end | ||||||
|  |   end | ||||||
|   out ..=sub(s,2) |   out ..=sub(s,2) | ||||||
|  end |  end | ||||||
|  return out |  return out | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user