diff options
| author | Calvin Wan <calvinwan@google.com> | 2023-06-06 19:48:43 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-06-12 13:49:36 -0700 |
| commit | 787cb8a48ae24ff07fa7c763909bb204bfdc84a7 (patch) | |
| tree | 3f5081154dbc5b8fedb73cac218d581065637bcc /builtin/stripspace.c | |
| parent | aba070683295a20bdf4f49146384984961c794b2 (diff) | |
| download | git-787cb8a48ae24ff07fa7c763909bb204bfdc84a7.tar.gz | |
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 'builtin/stripspace.c')
| -rw-r--r-- | builtin/stripspace.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/stripspace.c b/builtin/stripspace.c index 9451eb69ff..1987752359 100644 --- a/builtin/stripspace.c +++ b/builtin/stripspace.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "cache.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "parse-options.h" #include "setup.h" @@ -13,7 +14,7 @@ static void comment_lines(struct strbuf *buf) size_t len; msg = strbuf_detach(buf, &len); - strbuf_add_commented_lines(buf, msg, len); + strbuf_add_commented_lines(buf, msg, len, comment_line_char); free(msg); } @@ -58,7 +59,8 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix) die_errno("could not read the input"); if (mode == STRIP_DEFAULT || mode == STRIP_COMMENTS) - strbuf_stripspace(&buf, mode == STRIP_COMMENTS); + strbuf_stripspace(&buf, + mode == STRIP_COMMENTS ? comment_line_char : '\0'); else comment_lines(&buf); |
