28 assert(referent !=
NULL);
31 const char *end = strchr(referent, terminator);
33 return (
strview_t){.data = referent, .size = (size_t)(end - referent)};
37 return (
strview_t){.data = referent, .size = strlen(referent)};
108 const char *needle) {
111 assert(needle !=
NULL);
114 if (strcmp(needle,
"") == 0) {
121 const char *candidate = (
const char *)memchr(
123 if (candidate ==
NULL) {
128 if ((
size_t)(haystack.
data + haystack.
size - candidate) < strlen(needle)) {
138 offset = (size_t)(candidate - haystack.
data) + 1;
Memory allocation wrappers that exit on failure.
static char * gv_strndup(const char *original, size_t length)
static int cmp(const void *key, const void *candidate)
swig_ptr_object_handlers offset
static bool startswith(const char *s, const char *prefix)
does the string s begin with the string prefix?
platform abstraction for case-insensitive string functions
a non-owning string reference
const char * data
start of the pointed to string
size_t size
extent of the string in bytes
static bool strview_str_eq(strview_t a, const char *b)
compare a string reference to a string for equality
static bool strview_str_contains(strview_t haystack, const char *needle)
does the given string appear as a substring of the string view?
static int strview_cmp(strview_t a, strview_t b)
compare two string references
static char * strview_str(strview_t source)
make a heap-allocated string from this string view
static bool strview_eq(strview_t a, strview_t b)
compare two string references for equality
static bool strview_case_eq(strview_t a, strview_t b)
compare two string references for case insensitive equality
static strview_t strview(const char *referent, char terminator)
create a string reference
static bool strview_case_str_eq(strview_t a, const char *b)
compare a string reference to a string for case insensitive equality