From cb6d811ba2cc9084e67587fecd4da2606a678fb5 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 24 Mar 2014 03:05:48 +0000 Subject: [PATCH] Minor improvements to math.pl --- PBot/VERSION.pm | 2 +- modules/math.pl | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index d1fa562d..a8c5258c 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 532, + BUILD_REVISION => 533, BUILD_DATE => "2014-03-23", }; diff --git a/modules/math.pl b/modules/math.pl index eca5783e..82d9e7d2 100755 --- a/modules/math.pl +++ b/modules/math.pl @@ -7,7 +7,7 @@ my ($arguments, $response, $invalid); my @valid_keywords = ( 'sin', 'cos', 'tan', 'atan', 'exp', 'int', 'hex', 'oct', 'log', 'sqrt', 'floor', 'ceil', 'asin', 'acos', 'log10', 'sinh', 'cosh', 'tanh', 'abs', - 'pi' + 'pi', 'deg2rad', 'rad2deg', 'atan2' ); if ($#ARGV < 0) @@ -18,11 +18,12 @@ if ($#ARGV < 0) $arguments = join(' ', @ARGV); -if($arguments =~ m/([\$`\|])/) { +if($arguments =~ m/([\$`\|{}"'#@=])/) { $invalid = $1; } else { - while($arguments =~ /([a-zA-Z]+)/g) { + while($arguments =~ /([a-zA-Z0-9]+)/g) { my $keyword = $1; + next if $keyword =~ m/^[0-9]$/; $invalid = $keyword and last if not grep { /^$keyword$/ } @valid_keywords; } } @@ -32,12 +33,13 @@ if($invalid) { exit 1; } -$response = eval("use POSIX qw/ceil floor/; use Math::Complex;" . $arguments); +$response = eval("use POSIX qw/ceil floor/; use Math::Trig; use Math::Complex;" . $arguments); if($@) { my $error = $@; $error =~ s/ at \(eval \d+\) line \d+.//; $error =~ s/[\n\r]+//g; + $error =~ s/Died at .*//; print $error; exit 1; }