Skip to content

Add strcspn implementation#101

Open
umutoztunc wants to merge 1 commit intoshinh:masterfrom
umutoztunc:strcspn_implementation
Open

Add strcspn implementation#101
umutoztunc wants to merge 1 commit intoshinh:masterfrom
umutoztunc:strcspn_implementation

Conversation

@umutoztunc
Copy link
Contributor

@umutoztunc umutoztunc commented Mar 18, 2021

I thought of implementing it using a 256-bit bitmap. Like storing characters in s2 like a blacklist to stop iteration of s1. However, it might be an overkill to create a bitmap for overall use-cases. Under most circumstances, the length of s2 should be way smaller than s1. Thus, I decided to copy the implementation from Bionic like some other functions in string.h.

I was planning to write some test cases, but I noticed there are no test cases for functions like strchr and the test structure looked a bit weird to me. It might be better to refactor the tests at some point. Still, I can write tests similar to fgets if you'd like.

@Cucuzacu
Copy link

Cucuzacu commented Jan 4, 2026

Hello! If you are still interested about this project, I decided to make a fork: https://github.com/Cucuzacu/ELVM-Remastered. I will constantly update it to support more and more C functions. I added your strcspn implementation to my fork, along with scanf. Maybe you can help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants