[libcxx] r185298 - In istream::ignore, check the delimeter as an int_type, not as a char_type, so as to correctly handle EOF. This fixes http://llvm.org/bugs/show_bug.cgi?id=16427
Howard Hinnant
hhinnant at apple.com
Sun Jun 30 17:37:50 PDT 2013
Author: hhinnant
Date: Sun Jun 30 19:37:50 2013
New Revision: 185298
URL: http://llvm.org/viewvc/llvm-project?rev=185298&view=rev
Log:
In istream::ignore, check the delimeter as an int_type, not as a char_type, so as to correctly handle EOF. This fixes http://llvm.org/bugs/show_bug.cgi?id=16427
Added:
libcxx/trunk/test/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
Modified:
libcxx/trunk/include/istream
Modified: libcxx/trunk/include/istream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=185298&r1=185297&r2=185298&view=diff
==============================================================================
--- libcxx/trunk/include/istream (original)
+++ libcxx/trunk/include/istream Sun Jun 30 19:37:50 2013
@@ -1144,8 +1144,7 @@ basic_istream<_CharT, _Traits>::ignore(s
break;
}
++__gc_;
- char_type __ch = traits_type::to_char_type(__i);
- if (traits_type::eq(__ch, static_cast<char_type>(__dlm)))
+ if (traits_type::eq_int_type(__i, __dlm))
break;
}
}
@@ -1160,8 +1159,7 @@ basic_istream<_CharT, _Traits>::ignore(s
break;
}
++__gc_;
- char_type __ch = traits_type::to_char_type(__i);
- if (traits_type::eq(__ch, static_cast<char_type>(__dlm)))
+ if (traits_type::eq_int_type(__i, __dlm))
break;
}
}
Added: libcxx/trunk/test/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp?rev=185298&view=auto
==============================================================================
--- libcxx/trunk/test/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp (added)
+++ libcxx/trunk/test/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp Sun Jun 30 19:37:50 2013
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>&
+// ignore(streamsize n = 1, int_type delim = traits::eof());
+
+// http://llvm.org/bugs/show_bug.cgi?id=16427
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ int bad=-1;
+ std::ostringstream os;
+ os << "aaaabbbb" << static_cast<char>(bad)
+ << "ccccdddd" << std::endl;
+ std::string s=os.str();
+
+ std::istringstream is(s);
+ const unsigned int ignoreLen=10;
+ size_t a=is.tellg();
+ is.ignore(ignoreLen);
+ size_t b=is.tellg();
+ assert((b-a)==ignoreLen);
+}
More information about the cfe-commits
mailing list