mirror of
https://github.com/systemd/systemd
synced 2024-09-16 06:43:18 +00:00
string-util-fundamental: postfix -> suffix, use streq
This commit is contained in:
parent
2a02a8db91
commit
3c1e6909d5
|
@ -33,14 +33,14 @@ sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) {
|
|||
return (sd_char*) s + l;
|
||||
}
|
||||
|
||||
sd_char* endswith(const sd_char *s, const sd_char *postfix) {
|
||||
sd_char* endswith(const sd_char *s, const sd_char *suffix) {
|
||||
size_t sl, pl;
|
||||
|
||||
assert(s);
|
||||
assert(postfix);
|
||||
assert(suffix);
|
||||
|
||||
sl = strlen(s);
|
||||
pl = strlen(postfix);
|
||||
pl = strlen(suffix);
|
||||
|
||||
if (pl == 0)
|
||||
return (sd_char*) s + sl;
|
||||
|
@ -48,20 +48,20 @@ sd_char* endswith(const sd_char *s, const sd_char *postfix) {
|
|||
if (sl < pl)
|
||||
return NULL;
|
||||
|
||||
if (strcmp(s + sl - pl, postfix) != 0)
|
||||
if (!streq(s + sl - pl, suffix))
|
||||
return NULL;
|
||||
|
||||
return (sd_char*) s + sl - pl;
|
||||
}
|
||||
|
||||
sd_char* endswith_no_case(const sd_char *s, const sd_char *postfix) {
|
||||
sd_char* endswith_no_case(const sd_char *s, const sd_char *suffix) {
|
||||
size_t sl, pl;
|
||||
|
||||
assert(s);
|
||||
assert(postfix);
|
||||
assert(suffix);
|
||||
|
||||
sl = strlen(s);
|
||||
pl = strlen(postfix);
|
||||
pl = strlen(suffix);
|
||||
|
||||
if (pl == 0)
|
||||
return (sd_char*) s + sl;
|
||||
|
@ -69,7 +69,7 @@ sd_char* endswith_no_case(const sd_char *s, const sd_char *postfix) {
|
|||
if (sl < pl)
|
||||
return NULL;
|
||||
|
||||
if (strcasecmp(s + sl - pl, postfix) != 0)
|
||||
if (!strcaseeq(s + sl - pl, suffix))
|
||||
return NULL;
|
||||
|
||||
return (sd_char*) s + sl - pl;
|
||||
|
|
|
@ -59,8 +59,8 @@ static inline size_t strlen_ptr(const sd_char *s) {
|
|||
|
||||
sd_char *startswith(const sd_char *s, const sd_char *prefix) _pure_;
|
||||
sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) _pure_;
|
||||
sd_char *endswith(const sd_char *s, const sd_char *postfix) _pure_;
|
||||
sd_char *endswith_no_case(const sd_char *s, const sd_char *postfix) _pure_;
|
||||
sd_char *endswith(const sd_char *s, const sd_char *suffix) _pure_;
|
||||
sd_char *endswith_no_case(const sd_char *s, const sd_char *suffix) _pure_;
|
||||
|
||||
static inline bool isempty(const sd_char *a) {
|
||||
return !a || a[0] == '\0';
|
||||
|
|
Loading…
Reference in a new issue