Log Message:
-----------
Fixed log and log10 perl methods so that log obeys the useBaseTenLog
flag, and log10 doesn't try to call main::log10, which is not
available from within this preloaded package. The in- and outside
the safe compartment stuff is very confusing, and functions that are
not overloaded native perl functions seem to be not callable from the
Value::Formula package, so the perl method now calls
Parser::Function->call() directly (doesn't look pretty, but I've given
up on that).
Modified Files:
--------------
pg/lib/Parser:
Function.pm
pg/lib/Parser/Function:
numeric.pm
Revision Data
-------------
Index: Function.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Parser/Function.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -Llib/Parser/Function.pm -Llib/Parser/Function.pm -u -r1.14 -r1.15
--- lib/Parser/Function.pm
+++ lib/Parser/Function.pm
@@ -281,9 +281,10 @@
#
sub perl {
my $self = shift; my $parens = shift;
- my $fn = $self->{def}; my @p = ();
+ my $fn = $self->{def}; my @p = (); my $perl;
foreach my $x (@{$self->{params}}) {push(@p,$x->perl)}
- my $perl = ($fn->{perl}? $fn->{perl} : $self->{name}).'('.join(',',@p).')';
+ if ($fn->{perl}) {$perl = $fn->{perl}.'('.join(',',@p).')'}
+ else {$perl = 'Parser::Function->call('.join(',',"'$self->{name}'",@p).')'}
$perl = '('.$perl.')' if $parens == 1;
return $perl;
}
Index: numeric.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Parser/Function/numeric.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -Llib/Parser/Function/numeric.pm -Llib/Parser/Function/numeric.pm -u -r1.5 -r1.6
--- lib/Parser/Function/numeric.pm
+++ lib/Parser/Function/numeric.pm
@@ -69,6 +69,17 @@
return '\left|'.$self->{params}[0]->TeX.'\right|' if $self->{name} eq 'abs';
return $self->SUPER::TeX(@_);
}
+#
+# Handle log (and useBaseTenLog) as a special case
+#
+sub perl {
+ my $self = shift; my $context;
+ $context = $self->{context} if ref($self);
+ $context = $$Value::context unless $context;
+ return $self->SUPER::perl
+ unless $self->{name} eq 'log' && $context->flag('useBaseTenLog');
+ '(log('.$self->{params}[0]->perl.')/log(10))';
+}
#########################################################################
|