changeset 5022:4da942f0b76f

[project @ 2004-09-22 15:05:43 by jwe]
author jwe
date Wed, 22 Sep 2004 15:05:43 +0000
parents 2a0e2daac997
children 89814b22b729
files src/ChangeLog src/ov-fcn-inline.cc
diffstat 2 files changed, 32 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Sep 22 12:45:09 2004 +0000
+++ b/src/ChangeLog	Wed Sep 22 15:05:43 2004 +0000
@@ -1,3 +1,8 @@
+2004-09-22  David Bateman  <dbateman@free.fr>
+
+	* ov-fcn-inline.cc (Finline): When called with a single arg, derive
+	argument of inline function in a compatible manner.
+
 2004-09-22  Federico Zenith  <zenith@chemeng.ntnu.no>
 
 	* DLD-FUNCTIONS/qz.cc (Fqz): New @tex section(s) in doc string for
--- a/src/ov-fcn-inline.cc	Wed Sep 22 12:45:09 2004 +0000
+++ b/src/ov-fcn-inline.cc	Wed Sep 22 15:05:43 2004 +0000
@@ -575,8 +575,10 @@
 @deftypefnx {Built-in Function} {} inline (@var{str}, @var{n})\n\
 Create an inline function from the character string @var{str}.\n\
 If called with a single argument, the generated function is\n\
-assumed to have a single argument and will be defined\n\
-as the first isolated lower case character, except i or j.\n\
+assumed to have a single argument and will be defined as the\n\
+isolated lower case character, except i or j, that is closest\n\
+to x. If more than argument is the same distance from x, the\n\
+one later in the alphabet is chosen.\n\
 \n\
 If the second and subsequent arguments are character strings,\n\
 they are the names of the arguments of the function.\n\
@@ -600,13 +602,32 @@
 
 	  if (nargin == 1)
 	    {
+	      int dist = -1;
+	      char c;
+
 	      fargs.resize (1);
+	      fargs(0) = "x";
 
-	      // Find the first isolated string as the argument of the
-	      // function.
+	      for (int i = 0; i < fun.length(); i++)
+		{
+		  if (islower (fun [i]) && 
+		      (i == 0 ? true : !islower (fun [i-1])) &&
+		      (i == fun.length() ? true : !islower (fun [i+1])))
+		    {
+		      char new_c = fun [i];
 
-	      // XXX FIXME XXX -- use just "x" for now.
-	      fargs(0) = "x";
+		      if (new_c == 'i' || new_c == 'j') 
+			continue;
+		      int new_dist = std::abs(new_c - 'x');
+		      if (dist == -1 || (new_dist < dist) ||
+			  ((new_dist == dist) && (c < new_c)))
+			{
+			  fargs(0) = new_c;
+			  dist = new_dist;
+			  c = new_c;
+			}
+		    }
+		}
 	    }
 	  else if (nargin == 2 && args(1).is_numeric_type ())
 	    {