1141cc406Sopenharmony_ci/* Copyright (C) 1992, 1993, 1996 Free Software Foundation, Inc.
2141cc406Sopenharmony_ciThis file is part of the GNU C Library.
3141cc406Sopenharmony_ci
4141cc406Sopenharmony_ciThe GNU C Library is free software; you can redistribute it and/or
5141cc406Sopenharmony_cimodify it under the terms of the GNU Library General Public License as
6141cc406Sopenharmony_cipublished by the Free Software Foundation; either version 2 of the
7141cc406Sopenharmony_ciLicense, or (at your option) any later version.
8141cc406Sopenharmony_ci
9141cc406Sopenharmony_ciThe GNU C Library is distributed in the hope that it will be useful,
10141cc406Sopenharmony_cibut WITHOUT ANY WARRANTY; without even the implied warranty of
11141cc406Sopenharmony_ciMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12141cc406Sopenharmony_ciLibrary General Public License for more details.
13141cc406Sopenharmony_ci
14141cc406Sopenharmony_ciYou should have received a copy of the GNU Library General Public
15141cc406Sopenharmony_ciLicense along with the GNU C Library; see the file COPYING.LIB.  If
16141cc406Sopenharmony_cinot, see <https://www.gnu.org/licenses/>.  */
17141cc406Sopenharmony_ci
18141cc406Sopenharmony_ci#include "../include/sane/config.h"
19141cc406Sopenharmony_ci
20141cc406Sopenharmony_ci#include <string.h>
21141cc406Sopenharmony_ci
22141cc406Sopenharmony_ci#ifndef HAVE_STRSEP
23141cc406Sopenharmony_ci
24141cc406Sopenharmony_cichar *
25141cc406Sopenharmony_cistrsep (char **stringp, const char *delim)
26141cc406Sopenharmony_ci{
27141cc406Sopenharmony_ci  char *begin, *end;
28141cc406Sopenharmony_ci
29141cc406Sopenharmony_ci  begin = *stringp;
30141cc406Sopenharmony_ci  if (! begin || *begin == '\0')
31141cc406Sopenharmony_ci    return NULL;
32141cc406Sopenharmony_ci
33141cc406Sopenharmony_ci  /* Find the end of the token.  */
34141cc406Sopenharmony_ci  end = strpbrk (begin, delim);
35141cc406Sopenharmony_ci  if (end)
36141cc406Sopenharmony_ci    {
37141cc406Sopenharmony_ci      /* Terminate the token and set *STRINGP past NUL character.  */
38141cc406Sopenharmony_ci      *end++ = '\0';
39141cc406Sopenharmony_ci      *stringp = end;
40141cc406Sopenharmony_ci    }
41141cc406Sopenharmony_ci  else
42141cc406Sopenharmony_ci    /* No more delimiters; this is the last token.  */
43141cc406Sopenharmony_ci    *stringp = NULL;
44141cc406Sopenharmony_ci
45141cc406Sopenharmony_ci  return begin;
46141cc406Sopenharmony_ci}
47141cc406Sopenharmony_ci
48141cc406Sopenharmony_ci#endif /* !HAVE_STRSEP */
49