Fix crash on expanding command line strings

This commit is contained in:
Maxime Coste 2018-03-18 04:58:15 +11:00
parent 0a2807e652
commit 7ba4ef897b
5 changed files with 8 additions and 1 deletions

View File

@ -168,6 +168,7 @@ void skip_blanks_and_comments(Reader& reader)
Token parse_percent_token(Reader& reader, bool throw_on_unterminated) Token parse_percent_token(Reader& reader, bool throw_on_unterminated)
{ {
kak_assert(*reader == '%');
++reader; ++reader;
const auto type_start = reader.pos; const auto type_start = reader.pos;
while (reader and iswalpha(*reader)) while (reader and iswalpha(*reader))
@ -340,7 +341,9 @@ String expand_impl(StringView str, const Context& context,
Codepoint c = *reader; Codepoint c = *reader;
if (c == '\\') if (c == '\\')
{ {
c = *++reader; if (not (++reader))
throw parse_error{"unterminated escape"};
c = *reader;
if (c == '%' or c == '\\') if (c == '%' or c == '\\')
{ {
res += reader.substr_from(beg); res += reader.substr_from(beg);

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
set global modelinefmt %{\}