29 lines · cpp
1//===-- Implementation of strsep ------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/string/strsep.h"10 11#include "src/__support/macros/config.h"12#include "src/__support/macros/null_check.h"13#include "src/string/string_utils.h"14 15#include "src/__support/common.h"16 17namespace LIBC_NAMESPACE_DECL {18 19LLVM_LIBC_FUNCTION(char *, strsep,20 (char **__restrict stringp, const char *__restrict delim)) {21 LIBC_CRASH_ON_NULLPTR(stringp);22 if (!*stringp)23 return nullptr;24 LIBC_CRASH_ON_NULLPTR(delim);25 return internal::string_token<false>(*stringp, delim, stringp);26}27 28} // namespace LIBC_NAMESPACE_DECL29