--- loncom/xml/run.pm 2003/06/09 21:37:54 1.37 +++ loncom/xml/run.pm 2003/11/09 01:17:35 1.42 @@ -1,6 +1,6 @@ package Apache::run; # -# $Id: run.pm,v 1.37 2003/06/09 21:37:54 albertel Exp $ +# $Id: run.pm,v 1.42 2003/11/09 01:17:35 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,7 +38,6 @@ ENDEVALUATE sub evaluate { my ($expression,$safeeval,$decls) = @_; - &Apache::lonxml::debug("got $expression and decls $decls"); unless (defined($expression)) { return ''; } if ($Apache::lonxml::evaluate < 1) { return $expression; } my $result = ''; @@ -99,10 +98,18 @@ sub run { $error = 'Code ran too long. It ran for more than '. Apache->request->server->timeout.' seconds'; } - &Apache::lonxml::error('
'.&HTML::Entities::encode($error).' '. - &HTML::Entities::encode($innererror). - 'occured while running
'. - &HTML::Entities::encode($code).''); + my $errormsg='
'.&HTML::Entities::encode($error).' '. + &HTML::Entities::encode($innererror). + 'occured while running
'; + $code=&HTML::Entities::encode($code); + if ($innererror=~/line (\d+)/) { + my $linenumber=$1; + my @code=split("\n",$code); + $code[$linenumber-1]=''. + $code[$linenumber-1].''; + $code=join("\n",@code); + } + &Apache::lonxml::error($errormsg.$code.''); } if ( $#result < '1') { return $result[0]; @@ -113,29 +120,29 @@ sub run { } sub dump { - my ($target,$safeeval)=@_; - my $dump=''; - foreach my $symname (sort keys %{$safeeval->varglob('main::')}) { - if (($symname!~/^\_/) && ($symname!~/\:$/)) { - my $line; - if ($safeeval->reval('defined($'.$symname.')')) { - $line='$'.$symname.'='.$safeeval->reval('$'.$symname); - } - if ($safeeval->reval('defined(@'.$symname.')')) { - $line='@'.$symname.'=('. - $safeeval->reval('join(",",@'.$symname.')').")"; - } - if ($safeeval->reval('defined(%'.$symname.')')) { - $line='%'.$symname.'=('; - $line.=$safeeval->reval('join(",",map { $_."=>".$'. - $symname.'{$_} } sort keys %'. - $symname.')').")" - } - if ($line ne '') { $dump.=&HTML::Entities::encode($line)."