diff libinterp/corefcn/oct-stream.h @ 20500:44eb1102f8a8

don't recycle scanf format string if all conversions are done (bug #45808) * oct-stream.cc, oct-stream.h (scanf_format_elt::special_conversion): New enum value, no_conversion. (scanf_format_list::next): If not cycling through the list, return dummy scanf_format_elt after list has been exhausted. (octave_base_stream::do_scanf): Only cycle through the format list more than once if there are conversions to make and the limit on the number of values to convert has not been reached.
author John W. Eaton <jwe@octave.org>
date Wed, 26 Aug 2015 16:05:49 -0400
parents a9574e3c6e9e
children
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.h	Wed Aug 26 22:51:59 2015 +0200
+++ b/libinterp/corefcn/oct-stream.h	Wed Aug 26 16:05:49 2015 -0400
@@ -49,7 +49,8 @@
   enum special_conversion
   {
     whitespace_conversion = 1,
-    literal_conversion = 2
+    literal_conversion = 2,
+    null = 3
   };
 
   scanf_format_elt (const char *txt = 0, int w = 0, bool d = false,
@@ -129,6 +130,9 @@
 
   const scanf_format_elt *next (bool cycle = true)
   {
+    static scanf_format_elt dummy
+      (0, 0, false, scanf_format_elt::null, '\0', "");
+
     curr_idx++;
 
     if (curr_idx >= list.numel ())
@@ -136,8 +140,9 @@
         if (cycle)
           curr_idx = 0;
         else
-          return 0;
+          return &dummy;
       }
+
     return current ();
   }