diff options
Diffstat (limited to 'compat53/module.lua')
-rw-r--r-- | compat53/module.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/compat53/module.lua b/compat53/module.lua index f278f13..56c9932 100644 --- a/compat53/module.lua +++ b/compat53/module.lua | |||
@@ -671,8 +671,8 @@ if lua_version < "5.3" then | |||
671 | ["\""] = "\\\"" | 671 | ["\""] = "\\\"" |
672 | } | 672 | } |
673 | 673 | ||
674 | local function addquoted(c) | 674 | local function addquoted(c, d) |
675 | return addqt[c] or string_format("\\%03d", c:byte()) | 675 | return (addqt[c] or string_format(d~="" and "\\%03d" or "\\%d", c:byte()))..d |
676 | end | 676 | end |
677 | 677 | ||
678 | function M.string.format(fmt, ...) | 678 | function M.string.format(fmt, ...) |
@@ -684,7 +684,7 @@ if lua_version < "5.3" then | |||
684 | if kind == "s" then | 684 | if kind == "s" then |
685 | args[i] = _G.tostring(args[i]) | 685 | args[i] = _G.tostring(args[i]) |
686 | elseif kind == "q" then | 686 | elseif kind == "q" then |
687 | args[i] = '"'..string_gsub(args[i], "[%z%c\\\"\n]", addquoted)..'"' | 687 | args[i] = '"'..string_gsub(args[i], "([%z%c\\\"\n])(%d?)", addquoted)..'"' |
688 | return lead.."%"..mods.."s" | 688 | return lead.."%"..mods.."s" |
689 | end | 689 | end |
690 | end | 690 | end |