diff --git a/libcxx/include/locale b/libcxx/include/locale --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -3461,7 +3461,7 @@ class _LIBCPP_TYPE_VIS messages_base { public: - typedef ptrdiff_t catalog; + typedef intptr_t catalog; _LIBCPP_INLINE_VISIBILITY messages_base() {} }; @@ -3518,10 +3518,7 @@ messages<_CharT>::do_open(const basic_string& __nm, const locale&) const { #ifdef _LIBCPP_HAS_CATOPEN - catalog __cat = (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); - if (__cat != -1) - __cat = static_cast((static_cast(__cat) >> 1)); - return __cat; + return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); #else // !_LIBCPP_HAS_CATOPEN (void)__nm; return -1; @@ -3538,9 +3535,8 @@ __narrow_to_utf8()(back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); - if (__c != -1) - __c <<= 1; nl_catd __cat = (nl_catd)__c; + static_assert(sizeof(catalog) >= sizeof(nl_catd), "Unexpected nl_catd type"); char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str()); string_type __w; __widen_from_utf8()(back_inserter(__w), @@ -3559,10 +3555,7 @@ messages<_CharT>::do_close(catalog __c) const { #ifdef _LIBCPP_HAS_CATOPEN - if (__c != -1) - __c <<= 1; - nl_catd __cat = (nl_catd)__c; - catclose(__cat); + catclose((nl_catd)__c); #else // !_LIBCPP_HAS_CATOPEN (void)__c; #endif // _LIBCPP_HAS_CATOPEN