# HG changeset patch # User jwe # Date 790204271 0 # Node ID 59f5eb2d5eb307cc08bb2fc5184d5003ff691002 # Parent cfa5473c5f96a483d08c9cc1fdba84a5393118d3 [project @ 1995-01-15 21:11:11 by jwe] diff -r cfa5473c5f96 -r 59f5eb2d5eb3 src/data.cc --- a/src/data.cc Fri Jan 13 03:19:26 1995 +0000 +++ b/src/data.cc Sun Jan 15 21:11:11 1995 +0000 @@ -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"); diff -r cfa5473c5f96 -r 59f5eb2d5eb3 src/lex.l --- a/src/lex.l Fri Jan 13 03:19:26 1995 +0000 +++ b/src/lex.l Sun Jan 15 21:11:11 1995 +0000 @@ -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; diff -r cfa5473c5f96 -r 59f5eb2d5eb3 src/pt-exp-base.cc --- a/src/pt-exp-base.cc Fri Jan 13 03:19:26 1995 +0000 +++ b/src/pt-exp-base.cc Sun Jan 15 21:11:11 1995 +0000 @@ -2656,8 +2656,7 @@ return retval; Octave_object tmp_args; - tmp_args.resize (1); - Octave_object tmp = eval (print, 1, tmp_args); + Octave_object tmp = eval (print, 0, tmp_args); if (! error_state && tmp.length () > 0) retval = tmp(0);