diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-07-11 10:31:05 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-07-11 10:31:05 -0700 |
commit | 3c5de5c77b0718b47010b146160ecff6309f86b5 (patch) | |
tree | 10dfe3c6e701fab8fee60d0059a07b72cfd34c59 /git-compat-util.h | |
parent | bb2d8a817df91c68742e10ace2a791de176f7247 (diff) | |
parent | 9dc3515cf005639317fb95492b3157aadf056923 (diff) | |
download | git-3c5de5c77b0718b47010b146160ecff6309f86b5.tar.gz |
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
Diffstat (limited to 'git-compat-util.h')
-rw-r--r-- | git-compat-util.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h index 49d4029b8d..c99cddc54b 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -474,6 +474,23 @@ static inline int skip_prefix(const char *str, const char *prefix, } /* + * 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. */ |