Merge branch 'jk/ansi-color'
The output coloring scheme learned two new attributes, italic and strike, in addition to existing bold, reverse, etc. * jk/ansi-color: color: support strike-through attribute color: support "italic" attribute color: allow "no-" for negating attributes color: refactor parse_attr add skip_prefix_mem helper doc: refactor description of color format color: fix max-size comment
This commit is contained in:
@ -473,6 +473,23 @@ static inline int skip_prefix(const char *str, const char *prefix,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Like skip_prefix, but promises never to read past "len" bytes of the input
|
||||
* buffer, and returns the remaining number of bytes in "out" via "outlen".
|
||||
*/
|
||||
static inline int skip_prefix_mem(const char *buf, size_t len,
|
||||
const char *prefix,
|
||||
const char **out, size_t *outlen)
|
||||
{
|
||||
size_t prefix_len = strlen(prefix);
|
||||
if (prefix_len <= len && !memcmp(buf, prefix, prefix_len)) {
|
||||
*out = buf + prefix_len;
|
||||
*outlen = len - prefix_len;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If buf ends with suffix, return 1 and subtract the length of the suffix
|
||||
* from *len. Otherwise, return 0 and leave *len untouched.
|
||||
|
Reference in New Issue
Block a user