logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/

strchrnul.c (382B)


  1. // Based on the strchrnul(3) function from musl
  2. // Copyright © 2005-2020 Rich Felker, et al.
  3. // SPDX-License-Identifier: MIT
  4. #define _POSIX_C_SOURCE 200809L
  5. #include "strchrnul.h"
  6. #include <string.h>
  7. char *
  8. utils_strchrnul(const char *s, int c)
  9. {
  10. c = (unsigned char)c;
  11. if(!c) return (char *)s + strlen(s);
  12. for(; *s && *(unsigned char *)s != c; s++)
  13. ;
  14. return (char *)s;
  15. }