Merge branch 'master' into 2-8

This commit is contained in:
2018-07-06 16:50:50 +02:00
2 changed files with 21 additions and 10 deletions

View File

@ -230,7 +230,7 @@ static void regsubst(const StreamFormat& fmt, StreamBuffer& buffer, size_t start
}
buffer.replace(start+c+ovector[0], l, s);
length += s.length() - l;
c += s.length();
c += ovector[0] + s.length();
if (n == fmt.prec) // max match reached
return;
}

View File

@ -512,20 +512,31 @@ Each time newline is read, line is incremented.
buffer(token));
return false;
}
if (c == '$' && buffer[-1] == '\\')
{
// quoted variable reference
// terminate string here and do variable in next pass
buffer[-1] = quote;
ungetc(c, file);
break;
}
buffer.append(c);
if (c == quote && buffer[-2] != '\\')
if (c == quote)
{
quote = false;
break;
}
if (c == '\\')
{
c = getc(file);
if (c == '$')
{
// quoted variable reference
// terminate string here and do variable in next pass
buffer[-1] = quote;
ungetc(c, file);
break;
}
if (c == EOF || c == '\n')
{
error(line, filename(), "Backslash at end of line: %s\n",
buffer(token));
return false;
}
buffer.append(c);
}
c = getc(file);
}
buffer.append('\0').append(&l, sizeof(l)); // append line number