comparison 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
comparison
equal deleted inserted replaced
20499:7fbba8c8efd5 20500:44eb1102f8a8
47 public: 47 public:
48 48
49 enum special_conversion 49 enum special_conversion
50 { 50 {
51 whitespace_conversion = 1, 51 whitespace_conversion = 1,
52 literal_conversion = 2 52 literal_conversion = 2,
53 null = 3
53 }; 54 };
54 55
55 scanf_format_elt (const char *txt = 0, int w = 0, bool d = false, 56 scanf_format_elt (const char *txt = 0, int w = 0, bool d = false,
56 char typ = '\0', char mod = '\0', 57 char typ = '\0', char mod = '\0',
57 const std::string& ch_class = std::string ()) 58 const std::string& ch_class = std::string ())
127 const scanf_format_elt *current (void) const 128 const scanf_format_elt *current (void) const
128 { return list.numel () > 0 ? list.elem (curr_idx) : 0; } 129 { return list.numel () > 0 ? list.elem (curr_idx) : 0; }
129 130
130 const scanf_format_elt *next (bool cycle = true) 131 const scanf_format_elt *next (bool cycle = true)
131 { 132 {
133 static scanf_format_elt dummy
134 (0, 0, false, scanf_format_elt::null, '\0', "");
135
132 curr_idx++; 136 curr_idx++;
133 137
134 if (curr_idx >= list.numel ()) 138 if (curr_idx >= list.numel ())
135 { 139 {
136 if (cycle) 140 if (cycle)
137 curr_idx = 0; 141 curr_idx = 0;
138 else 142 else
139 return 0; 143 return &dummy;
140 } 144 }
145
141 return current (); 146 return current ();
142 } 147 }
143 148
144 void printme (void) const; 149 void printme (void) const;
145 150