[cfe-commits] [libcxx] r141506 - in /libcxx/trunk: include/istream test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
Howard Hinnant
hhinnant at apple.com
Sun Oct 9 08:20:46 PDT 2011
Author: hhinnant
Date: Sun Oct 9 10:20:46 2011
New Revision: 141506
URL: http://llvm.org/viewvc/llvm-project?rev=141506&view=rev
Log:
Fix <rdar://problem/10256836> getline of an empty string mistakenly causes failure
Modified:
libcxx/trunk/include/istream
libcxx/trunk/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
Modified: libcxx/trunk/include/istream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=141506&r1=141505&r2=141506&view=diff
==============================================================================
--- libcxx/trunk/include/istream (original)
+++ libcxx/trunk/include/istream Sun Oct 9 10:20:46 2011
@@ -1586,6 +1586,7 @@
{
__str.clear();
ios_base::iostate __err = ios_base::goodbit;
+ streamsize __extr = 0;
while (true)
{
typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
@@ -1594,6 +1595,7 @@
__err |= ios_base::eofbit;
break;
}
+ ++__extr;
_CharT __ch = _Traits::to_char_type(__i);
if (_Traits::eq(__ch, __dlm))
break;
@@ -1604,7 +1606,7 @@
break;
}
}
- if (__str.empty())
+ if (__extr == 0)
__err |= ios_base::failbit;
__is.setstate(__err);
}
Modified: libcxx/trunk/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp?rev=141506&r1=141505&r2=141506&view=diff
==============================================================================
--- libcxx/trunk/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp (original)
+++ libcxx/trunk/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp Sun Oct 9 10:20:46 2011
@@ -21,7 +21,7 @@
int main()
{
{
- std::istringstream in(" abc* def* ghij");
+ std::istringstream in(" abc* def** ghij");
std::string s("initial text");
getline(in, s, '*');
assert(in.good());
@@ -30,11 +30,14 @@
assert(in.good());
assert(s == " def");
getline(in, s, '*');
+ assert(in.good());
+ assert(s == "");
+ getline(in, s, '*');
assert(in.eof());
assert(s == " ghij");
}
{
- std::wistringstream in(L" abc* def* ghij");
+ std::wistringstream in(L" abc* def** ghij");
std::wstring s(L"initial text");
getline(in, s, L'*');
assert(in.good());
@@ -43,6 +46,9 @@
assert(in.good());
assert(s == L" def");
getline(in, s, L'*');
+ assert(in.good());
+ assert(s == L"");
+ getline(in, s, L'*');
assert(in.eof());
assert(s == L" ghij");
}
More information about the cfe-commits
mailing list