1 /*@ Implementation of cs.h: reverse finding related things.
2 *@ TODO Optimize (even asm hooks?)
4 * Copyright (c) 2017 - 2020 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
5 * SPDX-License-Identifier: ISC
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #define su_FILE su_cs_rfind
22 #define su_SOURCE_CS_RFIND
27 #include "su/code-in.h"
31 su_cs_ends_with_case(char const *cp
, char const *xp
){
34 ASSERT_NYD_EXEC(cp
!= NIL
, rv
= FAL0
);
35 ASSERT_NYD_EXEC(xp
!= NIL
, rv
= FAL0
);
39 if(LIKELY(*xp
!= '\0')){
48 for(cp
+= cl
- xl
;; ++cp
, ++xp
){
51 if((c
= su_cs_to_lower(*cp
)) != (xc
= su_cs_to_lower(*xp
)))
68 su_cs_rfind_c(char const *cp
, char x
){
69 char const *match
, *tail
;
71 ASSERT_NYD_EXEC(cp
!= NIL
, match
= NIL
);
73 for(match
= NIL
, tail
= cp
;; ++tail
){
83 return UNCONST(char*,match
);
86 #include "su/code-ou.h"