From be51b31a8d9cc06a32dc6903bec86fe457bd837a Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:35:08 +0800 Subject: [PATCH] bc: remove non-standard '**' operator (#518) * In yylex(), '^' and '**' are both tokenised as $EXP * Also, '^=' and '**=' are both tokenised as $EXP_EQ * Operators '**' and '**=' are not part of standard bc grammar so remove them [1] * Tested against GNU, OpenBSD and Gavin Howard versions of bc 1. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html Example input: 2 ^ 8 a = 2 a ^= 8 a --- bin/bc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bin/bc b/bin/bc index bd86ef6e..bff8d7b1 100755 --- a/bin/bc +++ b/bin/bc @@ -2224,13 +2224,10 @@ sub yylex $IDENT; } - } elsif (($char eq '*' && $line =~ s/^\*=//) or - ($char eq '^' && $line =~ s/=//)) { + } elsif ($char eq '^' && $line =~ s/=//) { $EXP_EQ; - } elsif (($char eq '*' && $line =~ s/^\*//) or - ($char eq '^')) { + } elsif ($char eq '^') { $EXP; - } elsif ($char eq '|' && $line =~ s/^\|//) { $O_O; } elsif ($char eq '&' && $line =~ s/^&//) {