]> git.ipfire.org Git - thirdparty/glibc.git/blame - string/strsep.c
build-many-glibcs.py: Add openrisc hard float glibc variant
[thirdparty/glibc.git] / string / strsep.c
CommitLineData
dff8da6b 1/* Copyright (C) 1992-2024 Free Software Foundation, Inc.
c84142e8
UD
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
c84142e8
UD
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12 Lesser General Public License for more details.
c84142e8 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6 15 License along with the GNU C Library; if not, see
5a82c748 16 <https://www.gnu.org/licenses/>. */
28f540f4 17
28f540f4
RM
18#include <string.h>
19
7551a1e5 20#undef __strsep
9a0a462c
UD
21#undef strsep
22
28f540f4 23char *
d68171ed 24__strsep (char **stringp, const char *delim)
28f540f4
RM
25{
26 char *begin, *end;
27
6df1b247 28 begin = *stringp;
14c44e2e 29 if (begin == NULL)
28f540f4
RM
30 return NULL;
31
5625f666
WD
32 /* Find the end of the token. */
33 end = begin + strcspn (begin, delim);
0a54e401 34
5625f666 35 if (*end)
6df1b247 36 {
76060ec0 37 /* Terminate the token and set *STRINGP past NUL character. */
6df1b247 38 *end++ = '\0';
76060ec0 39 *stringp = end;
6df1b247
RM
40 }
41 else
42 /* No more delimiters; this is the last token. */
43 *stringp = NULL;
28f540f4
RM
44
45 return begin;
46}
d68171ed 47weak_alias (__strsep, strsep)
b61345a1 48strong_alias (__strsep, __strsep_g)
78cf1d74 49libc_hidden_def (__strsep)
ee600e3f 50libc_hidden_def (__strsep_g)