Skip to content
Prev 18536 / 63424 Next

problem with \eqn (PR#8322)

Kurt Hornik wrote:
Apologies - the problem is with this section of "share/perl/R/Rdconv.pm"
around line 400 - it basically doesn't try very hard dealing with nested 
brackets.

=======================
## Get the arguments of a command.
sub get_arguments {
     my ($command, $text, $nargs) = @_;
     ## Arguments of get_arguments:
     ##  1, command: next occurence of 'command' is searched
     ##  2, text:    'text' is the text containing the command
     ##  3, nargs:   the optional number of arguments to be extracted;
     ##              default 1
     my @retval;
     ## Returns a list with the id of the last closing bracket and the
     ## arguments.

     if($text =~ /\\($command)(\[[^\]]+\])?($ID)/){
         $id = $3;
         $text =~ /$id(.*)$id/s;
         $retval[1] = $1;
         my $k=2;
         while(($k<=$nargs) && ($text =~ /$id($ID)/)){
             $id = $1;
             $text =~ /$id\s*(.*)$id/s;
             $retval[$k++] = $1;
         }
     }
     $retval[0] = $id;
     @retval;
}
==================

HT