This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Fix ctype_byname<wchar_t>::do_is() mask checking.
AbandonedPublic

Authored by jroelofs on Aug 26 2014, 11:39 AM.

Details

Summary

The previous method was very dependent on how the ctype masks were defined. For example, Android has print defined as (punct | upper | lower | digit | blank). When calling do_is(upper, L'a'), result would be set to true by if (upper & print) result |= iswprint_l(L'a', __l);

Diff Detail

Event Timeline

danalbert updated this revision to Diff 12957.Aug 26 2014, 11:39 AM
danalbert retitled this revision from to [libcxx] Fix ctype_byname<wchar_t>::do_is() mask checking..
danalbert updated this object.
danalbert edited the test plan for this revision. (Show Details)
danalbert added reviewers: mclow.lists, EricWF.
danalbert added a subscriber: Unknown Object (MLST).
danalbert added inline comments.Aug 26 2014, 11:43 AM
src/locale.cpp
1208

I don't think _LIBCPP_ASSERT() is actually what I want here (since it's usually compiled out). Do we already have something akin to this for _LIBCPP_DEBUG_LEVEL < 1?

I don't think this is correct. IIRC, the value of 'm' coming in is a mask. To
fix this, all of the tests need to be of this form:

if ((m & space) == space) result |= (iswspace_l(ch, __l) != 0);

Newlib also has this problem... Sorry I didn't bring this up sooner.

Cheers,

Jon

Yes, you're right. I had thought this was just one of our implementation details, but it is exposed by ctype::is().

mclow.lists edited edge metadata.Aug 26 2014, 1:52 PM

This is a behavior change. Today, if you pass in a mask that is not one listed, it returned false. With your change, it aborts.

That seems .. harsh.

jroelofs commandeered this revision.Aug 26 2014, 3:34 PM
jroelofs added a reviewer: danalbert.

Here's v2 of this patch: http://reviews.llvm.org/D5081

(This is a rebased version of: https://gist.github.com/jroelofs/8c6091f79ae2327f1ccb)

jroelofs abandoned this revision.Aug 26 2014, 3:35 PM