Rename s1 and s2 parameters of u32_strnrstr to haystack and needle in unicode module

This commit is contained in:
Thomas Jensen 2023-08-05 21:18:29 +02:00
parent f30f12a988
commit 6ce0f86898
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
2 changed files with 13 additions and 13 deletions

View File

@ -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;

View File

@ -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);
/**