[LON-CAPA-cvs] cvs: loncom /xml lonxml.pm run.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 13 Jul 2004 19:12:46 -0000
albertel Tue Jul 13 15:12:46 2004 EDT
Modified files:
/loncom/xml lonxml.pm run.pm
Log:
- can't do this in a subroutine the $decls are my scoped and therefore not visibile in the subroutine, Need to move it back into the regexp, which mean enabling require opcode when doing run::evaluate might be able to get around this in a future release.
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.329 loncom/xml/lonxml.pm:1.330
--- loncom/xml/lonxml.pm:1.329 Tue Jul 13 14:13:46 2004
+++ loncom/xml/lonxml.pm Tue Jul 13 15:12:46 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.329 2004/07/13 18:13:46 sakharuk Exp $
+# $Id: lonxml.pm,v 1.330 2004/07/13 19:12:46 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -754,27 +754,6 @@
&Apache::lonxml::debug("Setting rndseed to $rndseed");
&Apache::run::run($safeinit,$safeeval);
- my $subroutine=<<'EVALUATESUB';
-sub __LC_INTERNAL_EVALUATE__ {
- my ($__LC__a,$__LC__b,$__LC__c)=@_;
- my $__LC__prefix;
- while(1){
- {
- use strict;
- no strict "vars";
- if (eval(defined(eval($__LC__a.$__LC__b)))) {
- return $__LC__prefix.eval($__LC__a.$__LC__b.$__LC__c);
- }
- }
- $__LC__prefix.=substr($__LC__a,0,1,"");
- if ($__LC__a!~/^(\$|&|\#)/) { last; }
- }
- return $__LC__prefix.$__LC__a.$__LC__b.$__LC__c;
-}
-EVALUATESUB
- $safeeval->permit("require");
- $safeeval->reval($subroutine);
- $safeeval->deny("require");
}
sub default_homework_load {
Index: loncom/xml/run.pm
diff -u loncom/xml/run.pm:1.46 loncom/xml/run.pm:1.47
--- loncom/xml/run.pm:1.46 Wed Mar 31 00:24:00 2004
+++ loncom/xml/run.pm Tue Jul 13 15:12:46 2004
@@ -1,6 +1,6 @@
package Apache::run;
#
-# $Id: run.pm,v 1.46 2004/03/31 05:24:00 albertel Exp $
+# $Id: run.pm,v 1.47 2004/07/13 19:12:46 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -46,7 +46,26 @@
# only match the above if there is not { [ ( coming up
# Why? (I.e. this fails &a(1)[2]
(?=[^\[\{\(]|$)/
- &__LC_INTERNAL_EVALUATE__($1,$2,$3)/sexg;
+ my ($__LC__a,$__LC__b,$__LC__c)=($1,$2,$3);
+ my $__LC__prefix;
+ my $result;
+ while (1) {
+ {
+ use strict;
+ no strict "vars";
+ if (eval(defined(eval($__LC__a.$__LC__b)))) {
+ $result= $__LC__prefix.eval($__LC__a.$__LC__b.$__LC__c);
+ last;
+ }
+ }
+ $__LC__prefix.=substr($__LC__a,0,1,"");
+ if ($__LC__a!~m-^(\$|&|\#)-) { last; }
+ }
+ if (!defined($result)) {
+ $result=$__LC__prefix.$__LC__a.$__LC__b.$__LC__c;
+ }
+ $result;
+ /sexg;
if (scalar(values(%_LONCAPA_INTERNAL_oldexpressions))>10) {last;}
}
ENDEVALUATE
@@ -63,6 +82,7 @@
die("timeout");
};
my $innererror;
+ $safeeval->permit("require");
eval {
alarm($Apache::lonnet::perlvar{'lonScriptTimeout'});
$safeeval->reval('{'.$decls.';$_=<<\'EXPRESSION\';'."\n".$expression.
@@ -70,6 +90,7 @@
$innererror=$@;
alarm(0);
};
+ $safeeval->deny("require");
my $error=$@;
if ($error eq '' && $innererror eq '' && !$Apache::run::timeout) {
$result = $safeeval->reval('return $_;');