1 //===-- Implementation of strrchr------------------------------------------===// 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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "src/string/strrchr.h" 10 11 #include "src/__support/common.h" 12 13 namespace __llvm_libc { 14 LLVM_LIBC_ENTRYPOINT(strrchr)15char *LLVM_LIBC_ENTRYPOINT(strrchr)(const char *src, int c) { 16 const char ch = c; 17 char *last_occurrence = nullptr; 18 do { 19 if (*src == ch) 20 last_occurrence = const_cast<char *>(src); 21 } while (*src++); 22 return last_occurrence; 23 } 24 25 } // namespace __llvm_libc 26