Author: hhinnant
Date: Thu Feb 24 18:51:08 2011
New Revision: 126462
URL: http://llvm.org/viewvc/llvm-project?rev=126462&view=rev
Log:
Chris Jefferson spotted a problem with messages_base::catalog while getting
libc++ to work on boost. The standard says this type must be an int. But this
type is the key returned by the OS facility catopen. On OS X the type returned
by catopen is void*, which doesn't fit into an int on 64 bit platforms. Chris
suggested using ptrdiff_t instead of void*. It still isn't compliant with the
standard, but chances are that this change will fix what is ailing boost.
Chris also supplied the algorithm for distinguishing high-order pointers from
error conditions. Thanks Chris.
Modified:
libcxx/trunk/include/locale
Modified: libcxx/trunk/include/locale
URL:
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=126462&r1=126461&r2=126462&view=diff
==============================================================================
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Thu Feb 24 18:51:08 2011
@@ -3474,7 +3474,7 @@
class _LIBCPP_VISIBLE messages_base
{
public:
- typedef nl_catd catalog;
+ typedef ptrdiff_t catalog;
_LIBCPP_ALWAYS_INLINE messages_base() {}
};
@@ -3531,7 +3531,10 @@
typename messages<_CharT>::catalog
messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const
{
- return catopen(__nm.c_str(), NL_CAT_LOCALE);
+ catalog __cat = reinterpret_cast<catalog>(catopen(__nm.c_str(),
NL_CAT_LOCALE));
+ if (__cat != -1)
+ __cat = static_cast<catalog>((static_cast<size_t>(__cat) >> 1));
+ return __cat;
}
template <class _CharT>
@@ -3543,7 +3546,10 @@
__narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__ndflt),
__dflt.c_str(),
__dflt.c_str() +
__dflt.size());
- char* __n = catgets(__c, __set, __msgid, __ndflt.c_str());
+ if (__c != -1)
+ __c <<= 1;
+ nl_catd __cat = reinterpret_cast<nl_catd>(__c);
+ char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());
string_type __w;
__widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),
__n, __n +
strlen(__n));
@@ -3554,7 +3560,10 @@
void
messages<_CharT>::do_close(catalog __c) const
{
- catclose(__c);
+ if (__c != -1)
+ __c <<= 1;
+ nl_catd __cat = reinterpret_cast<nl_catd>(__c);
+ catclose(__cat);
}
extern template class messages<char>;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits