diff src/pt-idx.cc @ 9692:126b49caba0d

smart splitting of index chains
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 05 Oct 2009 10:42:58 +0200
parents c5f03874ea2a
children cd96d29c5efa
line wrap: on
line diff
--- a/src/pt-idx.cc	Mon Oct 05 10:20:18 2009 +0200
+++ b/src/pt-idx.cc	Mon Oct 05 10:42:58 2009 +0200
@@ -328,7 +328,14 @@
 	    {
 	      tree_argument_list *al = *p_args;
 
-	      if (al && al->has_magic_end ())
+              // In Matlab, () can only be followed by . In Octave, we do not
+              // enforce this for rvalue expressions, but we'll split the
+              // evaluation at this point. This will, hopefully, allow Octave's
+              // looser rules apply smoothly for Matlab overloaded subsref
+              // codes.
+              bool force_split = type[i-1] == '(' && type[i] != '.';
+
+	      if (force_split || (al && al->has_magic_end ()))
 		{
 		  // We have an expression like
 		  //
@@ -343,7 +350,7 @@
 		  const octave_value_list tmp_list
 		    = tmp.subsref (type.substr (tmpi, i - tmpi), idx, nargout);
 
-		  tmp = tmp_list(0);
+		  tmp = tmp_list.length () ? tmp_list(0) : octave_value ();
                   tmpi = i;
                   idx.clear ();