diff libinterp/corefcn/file-io.cc @ 21622:fed1111e1899

textscan: eliminate ReturnOnError="continue" mode (bug #47538) * oct-stream.cc (textscan_format_list::read_first_row, textscan::scan_one) No longer skip failed fields. (textscan::do_scan): Do not terminate on no_conversions. (textscan::read_format_once): Only "fail" if field wasn't empty. (textscan::parse_options): No longer parse "continue" option. * file-io.cc (Ftextscan): Update docstring and self-tests.
author Lachlan Andrew <lachlanbis@gmail.com>
date Sun, 10 Apr 2016 19:49:50 +1000
parents fe0a6de805e4
children 3cadca91e390
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc	Tue Apr 12 21:05:50 2016 +1000
+++ b/libinterp/corefcn/file-io.cc	Sun Apr 10 19:49:50 2016 +1000
@@ -1337,8 +1337,7 @@
 @item literals\n\
 In addition the format may contain literal character strings; these will be\n\
 skipped during reading.  If the input string does not match this literal,\n\
-the processing terminates, unless @qcode{\"ReturnOnError\"} is set to\n\
-@qcode{\"continue\"}.\n\
+the processing terminates.\n\
 @end table\n\
 \n\
 Parsed words corresponding to the first specifier are returned in the first\n\
@@ -1456,10 +1455,8 @@
 \n\
 @item @qcode{\"ReturnOnError\"}\n\
 If set to numerical 1 or true, return normally as soon as an error is\n\
-encountered, such as trying to read a string using @qcode{%f}.  If set to 0\n\
-or false, return an error and no data.  If set to @qcode{\"continue\"}\n\
-(default), textscan attempts to continue reading beyond the location;\n\
-however, this may cause the parsing to get out of sync.\n\
+encountered, such as trying to read a string using @qcode{%f}.\n\
+If set to 0 or false, return an error and no data.\n\
 \n\
 @item @qcode{\"Whitespace\"}\n\
 Any character in @var{value} will be interpreted as whitespace and trimmed;\n\
@@ -1690,18 +1687,13 @@
 %! str = "1 2 3\n4 s 6";
 %! fprintf (fid, str);
 %! fseek (fid, 0, "bof");
-%! c = textscan (fid, "%f %f %f");
-%! fseek (fid, 0, "bof");
-%! d = textscan (fid, "%f %f %f", "ReturnOnError", 1);
+%! c = textscan (fid, "%f %f %f", "ReturnOnError", 1);
 %! fseek (fid, 0, "bof");
 %! fclose (fid);
 %! unlink (f);
-%! u = textscan (str, "%f %f %f");
-%! v = textscan (str, "%f %f %f", "ReturnOnError", 1);
-%! assert (c, {[1;4], [2;NaN], [3;6]});
-%! assert (d, {[1;4], [2], [3]});
-%! assert (u, {[1;4], [2;NaN], [3;6]});
-%! assert (v, {[1;4], [2], [3]});
+%! u = textscan (str, "%f %f %f", "ReturnOnError", 1);
+%! assert (c, {[1;4], [2], [3]});
+%! assert (u, {[1;4], [2], [3]});
 
 %!test
 %! ## Check ReturnOnError
@@ -1726,14 +1718,11 @@
 %! fid = fopen (f, "w+");
 %! fprintf (fid, "1 s 3\n4 5 6");
 %! fseek (fid, 0, "bof");
-%! c = textscan (fid, "");
-%! fseek (fid, 0, "bof");
-%! d = textscan (fid, "", "ReturnOnError", 1);
+%! c = textscan (fid, "", "ReturnOnError", 1);
 %! fseek (fid, 0, "bof");
 %! fclose (fid);
 %! unlink (f);
-%! assert (c, {[1;4], [NaN;5], [3;6]});
-%! assert (d, {1});
+%! assert (c, {1});
 
 %!test
 %! ## Check ReturnOnError with empty fields