elua: change xgettext lexer to never include delimiters and also expand \n escape sequence in short strings to actual newline (no other escapes get this treatment)
This commit is contained in:
parent
297f9a821a
commit
0e5f9bc151
|
@ -117,22 +117,25 @@ end
|
||||||
|
|
||||||
local read_string = function(ls)
|
local read_string = function(ls)
|
||||||
local delim = ls.current
|
local delim = ls.current
|
||||||
local buf = { delim }
|
local buf = {}
|
||||||
local c = next_char(ls)
|
local c = next_char(ls)
|
||||||
while c ~= delim do
|
while c ~= delim do
|
||||||
if not c then lex_error(ls, "unfinished string", "<eof>")
|
if not c then lex_error(ls, "unfinished string", "<eof>")
|
||||||
elseif c == "\n" or c == "\r" then
|
elseif c == "\n" or c == "\r" then
|
||||||
lex_error(ls, "unfinished string", tconc(buf))
|
lex_error(ls, "unfinished string", tconc(buf))
|
||||||
elseif c == "\\" then
|
elseif c == "\\" then
|
||||||
buf[#buf + 1] = c
|
c = next_char(ls)
|
||||||
buf[#buf + 1] = next_char(ls)
|
if c == "n" then
|
||||||
|
buf[#buf + 1] = "\n"
|
||||||
|
else
|
||||||
|
buf[#buf + 1] = "\\" .. c
|
||||||
|
end
|
||||||
c = next_char(ls)
|
c = next_char(ls)
|
||||||
else
|
else
|
||||||
buf[#buf + 1] = c
|
buf[#buf + 1] = c
|
||||||
c = next_char(ls)
|
c = next_char(ls)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
buf[#buf + 1] = c
|
|
||||||
next_char(ls)
|
next_char(ls)
|
||||||
return tconc(buf)
|
return tconc(buf)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue