mirror of
https://github.com/git/git.git
synced 2026-01-10 10:13:33 +00:00
strbuf: accept a comment string for strbuf_commented_addf()
As part of our transition to multi-byte comment characters, let's take a NUL-terminated string pointer for strbuf_commented_addf() rather than a single character. All of the callers have to be adjusted, but they can just pass comment_line_str rather than comment_line_char. Note that we rely on strbuf_add_commented_lines() under the hood, so we'll cheat a bit to squeeze our string into a single character (for now the two are equivalent, and we'll address this TODO in the next patch). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
2982b65690
commit
3a35d96284
10
strbuf.c
10
strbuf.c
@@ -368,7 +368,7 @@ void strbuf_add_commented_lines(struct strbuf *out, const char *buf,
|
||||
add_lines(out, prefix, buf, size, 1);
|
||||
}
|
||||
|
||||
void strbuf_commented_addf(struct strbuf *sb, char comment_prefix,
|
||||
void strbuf_commented_addf(struct strbuf *sb, const char *comment_prefix,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list params;
|
||||
@@ -379,7 +379,13 @@ void strbuf_commented_addf(struct strbuf *sb, char comment_prefix,
|
||||
strbuf_vaddf(&buf, fmt, params);
|
||||
va_end(params);
|
||||
|
||||
strbuf_add_commented_lines(sb, buf.buf, buf.len, comment_prefix);
|
||||
/*
|
||||
* TODO Our commented_lines helper does not yet understand
|
||||
* comment strings. But since we know that the strings are
|
||||
* always single-char, we can cheat for the moment, and
|
||||
* fix this later.
|
||||
*/
|
||||
strbuf_add_commented_lines(sb, buf.buf, buf.len, comment_prefix[0]);
|
||||
if (incomplete_line)
|
||||
sb->buf[--sb->len] = '\0';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user