mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
util: Add virStringHasSuffix()
This is the case-sensitive counterpart of the existing virStringHasCaseSuffix() function. Signed-off-by: Andrea Bolognani <abologna@redhat.com> ACKed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
b5cc0a7f29
commit
d93b9e8829
@ -2966,6 +2966,7 @@ virStringFilterChars;
|
|||||||
virStringHasCaseSuffix;
|
virStringHasCaseSuffix;
|
||||||
virStringHasChars;
|
virStringHasChars;
|
||||||
virStringHasControlChars;
|
virStringHasControlChars;
|
||||||
|
virStringHasSuffix;
|
||||||
virStringIsEmpty;
|
virStringIsEmpty;
|
||||||
virStringIsPrintable;
|
virStringIsPrintable;
|
||||||
virStringListAdd;
|
virStringListAdd;
|
||||||
|
@ -1235,6 +1235,19 @@ virStringReplace(const char *haystack,
|
|||||||
return virBufferContentAndReset(&buf);
|
return virBufferContentAndReset(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
virStringHasSuffix(const char *str,
|
||||||
|
const char *suffix)
|
||||||
|
{
|
||||||
|
int len = strlen(str);
|
||||||
|
int suffixlen = strlen(suffix);
|
||||||
|
|
||||||
|
if (len < suffixlen)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return STREQ(str + len - suffixlen, suffix);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
virStringHasCaseSuffix(const char *str,
|
virStringHasCaseSuffix(const char *str,
|
||||||
const char *suffix)
|
const char *suffix)
|
||||||
|
@ -288,6 +288,8 @@ char *virStringReplace(const char *haystack,
|
|||||||
const char *newneedle)
|
const char *newneedle)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
||||||
|
|
||||||
|
bool virStringHasSuffix(const char *str,
|
||||||
|
const char *suffix);
|
||||||
int virStringHasCaseSuffix(const char *str,
|
int virStringHasCaseSuffix(const char *str,
|
||||||
const char *suffix);
|
const char *suffix);
|
||||||
int virStringStripSuffix(char *str,
|
int virStringStripSuffix(char *str,
|
||||||
|
Loading…
Reference in New Issue
Block a user