strsep.c 569 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (C) 2002 Manuel Novoa III
  3. * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include "_string.h"
  8. char attribute_hidden *__strsep(char ** __restrict s1, const char * __restrict s2)
  9. {
  10. register char *s = *s1;
  11. register char *p;
  12. #if 1
  13. p = NULL;
  14. if (s && *s && (p = __strpbrk(s, s2))) {
  15. *p++ = 0;
  16. }
  17. #else
  18. if (s && *s && *(p = s + __strcspn(s, s2))) {
  19. *p++ = 0;
  20. } else {
  21. p = NULL;
  22. }
  23. #endif
  24. *s1 = p;
  25. return s;
  26. }
  27. strong_alias(__strsep,strsep)