Mercurial > octave
changeset 24304:ddaee520d342
maint: merge stable to default.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 24 Nov 2017 17:29:00 -0800 |
parents | a9db5eed8fce (current diff) ddc91a2ee0e0 (diff) |
children | 606f3866cdb7 |
files | libinterp/corefcn/file-io.cc libinterp/corefcn/oct-stream.cc |
diffstat | 2 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc Fri Nov 24 18:14:37 2017 +0100 +++ b/libinterp/corefcn/file-io.cc Fri Nov 24 17:29:00 2017 -0800 @@ -2210,6 +2210,17 @@ ## Check for delimiter after exponent %!assert (textscan ("1e-3|42", "%f", "delimiter", "|"), {[1e-3; 42]}) + +%!test <*52479> +%! str = "\t\ta\tb\tc\n"; +%! ret = textscan (str, "%s", "delimiter", "\t"); +%! assert (ret, { {''; ''; 'a'; 'b'; 'c'} }) ; + +%!test <*52479> +%! str = "\t\ta\tb\tc\n"; +%! ret = textscan (str, "%s", "delimiter", {"\t"}); +%! assert (ret, { {''; ''; 'a'; 'b'; 'c'} }) ; + */ // These tests have end-comment sequences, so can't just be in a comment
--- a/libinterp/corefcn/oct-stream.cc Fri Nov 24 18:14:37 2017 +0100 +++ b/libinterp/corefcn/oct-stream.cc Fri Nov 24 17:29:00 2017 -0800 @@ -29,6 +29,7 @@ #include <cctype> #include <cstring> +#include <algorithm> #include <deque> #include <fstream> #include <iomanip> @@ -3714,6 +3715,24 @@ error ("%s: unrecognized option '%s'", who.c_str (), param.c_str ()); } + // Remove any user-supplied delimiter from whitespace list + for (unsigned int j = 0; j < delims.length (); j++) + { + whitespace.erase (std::remove (whitespace.begin (), + whitespace.end (), + delims[j]), + whitespace.end ()); + } + for (int j = 0; j < delim_list.numel (); j++) + { + std::string delim = delim_list(j).string_value (); + if (delim.length () == 1) + whitespace.erase (std::remove (whitespace.begin (), + whitespace.end (), + delim[0]), + whitespace.end ()); + } + whitespace_table = std::string (256, '\0'); for (unsigned int i = 0; i < whitespace.length (); i++) whitespace_table[whitespace[i]] = '1';