# HG changeset patch # User Lachlan Andrew # Date 1458976471 -39600 # Node ID 990c6c31a684d8e6a1fcfb2501128847ad9e5330 # Parent 7ebd8ac261780be961214bddd5f93717856b7da6 Accept escape sequences in single quoted strings for "delimiter" (bug #47539) * oct-stream.cc (textscan::parse_options): call do_string_escapes for "delimiter". * file-io.cc: Add BIST tests. diff -r 7ebd8ac26178 -r 990c6c31a684 libinterp/corefcn/file-io.cc --- a/libinterp/corefcn/file-io.cc Sun Feb 14 10:12:30 2016 +1100 +++ b/libinterp/corefcn/file-io.cc Sat Mar 26 18:14:31 2016 +1100 @@ -1977,6 +1977,14 @@ %! assert (C{3}', [13, 24, 35]); %! assert (C{4}', [15, 25, NaN]); +## Single-quoted escape sequences +%!test +%! str = "11\t12\t13\r21\t22\t23"; +%! c = textscan (str, "", "delimiter", '\t', "EndOfLine", '\r'); +%! assert (c{1}', [11, 21]); +%! assert (c{2}', [12, 22]); +%! assert (c{3}', [13, 23]); + ## Bug #44750 %!test %! assert (textscan ("/home/foo/", "%s", "delimiter", "/", "MultipleDelimsAsOne", 1){1}, ... diff -r 7ebd8ac26178 -r 990c6c31a684 libinterp/corefcn/oct-stream.cc --- a/libinterp/corefcn/oct-stream.cc Sun Feb 14 10:12:30 2016 +1100 +++ b/libinterp/corefcn/oct-stream.cc Sat Mar 26 18:14:31 2016 +1100 @@ -3585,6 +3585,8 @@ invalid = false; have_delims = true; delims = args(i+1).string_value (); + if (args(i+1).is_sq_string ()) + delims = do_string_escapes (delims); } else if (args(i+1).is_cell ()) { @@ -3599,6 +3601,9 @@ invalid = true; else { + if (delim_list(j).is_sq_string ()) + delim_list(j) = do_string_escapes (delim_list(j) + .string_value ()); octave_idx_type len = delim_list(j).string_value () .length (); delim_len = std::max (static_cast (len), delim_len);