xref: /llvm-project/libc/src/string/strsep.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1b4ab398cSAlex Brachet //===-- Implementation of strsep ------------------------------------------===//
2b4ab398cSAlex Brachet //
3b4ab398cSAlex Brachet // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4b4ab398cSAlex Brachet // See https://llvm.org/LICENSE.txt for license information.
5b4ab398cSAlex Brachet // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6b4ab398cSAlex Brachet //
7b4ab398cSAlex Brachet //===----------------------------------------------------------------------===//
8b4ab398cSAlex Brachet 
9b4ab398cSAlex Brachet #include "src/string/strsep.h"
10b4ab398cSAlex Brachet 
11*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
12b4ab398cSAlex Brachet #include "src/string/string_utils.h"
13b4ab398cSAlex Brachet 
14*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
15b4ab398cSAlex Brachet 
16e06b5a24SAtariDreams LLVM_LIBC_FUNCTION(char *, strsep,
17e06b5a24SAtariDreams                    (char **__restrict stringp, const char *__restrict delim)) {
18b4ab398cSAlex Brachet   if (!*stringp)
19b4ab398cSAlex Brachet     return nullptr;
20b4ab398cSAlex Brachet   return internal::string_token<false>(*stringp, delim, stringp);
21b4ab398cSAlex Brachet }
22b4ab398cSAlex Brachet 
23*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
24