Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin Wan <calvinwan@google.com>2023-06-06 22:48:43 +0300
committerJunio C Hamano <gitster@pobox.com>2023-06-12 23:49:36 +0300
commit787cb8a48ae24ff07fa7c763909bb204bfdc84a7 (patch)
tree3f5081154dbc5b8fedb73cac218d581065637bcc /strbuf.h
parentaba070683295a20bdf4f49146384984961c794b2 (diff)
strbuf: remove global variable
As a library that only interacts with other primitives, strbuf should not utilize the comment_line_char global variable within its functions. Therefore, add an additional parameter for functions that use comment_line_char and refactor callers to pass it in instead. strbuf_stripspace() removes the skip_comments boolean and checks if comment_line_char is a non-NUL character to determine whether to skip comments or not. Signed-off-by: Calvin Wan <calvinwan@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.h')
-rw-r--r--strbuf.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/strbuf.h b/strbuf.h
index 5d97e27b99..da91c17257 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -291,7 +291,8 @@ void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
* by a comment character and a blank.
*/
void strbuf_add_commented_lines(struct strbuf *out,
- const char *buf, size_t size);
+ const char *buf, size_t size,
+ char comment_line_char);
/**
@@ -420,8 +421,8 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
* Add a formatted string prepended by a comment character and a
* blank to the buffer.
*/
-__attribute__((format (printf, 2, 3)))
-void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...);
+__attribute__((format (printf, 3, 4)))
+void strbuf_commented_addf(struct strbuf *sb, char comment_line_char, const char *fmt, ...);
__attribute__((format (printf,2,0)))
void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
@@ -543,10 +544,11 @@ int strbuf_getcwd(struct strbuf *sb);
int strbuf_normalize_path(struct strbuf *sb);
/**
- * Strip whitespace from a buffer. The second parameter controls if
- * comments are considered contents to be removed or not.
+ * Strip whitespace from a buffer. If comment_line_char is non-NUL,
+ * then lines beginning with that character are considered comments,
+ * thus removed.
*/
-void strbuf_stripspace(struct strbuf *buf, int skip_comments);
+void strbuf_stripspace(struct strbuf *buf, char comment_line_char);
static inline int strbuf_strip_suffix(struct strbuf *sb, const char *suffix)
{