[libc] implement getdelim (#243660)
Add the getdelim function. Implementation was done when adding getline
in PR #242975. This PR mostly adds tests, which are somewhat based on
the getline tests. In future they should be unified or at least made
more similar.
Assisted-by: Automated tooling, human reviewed.