Fix line counts on syntax errors.

This commit is contained in:
Jordan Bancino 2023-04-27 15:54:21 +00:00
parent 72467f6503
commit 6e976a2b8d

View file

@ -171,6 +171,10 @@ HeaderConsumeArg(HeaderExpr * expr)
{ {
block--; block--;
} }
else if (c == '\n')
{
expr->state.lineNo++;
}
} }
if (i >= len) if (i >= len)
@ -283,6 +287,10 @@ HeaderParse(Stream * stream, HeaderExpr * expr)
i++; i++;
expr->data.text[i] = c; expr->data.text[i] = c;
i++; i++;
if (c == '\n')
{
expr->state.lineNo++;
}
} }
} }
else else
@ -367,6 +375,7 @@ HeaderParse(Stream * stream, HeaderExpr * expr)
if (c == '\n') if (c == '\n')
{ {
expr->data.text[i] = '\0'; expr->data.text[i] = '\0';
expr->state.lineNo++;
break; break;
} }
else else
@ -439,6 +448,10 @@ HeaderParse(Stream * stream, HeaderExpr * expr)
{ {
block--; block--;
} }
else if (c == '\n')
{
expr->state.lineNo++;
}
if (block <= 0 && c == ';') if (block <= 0 && c == ';')
{ {
@ -514,10 +527,11 @@ HeaderParse(Stream * stream, HeaderExpr * expr)
expr->data.declaration.args = ArrayCreate(); expr->data.declaration.args = ArrayCreate();
do { do
word = HeaderConsumeArg(expr); {
ArrayAdd(expr->data.declaration.args, word); word = HeaderConsumeArg(expr);
word = NULL; ArrayAdd(expr->data.declaration.args, word);
word = NULL;
} }
while ((!StreamEof(expr->state.stream)) && ((c = HeaderConsumeWhitespace(expr)) != ')')); while ((!StreamEof(expr->state.stream)) && ((c = HeaderConsumeWhitespace(expr)) != ')'));