Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-22 Thread Volodymyr Sapsai via cfe-commits
On Nov 20, 2017, at 23:59, Reimar Döffinger wrote: > > On 21.11.2017, at 03:54, Volodymyr Sapsai > wrote: >> >>> If (exceptions()) != 0 then the exception is rethrown. >> And looks like libstdc++ rethrows exception even

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Reimar Döffinger via cfe-commits
On 21.11.2017, at 03:54, Volodymyr Sapsai wrote: > >> If (exceptions()) != 0 then the exception is rethrown. > And looks like libstdc++ rethrows exception even if badbit is not set. Thanks for looking all that up, I was in a hurry. > If you feel comfortable, I can finish

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Volodymyr Sapsai via cfe-commits
On Nov 20, 2017, at 16:33, Reimar Döffinger wrote: > > On 20 November 2017 22:19:04 CET, Volodymyr Sapsai > wrote: >> On Nov 20, 2017, at 11:32, Reimar Döffinger >> wrote: >>> >>> On Mon, Nov

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Reimar Döffinger via cfe-commits
On 20 November 2017 22:19:04 CET, Volodymyr Sapsai wrote: >On Nov 20, 2017, at 11:32, Reimar Döffinger >wrote: >> >> On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote: catch (...) { +if (__n > 0) +

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Volodymyr Sapsai via cfe-commits
On Nov 20, 2017, at 11:32, Reimar Döffinger wrote: > > On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote: >>> catch (...) >>> { >>> +if (__n > 0) >>> +*__s = char_type(); >>> this->__set_badbit_and_consider_rethrow();

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Reimar Döffinger via cfe-commits
On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote: > > catch (...) > > { > > +if (__n > 0) > > +*__s = char_type(); > > this->__set_badbit_and_consider_rethrow(); > > } > > or maybe something else? That one (note that the

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Volodymyr Sapsai via cfe-commits
On Nov 19, 2017, at 08:07, Reimar Döffinger wrote: > > On Wed, Nov 15, 2017 at 11:35:56AM -0800, Volodymyr Sapsai wrote: >> On Nov 12, 2017, at 12:37, Reimar Döffinger wrote: >> libc++ can be built with exceptions enabled or disabled (see >>

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-19 Thread Reimar Döffinger via cfe-commits
On Wed, Nov 15, 2017 at 11:35:56AM -0800, Volodymyr Sapsai wrote: > On Nov 12, 2017, at 12:37, Reimar Döffinger wrote: > libc++ can be built with exceptions enabled or disabled (see > LIBCXX_ENABLE_EXCEPTIONS >

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-15 Thread Volodymyr Sapsai via cfe-commits
On Nov 12, 2017, at 12:37, Reimar Döffinger wrote: > > On Thu, Nov 09, 2017 at 05:37:32PM -0800, Volodymyr Sapsai wrote: >> On Nov 9, 2017, at 12:13, Reimar Döffinger wrote: >>> >>> Hello! >>> >>> On Wed, Nov 08, 2017 at 12:36:00PM -0800,

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-09 Thread Volodymyr Sapsai via cfe-commits
On Nov 9, 2017, at 12:13, Reimar Döffinger wrote: > > Hello! > > On Wed, Nov 08, 2017 at 12:36:00PM -0800, Volodymyr Sapsai wrote: >> Thanks for the patch, Reimar. Can you please add tests to ensure this >> functionality doesn’t regress? As null character is required

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-09 Thread Reimar Döffinger via cfe-commits
Hello! On Wed, Nov 08, 2017 at 12:36:00PM -0800, Volodymyr Sapsai wrote: > Thanks for the patch, Reimar. Can you please add tests to ensure this > functionality doesn’t regress? As null character is required by the standard > (27.7.2.3p21), a good starting point seems to be >

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-08 Thread Volodymyr Sapsai via cfe-commits
Thanks for the patch, Reimar. Can you please add tests to ensure this functionality doesn’t regress? As null character is required by the standard (27.7.2.3p21), a good starting point seems to be

[PATCH] Ensure std::getline always 0-terminates string.

2017-10-04 Thread Reimar Döffinger via cfe-commits
If the sentinel failed (e.g. due to having reached EOF before) or an exception was caught it failed to do that. The C++14 standard says: "In any case, if n is greater than zero, it then stores a null character (using charT()) into the next successive location of the array." Other implementations