diff options
author | Jeff King <peff@peff.net> | 2024-03-12 05:17:32 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-12 13:28:10 -0700 |
commit | a1bb146aaf551db4ff9b4aafaaa2f7a9f9574f93 (patch) | |
tree | 7c6bf2855b7133f7879fe7d0e6198ddbd59f533f /strbuf.c | |
parent | 3a35d96284b4a0551a350707df68f368947630d1 (diff) | |
download | git-a1bb146aaf551db4ff9b4aafaaa2f7a9f9574f93.tar.gz |
strbuf: accept a comment string for strbuf_add_commented_lines()
As part of our transition to multi-byte comment characters, let's take a
NUL-terminated string pointer for strbuf_add_commented_lines() rather
than a single character.
All of the callers have to be adjusted; most can just pass
comment_line_str rather than comment_line_char.
And now our "cheat" in strbuf_commented_addf() can go away, as we can
take the full string from it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.c')
-rw-r--r-- | strbuf.c | 16 |
1 files changed, 3 insertions, 13 deletions
@@ -359,13 +359,9 @@ static void add_lines(struct strbuf *out, } void strbuf_add_commented_lines(struct strbuf *out, const char *buf, - size_t size, char comment_prefix) + size_t size, const char *comment_prefix) { - char prefix[2]; - - prefix[0] = comment_prefix; - prefix[1] = '\0'; - add_lines(out, prefix, buf, size, 1); + add_lines(out, comment_prefix, buf, size, 1); } void strbuf_commented_addf(struct strbuf *sb, const char *comment_prefix, @@ -379,13 +375,7 @@ void strbuf_commented_addf(struct strbuf *sb, const char *comment_prefix, strbuf_vaddf(&buf, fmt, params); va_end(params); - /* - * 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]); + strbuf_add_commented_lines(sb, buf.buf, buf.len, comment_prefix); if (incomplete_line) sb->buf[--sb->len] = '\0'; |