Mercurial > hg > octave-lyh
changeset 12958:ae88a81e5d5c
maint: periodic merge of stable to default
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 12 Aug 2011 14:16:34 -0400 |
parents | 332a97ea63ba (current diff) fb69561e5901 (diff) |
children | 0c86ae6f7c34 |
files | scripts/miscellaneous/private/__xzip__.m src/Makefile.am src/oct-parse.yy src/oct-stream.cc |
diffstat | 6 files changed, 46 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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);
--- 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
--- a/scripts/strings/str2num.m +++ b/scripts/strings/str2num.m @@ -17,7 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- 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)
--- 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) \
--- 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;