# HG changeset patch # User John W. Eaton # Date 1313172994 14400 # Node ID ae88a81e5d5ccae495b1f333d83172c8727485ba # Parent 332a97ea63baf6d664e0e5cfefb9bfc24ba73bed# Parent fb69561e5901e6b9d1e6117d8a42eb81d4f4d0e1 maint: periodic merge of stable to default diff --git a/doc/interpreter/oop.txi b/doc/interpreter/oop.txi --- a/doc/interpreter/oop.txi +++ b/doc/interpreter/oop.txi @@ -578,8 +578,8 @@ @item @tab a / b @tab mrdivide (a, b) @tab Matrix right division operator @tab @item @tab a .\ b @tab ldivide (a, b) @tab Element-wise left division operator @tab @item @tab a \ b @tab mldivide (a, b) @tab Matrix left division operator @tab -@item @tab a .^ b @tab ldivide (a, b) @tab Element-wise power operator @tab -@item @tab a ^ b @tab mldivide (a, b) @tab Matrix power operator @tab +@item @tab a .^ b @tab power (a, b) @tab Element-wise power operator @tab +@item @tab a ^ b @tab mpower (a, b) @tab Matrix power operator @tab @item @tab a < b @tab lt (a, b) @tab Less than operator @tab @item @tab a <= b @tab le (a, b) @tab Less than or equal to operator @tab @item @tab a > b @tab gt (a, b) @tab Greater than operator @tab diff --git a/scripts/miscellaneous/private/__xzip__.m b/scripts/miscellaneous/private/__xzip__.m --- a/scripts/miscellaneous/private/__xzip__.m +++ b/scripts/miscellaneous/private/__xzip__.m @@ -80,14 +80,16 @@ commandname, status); endif - if (nargout > 0) - if (nargin == 5) + if (nargin == 5) + if (nargout > 0) entries = cellfun( @(x) fullfile (outdir, sprintf ("%s.%s", x, extension)), f, "uniformoutput", false); - else - movefile (cellfun(@(x) sprintf ("%s.%s", x, extension), f, - "uniformoutput", false), cwd); + endif + else + movefile (cellfun(@(x) sprintf ("%s.%s", x, extension), f, + "uniformoutput", false), cwd); + if (nargout > 0) ## FIXME this does not work when you try to compress directories entries = cellfun(@(x) sprintf ("%s.%s", x, extension), files, "uniformoutput", false); diff --git a/scripts/miscellaneous/tar.m b/scripts/miscellaneous/tar.m --- a/scripts/miscellaneous/tar.m +++ b/scripts/miscellaneous/tar.m @@ -42,7 +42,7 @@ files = cellstr (files); endif - if (ischar (tarfile) && iscellstr (files) && ischar (root)) + if (! (ischar (tarfile) && iscellstr (files) && ischar (root))) error ("tar: all arguments must be character strings"); endif diff --git a/scripts/strings/str2num.m b/scripts/strings/str2num.m --- a/scripts/strings/str2num.m +++ b/scripts/strings/str2num.m @@ -17,7 +17,8 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} str2num (@var{s}) +## @deftypefn {Function File} {@var{x} =} str2num (@var{s}) +## @deftypefnx {Function File} {[@var{x}, @var{state}] =} str2num (@var{s}) ## Convert the string (or character array) @var{s} to a number (or an ## array). Examples: ## @@ -33,6 +34,10 @@ ## @end group ## @end example ## +## The optional second output, @var{state}, is logically true when the +## coversion is successful. If the conversion fails the numeric output, +## @var{n}, is empty and @var{state} is false. +## ## @strong{Caution:} As @code{str2num} uses the @code{eval} function ## to do the conversion, @code{str2num} will execute any code contained ## in the string @var{s}. Use @code{str2double} instead if you want to @@ -42,16 +47,18 @@ ## Author: jwe -function m = str2num (s) +function [m, state] = str2num (s) if (nargin == 1 && ischar (s)) [nr, nc] = size (s); sep = ";"; sep = sep (ones (nr, 1), 1); s = sprintf ("m = [%s];", reshape ([s, sep]', 1, nr * (nc + 1))); - eval (s, "m = [];"); + state = true; + eval (s, "m = []; state = false;"); if (ischar (m)) m = []; + state = false; endif else print_usage (); @@ -65,3 +72,8 @@ %!error str2num ("string", 1); +%!test +%! [x, state] = str2num ("pi"); +%! assert (state) +%! [x, state] = str2num (tmpnam); +%! assert (! state) diff --git a/src/Makefile.am b/src/Makefile.am --- a/src/Makefile.am +++ b/src/Makefile.am @@ -541,7 +541,7 @@ ../libcruft/libcruft.la \ ../libcruft/libranlib.la \ ../libgnu/libgnu.la \ - $(FFTW_XLDFLAGS) $(FFTW_XLIBS) + $(FFTW_XLDFLAGS) $(FFTW_XLIBS) \ $(QHULL_LDFLAGS) $(QHULL_LIBS) \ $(QRUPDATE_LDFLAGS) $(QRUPDATE_LIBS) \ $(SPARSE_XLDFLAGS) $(SPARSE_XLIBS) \ diff --git a/src/oct-parse.yy b/src/oct-parse.yy --- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -4215,12 +4215,26 @@ @noindent\n\ calls the function @code{acos} with the argument @samp{-1}.\n\ \n\ -The function @code{feval} is necessary in order to be able to write\n\ -functions that call user-supplied functions, because Octave does not\n\ -have a way to declare a pointer to a function (like C) or to declare a\n\ -special kind of variable that can be used to hold the name of a function\n\ -(like @code{EXTERNAL} in Fortran). Instead, you must refer to functions\n\ -by name, and use @code{feval} to call them.\n\ +The function @code{feval} can also be used with function handles of\n\ +any sort. @xref{Function Handles} Historically, @code{feval} was\n\ +the only way to call user-supplied functions in strings, but\n\ +function handles are now preferred due to the cleaner syntax they\n\ +offer. For example,\n\ +\n\ +@example\n\ +@group\n\ +@var{f} = @@exp;\n\ +feval (@var{f}, 1)\n\ + @result{} 2.7183\n\ +@var{f} (1)\n\ + @result{} 2.7183\n\ +@end group\n\ +@end example\n\ +\n\ +@noindent\n\ +are equivalent ways to call the function referred to by @var{f}. If it\n\ +cannot be predicted beforehand that @var{f} is a function handle or the\n\ +function name in a string, @code{feval} can be used instead.\n\ @end deftypefn") { octave_value_list retval; diff --git a/src/oct-stream.cc b/src/oct-stream.cc