aboutsummaryrefslogtreecommitdiffstats
path: root/strbuf.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2024-03-12 05:17:29 -0400
committerJunio C Hamano <gitster@pobox.com>2024-03-12 13:28:10 -0700
commit3a35d96284b4a0551a350707df68f368947630d1 (patch)
treedb81191984b7ea8220cf5559181def57c38e059d /strbuf.c
parentstrbuf: accept a comment string for strbuf_stripspace() (diff)
downloadgit-3a35d96284b4a0551a350707df68f368947630d1.tar.gz
git-3a35d96284b4a0551a350707df68f368947630d1.zip
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>
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/strbuf.c b/strbuf.c
index e9b6127e76..76d02e0920 100644
--- a/strbuf.c
+++ b/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';