Mercurial > hg > octave-lojdl
changeset 7708:b42abee70a98
fread, fwrite: allow SKIP arg to be omitted
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 14 Apr 2008 13:13:25 -0400 |
parents | 446dec9d1de5 |
children | fa41af732801 |
files | src/ChangeLog src/file-io.cc |
diffstat | 2 files changed, 29 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-04-14 John W. Eaton <jwe@octave.org> + + * file-io.cc (Ffread): Allow SKIP arg to be omitted. + (Ffwrite): Likewise. Handle args in a way consistent with Ffread. + 2008-04-09 Michael Goffioul <michael.goffioul@gmail.com> * DLD-FUNCTIONS/dispatch.cc: Replace system("echo '...'>...") calls
--- a/src/file-io.cc +++ b/src/file-io.cc @@ -1496,7 +1496,7 @@ int idx = 1; - if (nargin > 1 && ! args(idx).is_string ()) + if (nargin > idx && ! args(idx).is_string ()) size = args(idx++); if (nargin > idx) @@ -1507,6 +1507,11 @@ if (nargin > idx) arch = args(idx++); + else if (skip.is_string ()) + { + arch = skip; + skip = 0; + } octave_idx_type count = -1; @@ -1598,16 +1603,27 @@ if (! error_state) { - octave_value data = args(1); + octave_value prec = "uchar"; + octave_value skip = 0; + octave_value arch = "unknown"; - octave_value prec = (nargin > 2) - ? args(2) : octave_value ("uchar"); + int idx = 1; + + octave_value data = args(idx++); + + if (nargin > idx) + prec = args(idx++); - octave_value skip = (nargin > 3) - ? args(3) : octave_value (0.0); + if (nargin > idx) + skip = args(idx++); - octave_value arch = (nargin > 4) - ? args(4) : octave_value ("unknown"); + if (nargin > idx) + arch = args(idx++); + else if (skip.is_string ()) + { + arch = skip; + skip = 0; + } double status = do_fwrite (os, data, prec, skip, arch);