# HG changeset patch # User jwe # Date 1095865543 0 # Node ID 4da942f0b76f647013042a100a4cb7e4c7bfa9df # Parent 2a0e2daac9970f30116716634cab2a80ef282c6e [project @ 2004-09-22 15:05:43 by jwe] diff -r 2a0e2daac997 -r 4da942f0b76f src/ChangeLog --- 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 + + * 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 * DLD-FUNCTIONS/qz.cc (Fqz): New @tex section(s) in doc string for diff -r 2a0e2daac997 -r 4da942f0b76f src/ov-fcn-inline.cc --- 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 ()) {