Skip to content

Commit

Permalink
Add newlines in string.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakpakin committed Sep 20, 2018
1 parent 9331bba commit 9f5c280
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fennel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ local function parser(getbyte, filename)
until not b or (state == "done")
if not b then parseError('unexpected end of source') end
local raw = string.char(unpack(chars))
local loadFn = loadCode(('return %s'):format(raw), nil, filename)
local formatted = raw:gsub("[\1-\31]", function (c) return '\\' .. c:byte() end)
local loadFn = loadCode(('return %s'):format(formatted), nil, filename)
dispatch(loadFn())
else -- Try symbol
local chars = {}
Expand Down
1 change: 1 addition & 0 deletions test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ local cases = {
["\"abc\\\"def\""]="abc\"def",
["\'abc\\\"\'"]="abc\"",
["\"abc\\240\""]="abc\240",
["\"abc\n\\240\""]="abc\n\240",
},

functions = {
Expand Down

0 comments on commit 9f5c280

Please sign in to comment.