changeset 21566:02826fb0f261

textscan: Fix bug in exponent parsing * oct-stream.cc (textscan::read_double): Fix typo in exponent read loop. * file-io.cc: Add BIST test for exponent parsing.
author Mike Miller <mtmiller@octave.org>
date Wed, 30 Mar 2016 17:28:43 -0700
parents 08baf0ebc9a9
children 3d25f9f4a62b
files libinterp/corefcn/file-io.cc libinterp/corefcn/oct-stream.cc
diffstat 2 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc	Sat Mar 26 19:46:49 2016 +1100
+++ b/libinterp/corefcn/file-io.cc	Wed Mar 30 17:28:43 2016 -0700
@@ -2197,6 +2197,9 @@
 %! assert (c, {1, "/", 2});
 
 %!assert (textscan (["1 2 3 4"; "5 6 7 8"], "%f"), {[15; 26; 37; 48]})
+
+%% Check for delimiter after exponent
+%!assert (textscan ("1e-3|42", "%f", "delimiter", "|"), {[1e-3; 42]})
 */
 
 // These tests have end-comment sequences, so can't just be in a comment
--- a/libinterp/corefcn/oct-stream.cc	Sat Mar 26 19:46:49 2016 +1100
+++ b/libinterp/corefcn/oct-stream.cc	Wed Mar 30 17:28:43 2016 -0700
@@ -2884,7 +2884,7 @@
                 width_left--;
             }
           valid = false;
-          while (width_left-- && is && (ch = is.get ()) >= '0' && ch1 <= '9')
+          while (width_left-- && is && (ch = is.get ()) >= '0' && ch <= '9')
             {
               exp = exp*10 + ch - '0';
               valid = true;