[LON-CAPA-cvs] cvs: loncom /interface lonspreadsheet.pm

www lon-capa-cvs@mail.lon-capa.org
Fri, 05 Jul 2002 21:44:50 -0000


www		Fri Jul  5 17:44:50 2002 EDT

  Modified files:              
    /loncom/interface	lonspreadsheet.pm 
  Log:
  share('$@') magically activated the eval error checking in a test program
  (thanks Matthew!), but apparently still not here.
  
  Test program:
  
  use strict;
  use Safe;
  
  my $stuff=(<<'ENDSTUFF');
  my $a=5;
  my $b=0;
  
  my $c=eval '$a/$b';
  return 'Oops '.$@;
  ENDSTUFF
  
  my $se=new Safe;
  $se->permit("entereval");
  $se->share('$@');
  
  print $se->reval($stuff)."\n";
  print eval($stuff)."\n";
  
  
  
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.95 loncom/interface/lonspreadsheet.pm:1.96
--- loncom/interface/lonspreadsheet.pm:1.95	Thu Jul  4 21:31:25 2002
+++ loncom/interface/lonspreadsheet.pm	Fri Jul  5 17:44:50 2002
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.95 2002/07/05 01:31:25 www Exp $
+# $Id: lonspreadsheet.pm,v 1.96 2002/07/05 21:44:50 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -112,6 +112,7 @@
 
 my %starttimes;
 my %usedtimes;
+my %numbertimes;
 
 # Stuff that only the screen handler can know
 
@@ -129,6 +130,7 @@
     $safeeval->permit("sort");
     $safeeval->deny(":base_io");
     $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
+    $safeeval->share('$@');
     my $code=<<'ENDDEFS';
 # ---------------------------------------------------- Inside of the safe space
 
@@ -835,15 +837,14 @@
     &sett();
     my $notfinished=1;
     my $depth=0;
-    my $errormsg;
     while ($notfinished) {
 	$notfinished=0;
         foreach (keys(%t)) {
             my $old=$v{$_};
-            $v{$_}=eval($t{$_});
+            $v{$_}=eval $t{$_};
 	    if ($@) {
-		$v{$_}='"error"';
-                $errormsg.=$_.': '.$@."\n";
+		undef %v;
+                return $_.': '.$@;
             }
 	    if ($v{$_} ne $old) { $notfinished=1; }
         }
@@ -853,7 +854,7 @@
             return 'Maximum calculation depth exceeded';
         }
     }
-    return $errormsg;
+    return '';
 }
 
 sub templaterow {