aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/bc.c2
-rwxr-xr-xtestsuite/bc.tests5
2 files changed, 7 insertions, 0 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index c5288102d..1e2ca8b83 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -2950,6 +2950,8 @@ static BC_STATUS zbc_lex_identifier(BcLex *l)
continue;
match:
// buf starts with keyword bc_lex_kws[i]
+ if (isalnum(buf[j]) || buf[j]=='_')
+ continue; // "ifz" does not match "if" keyword, "if." does
l->t.t = BC_LEX_KEY_1st_keyword + i;
if (!bc_lex_kws_POSIX(i)) {
s = bc_posix_error_fmt("%sthe '%.8s' keyword", "POSIX does not allow ", bc_lex_kws[i].name8);
diff --git a/testsuite/bc.tests b/testsuite/bc.tests
index e303cf6ae..d33f8c90a 100755
--- a/testsuite/bc.tests
+++ b/testsuite/bc.tests
@@ -76,6 +76,11 @@ testing "bc while(cond)<NL>" \
"8\n7\n6\n5\n4\n3\n2\n1\n9\n" \
"" "i=9;while(--i)\ni\n9"
+testing "bc ifz does not match if keyword" \
+ "bc" \
+ "1\n2\n2\n3\n" \
+ "" "ifz=1;ifz\n++ifz;ifz++\nifz"
+
testing "bc print 1,2,3" \
"bc" \
"123" \