Mercurial > octave-nkf
comparison libinterp/corefcn/oct-stream.cc @ 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 | a76e20f2f156 |
children | 1a0a433c8263 |
comparison
equal
deleted
inserted
replaced
20499:7fbba8c8efd5 | 20500:44eb1102f8a8 |
---|---|
1601 { | 1601 { |
1602 octave_quit (); | 1602 octave_quit (); |
1603 | 1603 |
1604 if (elt) | 1604 if (elt) |
1605 { | 1605 { |
1606 if (! (elt->type == scanf_format_elt::whitespace_conversion | 1606 if (elt->type == scanf_format_elt::null |
1607 || elt->type == scanf_format_elt::literal_conversion | 1607 || (! (elt->type == scanf_format_elt::whitespace_conversion |
1608 || elt->type == '%') | 1608 || elt->type == scanf_format_elt::literal_conversion |
1609 && max_conv > 0 && conversion_count == max_conv) | 1609 || elt->type == '%') |
1610 && max_conv > 0 && conversion_count == max_conv)) | |
1610 { | 1611 { |
1612 // We are done, either because we have reached the end | |
1613 // of the format string and are not cycling through | |
1614 // the format again or because we've converted all the | |
1615 // values that have been requested and the next format | |
1616 // element is a conversion. Determine final array | |
1617 // size and exit. | |
1618 | |
1611 if (all_char_conv && one_elt_size_spec) | 1619 if (all_char_conv && one_elt_size_spec) |
1612 { | 1620 { |
1613 final_nr = 1; | 1621 final_nr = 1; |
1614 final_nc = data_index; | 1622 final_nc = data_index; |
1615 } | 1623 } |
1857 } | 1865 } |
1858 | 1866 |
1859 break; | 1867 break; |
1860 } | 1868 } |
1861 else | 1869 else |
1862 elt = fmt_list.next (nconv > 0); | 1870 { |
1871 // Cycle through the format list more than once if we have | |
1872 // some conversions to make and we haven't reached the | |
1873 // limit on the number of values to convert (possibly | |
1874 // because there is no specified limit). | |
1875 | |
1876 elt = fmt_list.next (nconv > 0 | |
1877 && (max_conv == 0 | |
1878 || conversion_count < max_conv)); | |
1879 } | |
1863 } | 1880 } |
1864 } | 1881 } |
1865 | 1882 |
1866 if (ok ()) | 1883 if (ok ()) |
1867 { | 1884 { |