mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-02-12 07:40:16 +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?
|
// 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)) {
|
if (is_empty(needle)) {
|
||||||
return (uint32_t *) s1;
|
return (uint32_t *) haystack;
|
||||||
}
|
}
|
||||||
if (is_empty(s1)) {
|
if (is_empty(haystack)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (skip < 0) {
|
if (skip < 0) {
|
||||||
skip = 0;
|
skip = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t *p = u32_strrchr(s1, s2[0]);
|
uint32_t *p = u32_strrchr(haystack, needle[0]);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (p >= s1) {
|
while (p >= haystack) {
|
||||||
int comp = u32_strncmp(p, s2, s2_len);
|
int comp = u32_strncmp(p, needle, needle_len);
|
||||||
if (comp == 0) {
|
if (comp == 0) {
|
||||||
if (skip--) {
|
if (skip--) {
|
||||||
--p;
|
--p;
|
||||||
|
@ -238,14 +238,14 @@ uint32_t *u32_nspaces(const size_t n);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return pointer to last occurrence of string `s2` in string `s1`.
|
* Return pointer to last occurrence of string `needle` in string `haystack`.
|
||||||
* @param s1 string to search
|
* @param haystack string to search
|
||||||
* @param s2 string to search for in `s1`
|
* @param needle string to search for in `haystack`
|
||||||
* @param s2_len length in characters of `s2`
|
* @param needle_len length in characters of `needle`
|
||||||
* @param skip number of finds to ignore before returning anything
|
* @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