mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-02-07 21:29:57 +01:00
Rename s1
and s2
parameters of u32_strnrstr
to haystack
and needle
in unicode module
This commit is contained in:
parent
f30f12a988
commit
6ce0f86898
@ -351,25 +351,25 @@ uint32_t *u32_nspaces(const size_t n)
|
||||
|
||||
|
||||
// TODO It seems skip is always 0, can we remove that parameter?
|
||||
uint32_t *u32_strnrstr(const uint32_t *s1, const uint32_t *s2, const size_t s2_len, int skip)
|
||||
uint32_t *u32_strnrstr(const uint32_t *haystack, const uint32_t *needle, const size_t needle_len, int skip)
|
||||
{
|
||||
if (is_empty(s2)) {
|
||||
return (uint32_t *) s1;
|
||||
if (is_empty(needle)) {
|
||||
return (uint32_t *) haystack;
|
||||
}
|
||||
if (is_empty(s1)) {
|
||||
if (is_empty(haystack)) {
|
||||
return NULL;
|
||||
}
|
||||
if (skip < 0) {
|
||||
skip = 0;
|
||||
}
|
||||
|
||||
uint32_t *p = u32_strrchr(s1, s2[0]);
|
||||
uint32_t *p = u32_strrchr(haystack, needle[0]);
|
||||
if (!p) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (p >= s1) {
|
||||
int comp = u32_strncmp(p, s2, s2_len);
|
||||
while (p >= haystack) {
|
||||
int comp = u32_strncmp(p, needle, needle_len);
|
||||
if (comp == 0) {
|
||||
if (skip--) {
|
||||
--p;
|
||||
|
@ -238,14 +238,14 @@ uint32_t *u32_nspaces(const size_t n);
|
||||
|
||||
|
||||
/**
|
||||
* Return pointer to last occurrence of string `s2` in string `s1`.
|
||||
* @param s1 string to search
|
||||
* @param s2 string to search for in `s1`
|
||||
* @param s2_len length in characters of `s2`
|
||||
* Return pointer to last occurrence of string `needle` in string `haystack`.
|
||||
* @param haystack string to search
|
||||
* @param needle string to search for in `haystack`
|
||||
* @param needle_len length in characters of `needle`
|
||||
* @param skip number of finds to ignore before returning anything
|
||||
* @return pointer to last occurrence of string `s2` in string `s1`; NULL if not found or error
|
||||
* @return pointer to last occurrence of string `needle` in string `haystack`; NULL if not found or error
|
||||
*/
|
||||
uint32_t *u32_strnrstr(const uint32_t *s1, const uint32_t *s2, const size_t s2_len, int skip);
|
||||
uint32_t *u32_strnrstr(const uint32_t *haystack, const uint32_t *needle, const size_t needle_len, int skip);
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user