Mercurial > hg > octave-jordi
changeset 1031:59f5eb2d5eb3
[project @ 1995-01-15 21:11:11 by jwe]
author | jwe |
---|---|
date | Sun, 15 Jan 1995 21:11:11 +0000 |
parents | cfa5473c5f96 |
children | eb788d2f49c2 |
files | src/data.cc src/lex.l src/pt-exp-base.cc |
diffstat | 3 files changed, 31 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/data.cc +++ b/src/data.cc @@ -592,17 +592,23 @@ return retval; } -DEFUN ("size", Fsize, Ssize, 1, 1, - "[m, n] = size (x): return rows and columns of X") +DEFUN ("size", Fsize, Ssize, 2, 1, +[m, n] = size (x): return rows and columns of X\n\ +\n\ +d = size (x): return number of rows and columns of x as a row vector\n\ +\n\ +m = size (x, 1): return number of rows in x\n\ +m = size (x, 2): return number of columns in x") { Octave_object retval; int nargin = args.length (); - if (nargin == 1 && args(0).is_defined ()) + if (nargin == 1 && nargout < 3) { int nr = args(0).rows (); int nc = args(0).columns (); + if (nargout == 0 || nargout == 1) { Matrix m (1, 2); @@ -615,8 +621,22 @@ retval(1) = (double) nc; retval(0) = (double) nr; } + } + else if (nargin == 2 && nargout < 2) + { + int nd = NINT (args(1).double_value ()); + + if (error_state) + error ("size: expecting scalar as second argument"); else - print_usage ("size"); + { + if (nd == 1) + retval(0) = (double) (args(0).rows ()); + else if (nd == 2) + retval(0) = (double) (args(0).columns ()); + else + error ("size: invalid second argument -- expecting 1 or 2"); + } } else print_usage ("size");
--- a/src/lex.l +++ b/src/lex.l @@ -1526,7 +1526,7 @@ ostrstream buf; int c; - int prev = 0; + int escape_pending = 0; while ((c = yyinput ()) != EOF) { @@ -1536,13 +1536,14 @@ { if (! have_continuation ()) buf << (char) c; - goto next; + + escape_pending = ! escape_pending; + continue; } else if (c == '.') { if (! have_ellipsis_continuation ()) buf << (char) c; - goto next; } else if (c == '\n') { @@ -1550,7 +1551,7 @@ } else if (c == delim) { - if (prev == '\\') + if (escape_pending) buf << (char) c; else { @@ -1597,8 +1598,7 @@ buf << (char) c; } - next: - prev = c; + escape_pending = 0; } return LEXICAL_ERROR;