From d69d706376fb4ea7beb76bcc41d307f51c8bf1f7 Mon Sep 17 00:00:00 2001 From: Pavlina Moravcova Varekova Date: Wed, 25 Sep 2019 14:43:57 +0200 Subject: [PATCH] Add missing position marker to a few expression error messages --- rpmio/expression.c | 15 +++++++++------ tests/rpmmacro.at | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/rpmio/expression.c b/rpmio/expression.c index 94a7e47e63..9a0282a6db 100644 --- a/rpmio/expression.c +++ b/rpmio/expression.c @@ -434,6 +434,7 @@ static Value doTernary(ParseState state); static Value doPrimary(ParseState state) { Value v = NULL; + const char *p = state->p; DEBUG(printf("doPrimary()\n")); @@ -443,7 +444,7 @@ static Value doPrimary(ParseState state) goto err; v = doTernary(state); if (state->nextToken != TOK_CLOSE_P) { - exprErr(state, _("unmatched ("), NULL); + exprErr(state, _("unmatched ("), p); goto err; } if (rdToken(state)) @@ -466,7 +467,7 @@ static Value doPrimary(ParseState state) goto err; if (! valueIsInteger(v)) { - exprErr(state, _("- only on numbers"), NULL); + exprErr(state, _("- only on numbers"), p); goto err; } @@ -485,7 +486,7 @@ static Value doPrimary(ParseState state) break; case TOK_EOF: - exprErr(state, _("unexpected end of expression"), NULL); + exprErr(state, _("unexpected end of expression"), state->p); goto err; default: @@ -518,6 +519,7 @@ static Value doMultiplyDivide(ParseState state) while (state->nextToken == TOK_MULTIPLY || state->nextToken == TOK_DIVIDE) { int op = state->nextToken; + const char *p = state->p; if (rdToken(state)) goto err; @@ -539,7 +541,7 @@ static Value doMultiplyDivide(ParseState state) if ((state->flags & RPMEXPR_DISCARD) != 0) continue; /* just use v1 in discard mode */ if ((i2 == 0) && (op == TOK_DIVIDE)) { - exprErr(state, _("division by zero"), NULL); + exprErr(state, _("division by zero"), p); goto err; } if (op == TOK_MULTIPLY) @@ -547,7 +549,7 @@ static Value doMultiplyDivide(ParseState state) else valueSetInteger(v1, i1 / i2); } else { - exprErr(state, _("* and / not supported for strings"), NULL); + exprErr(state, _("* and / not supported for strings"), p); goto err; } } @@ -576,6 +578,7 @@ static Value doAddSubtract(ParseState state) while (state->nextToken == TOK_ADD || state->nextToken == TOK_MINUS) { int op = state->nextToken; + const char *p = state->p; if (rdToken(state)) goto err; @@ -602,7 +605,7 @@ static Value doAddSubtract(ParseState state) char *copy; if (op == TOK_MINUS) { - exprErr(state, _("- not supported for strings"), NULL); + exprErr(state, _("- not supported for strings"), p); goto err; } diff --git a/tests/rpmmacro.at b/tests/rpmmacro.at index 89ab9c77de..448af3925e 100644 --- a/tests/rpmmacro.at +++ b/tests/rpmmacro.at @@ -332,9 +332,11 @@ error: ^ error: syntax error while parsing ==: "a"=!"b" error: ^ error: unexpected end of expression: 4+ +error: ^ error: bare words are no longer supported, please use "...": bare error: ^ error: division by zero: 1/0 +error: ^ error: types must match: 0 < 1 ? 2 : 1*"a" error: types must match: 0 < 1 ? 1*"a" : 2 error: types must match: 0 < 1 ? 2 : "a"