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.
I thought of implementing it using a 256-bit bitmap. Like storing characters in
s2
like a blacklist to stop iteration ofs1
. However, it might be an overkill to create a bitmap for overall use-cases. Under most circumstances, the length ofs2
should be way smaller thans1
. Thus, I decided to copy the implementation from Bionic like some other functions instring.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 tofgets
if you'd like.