This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add strcpsn and strpbrk implementation.
ClosedPublic

Authored by cgyurgyik on Aug 5 2020, 5:52 PM.

Details

Summary

[libc] Add strcspn and strpbrk implementation. Also removes unnecessary header from strspn, and adds the bitset to dependencies.

Diff Detail

Event Timeline

cgyurgyik created this revision.Aug 5 2020, 5:52 PM
cgyurgyik requested review of this revision.Aug 5 2020, 5:52 PM
cgyurgyik updated this revision to Diff 283460.Aug 5 2020, 5:54 PM
cgyurgyik updated this revision to Diff 283463.Aug 5 2020, 6:12 PM
MaskRay added a subscriber: MaskRay.Aug 5 2020, 9:36 PM
MaskRay added inline comments.
libc/src/string/strpbrk.cpp
16

You can implement strpbrk on top of strcspn

cgyurgyik added inline comments.Aug 6 2020, 6:04 AM
libc/src/string/strpbrk.cpp
16

Ack, let me tackle that.

cgyurgyik updated this revision to Diff 283604.Aug 6 2020, 7:35 AM
cgyurgyik retitled this revision from [libc] Add strpbrk implementation. to [libc] Add strcpsn and strpbrk implementation..
cgyurgyik edited the summary of this revision. (Show Details)

Address MaskRay's comment. Adds strcspn implementation, and uses it in strpbrk.

cgyurgyik marked an inline comment as done.Aug 6 2020, 7:36 AM
cgyurgyik updated this revision to Diff 283649.Aug 6 2020, 10:33 AM

Replaces include "../strcspn.h" with a common static function in a string_util. This allows the user to package libc with strpbrk but without strcspn.

sivachandra accepted this revision.Aug 7 2020, 1:12 PM
This revision is now accepted and ready to land.Aug 7 2020, 1:12 PM
This revision was automatically updated to reflect the committed changes.