changeset 18894:c32f378e08f3 stable

* strread.m: Process string escapes on single quoted format (bug #42609)
author John W. Eaton <jwe@octave.org>
date Wed, 25 Jun 2014 17:17:38 -0400
parents 35838f49e2f6
children c457a84bc7d3
files scripts/io/strread.m
diffstat 1 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/io/strread.m	Tue Jun 24 22:36:47 2014 +0200
+++ b/scripts/io/strread.m	Wed Jun 25 17:17:38 2014 -0400
@@ -192,6 +192,10 @@
     error ("strread: STR and FORMAT arguments must be strings");
   endif
 
+  if (strcmp (typeinfo (format), "sq_string"))
+    format = do_string_escapes (format);
+  endif
+
   ## Parse format string to compare number of conversion fields and nargout
   nfields = length (strfind (format, "%")) - length (strfind (format, "%*"));
   ## If str only has numeric fields, a (default) format ("%f") will do.
@@ -985,14 +989,28 @@
 
 %% Test #1 bug #42609
 %!test
-%! [a, b, c] = strread ("1 2 3\n4 5 6\n7 8 9\n", "%f %f %f\n") ;
+%! [a, b, c] = strread ("1 2 3\n4 5 6\n7 8 9\n", "%f %f %f\n");
 %! assert (a, [1; 4; 7]);
 %! assert (b, [2; 5; 8]);
 %! assert (c, [3; 6; 9]);
 
 %% Test #2 bug #42609
 %!test
-%! [a, b, c] = strread ("1 2\n3\n4 5\n6\n7 8\n9\n", "%f %f\n%f") ;
+%! [a, b, c] = strread ("1 2\n3\n4 5\n6\n7 8\n9\n", "%f %f\n%f");
+%! assert (a, [1;4;7]);
+%! assert (b, [2; 5; 8]);
+%! assert (c, [3; 6; 9]);
+
+%% Test #3 bug #42609
+%!test
+%! [a, b, c] = strread ("1 2 3\n4 5 6\n7 8 9\n", '%f %f %f\n');
+%! assert (a, [1; 4; 7]);
+%! assert (b, [2; 5; 8]);
+%! assert (c, [3; 6; 9]);
+
+%% Test #3 bug #42609
+%!test
+%! [a, b, c] = strread ("1 2\n3\n4 5\n6\n7 8\n9\n", '%f %f\n%f');
 %! assert (a, [1;4;7]);
 %! assert (b, [2; 5; 8]);
 %! assert (c, [3; 6; 9]);