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

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 18 Jun 2003 17:35:14 -0000


matthew		Wed Jun 18 13:35:14 2003 EDT

  Modified files:              
    /loncom/interface/spreadsheet	Spreadsheet.pm 
  Log:
  Attempt to fix bug 1635.  Errors in quoting of parameters caused errors.
  
  
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.13 loncom/interface/spreadsheet/Spreadsheet.pm:1.14
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.13	Wed Jun 18 11:32:37 2003
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Wed Jun 18 13:35:14 2003
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.13 2003/06/18 15:32:37 matthew Exp $
+# $Id: Spreadsheet.pm,v 1.14 2003/06/18 17:35:14 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -816,30 +816,32 @@
         #    4. If there is a collision, return 'bad parameter name error'
         my $returnvalue = '';
         my @matches = ();
+        my @values = ();
         $#matches = -1;
         study $expression;
-        my $parameter;
-        foreach $parameter (keys(%{$self->{'constants'}})) {
-            push @matches,$parameter if ($parameter =~ /$expression/);
+        while (my($parameter,$value) = each(%{$self->{'constants'}})) {
+            next if ($parameter !~ /$expression/);
+            push(@matches,$parameter);
+            push(@values,$value);
         }
         if (scalar(@matches) == 0) {
             $returnvalue = '""';#'"unmatched parameter: '.$parameter.'"';
         } elsif (scalar(@matches) == 1) {
             # why do we not do this lookup here, instead of delaying it?
-            $returnvalue = '$c{\''.$matches[0].'\'}';
+            $returnvalue = $values[0];
         } elsif (scalar(@matches) > 0) {
             # more than one match.  Look for a concise one
             $returnvalue =  "'non-unique parameter name : $expression'";
-            foreach (@matches) {
-                if (/^$expression$/) {
+            for (my $i=0; $i<=$#matches;$i++) {
+                if ($matches[$i] =~ /^$expression$/) {
                     # why do we not do this lookup here?
-                    $returnvalue = '$c{\''.$_.'\'}';
+                    $returnvalue = $values[$i];
                 }
             }
         } else {
             # There was a negative number of matches, which indicates 
             # something is wrong with reality.  Better warn the user.
-            $returnvalue = '"bizzare parameter: '.$parameter.'"';
+            $returnvalue = '"bizzare parameter: '.$expression.'"';
         }
         return $returnvalue;
     }