From 6e976a2b8df02b330330d3b5cec0278dc7e27c13 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Thu, 27 Apr 2023 15:54:21 +0000 Subject: [PATCH] Fix line counts on syntax errors. --- src/HeaderParser.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/HeaderParser.c b/src/HeaderParser.c index c020d95..959908f 100644 --- a/src/HeaderParser.c +++ b/src/HeaderParser.c @@ -171,6 +171,10 @@ HeaderConsumeArg(HeaderExpr * expr) { block--; } + else if (c == '\n') + { + expr->state.lineNo++; + } } if (i >= len) @@ -283,6 +287,10 @@ HeaderParse(Stream * stream, HeaderExpr * expr) i++; expr->data.text[i] = c; i++; + if (c == '\n') + { + expr->state.lineNo++; + } } } else @@ -367,6 +375,7 @@ HeaderParse(Stream * stream, HeaderExpr * expr) if (c == '\n') { expr->data.text[i] = '\0'; + expr->state.lineNo++; break; } else @@ -439,6 +448,10 @@ HeaderParse(Stream * stream, HeaderExpr * expr) { block--; } + else if (c == '\n') + { + expr->state.lineNo++; + } if (block <= 0 && c == ';') { @@ -514,10 +527,11 @@ HeaderParse(Stream * stream, HeaderExpr * expr) expr->data.declaration.args = ArrayCreate(); - do { - word = HeaderConsumeArg(expr); - ArrayAdd(expr->data.declaration.args, word); - word = NULL; + do + { + word = HeaderConsumeArg(expr); + ArrayAdd(expr->data.declaration.args, word); + word = NULL; } while ((!StreamEof(expr->state.stream)) && ((c = HeaderConsumeWhitespace(expr)) != ')'));