return false;
}
+/* If SS begins with TARGET, except possibly for case differences, removes it
+ and returns true. Otherwise, returns false without changing SS. */
+bool
+ss_match_string_case (struct substring *ss, const struct substring target)
+{
+ size_t length = ss_length (target);
+ if (ss_equals_case (ss_head (*ss, length), target))
+ {
+ ss_advance (ss, length);
+ return true;
+ }
+ else
+ return false;
+}
+
/* Removes the first byte from SS and returns it.
If SS is empty, returns EOF without modifying SS. */
int
&& !memcmp (ss.string, prefix.string, prefix.length));
}
+/* Returns true if SS starts with PREFIX in any case, false otherwise. */
+bool
+ss_starts_with_case (struct substring ss, struct substring prefix)
+{
+ return (ss.length >= prefix.length
+ && !memcasecmp (ss.string, prefix.string, prefix.length));
+}
+
/* Returns true if SS ends with SUFFIX, false otherwise. */
bool
ss_ends_with (struct substring ss, struct substring suffix)
suffix.length));
}
+/* Returns true if SS ends with SUFFIX in any case, false otherwise. */
+bool
+ss_ends_with_case (struct substring ss, struct substring suffix)
+{
+ return (ss.length >= suffix.length
+ && !memcasecmp (&ss.string[ss.length - suffix.length], suffix.string,
+ suffix.length));
+}
+
/* Returns the number of contiguous bytes at the beginning
of SS that are in SKIP_SET. */
size_t
st->ss.length += u8_uctomb (CHAR_CAST (uint8_t *, ds_end (st)), uc, 6);
}
+/* Appends N copies of S to ST. */
+void
+ds_put_substring_multiple (struct string *dst, struct substring src, size_t n)
+{
+ char *p = ds_put_uninit (dst, n * src.length);
+ for (size_t i = 0; i < n; i++)
+ {
+ memcpy (p, src.string, src.length);
+ p += src.length;
+ }
+}
+
/* If relocation has been enabled, replace ST,
with its relocated version */
void