/* Description: Copy the characters in &substring_t @src to the c-style string @dest. Copy no more than @size - 1 characters, plus the terminating NUL. Return length of @src.  */
size_t match_strlcpy(char *dest, const substring_t *src, size_t size)
/* Description: Copy the characters in &substring_t @src to the c-style string @dest. Copy no more than @size - 1 characters, plus the terminating NUL. Return length of @src.  */
size_t match_strlcpy(char *dest, const substring_t *src, size_t size)
{
	size_t ret = src->to - src->from;
	if (size) {
		size_t len = ret >= size ? size - 1 : ret;
		memcpy(dest, src->from, len);
		dest[len] = '\0';
	}
	return ret;
}