[PATCH v2] Prefer fgetc over fgets where possible
- From
- AreaZR via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Dec 18, 2024, 01:16 UTC
- Message-ID
- <pull.1550.v2.git.git.1734484601471.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1550.git.git.1689608291732.gitgitgadget@gmail.com>
From: Seija Kijin <doremylover123@gmail.com>
fputc is meant for single characters, fputs is for strings. We are better off inserting sole \n characters as characters, not whole strings.
Signed-off-by: Seija Kijin doremylover123@gmail.com
---
Prefer fgetc over fgets where possible
fputc is meant for single characters, fputs is for strings. We are
better off inserting sole \n characters as characters, not whole
strings.Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1550%2FAreaZR%2Ffgetc-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1550/AreaZR/fgetc-v2 Pull-Request: https://github.com/git/git/pull/1550
Range-diff vs v1:
1: f833a7cc857 ! 1: 26f329befbd Prefer fgetc over fgets where possible
@@ Commit message
Signed-off-by: Seija Kijin doremylover123@gmail.com
+ ## bisect.c ##
+@@ bisect.c: static void show_list(const char *debug, int counted, int nr,
+ subject_len = find_commit_subject(buf, &subject_start);
+ if (subject_len)
+ fprintf(stderr, " %.*s", subject_len, subject_start);
+- fprintf(stderr, "\n");
++ fputc('\n', stderr);
+ }
+ }
+
+
+ ## commit-graph.c ##
+@@ commit-graph.c: static void graph_report(const char *fmt, ...)
+ verify_commit_graph_error = 1;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+- fprintf(stderr, "\n");
++ fputc('\n', stderr);
+ va_end(ap);
+ }
+
+
## wt-status.c ##
@@ wt-status.c: static void wt_longstatus_print_tracking(struct wt_status *s)
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
- comment_line_char);
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%s",
+ comment_line_str);
else
- fputs("\n", s->fp);
+ fputc('\n', s->fp);bisect.c | 2 +- commit-graph.c | 2 +- wt-status.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/bisect.c b/bisect.c index d71c4e4b44b..3b1e034013f 100644 --- a/bisect.c +++ b/bisect.c @@ -179,7 +179,7 @@ static void show_list(const char *debug, int counted, int nr, subject_len = find_commit_subject(buf, &subject_start); if (subject_len) fprintf(stderr, " %.*s", subject_len, subject_start); - fprintf(stderr, "\n"); + fputc('\n', stderr); } } diff --git a/commit-graph.c b/commit-graph.c index e2e2083951c..b649598916a 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -2696,7 +2696,7 @@ static void graph_report(const char *fmt, ...) verify_commit_graph_error = 1; va_start(ap, fmt); vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); + fputc('\n', stderr); va_end(ap); } diff --git a/wt-status.c b/wt-status.c index 6a8c05d1cff..75b8e900a4c 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1227,7 +1227,7 @@ static void wt_longstatus_print_tracking(struct wt_status *s) color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%s", comment_line_str); else - fputs("\n", s->fp); + fputc('\n', s->fp); strbuf_release(&sb); } @@ -1832,7 +1832,7 @@ static void wt_longstatus_print_state(struct wt_status *s) if (state->merge_in_progress) { if (state->rebase_interactive_in_progress) { show_rebase_information(s, state_color); - fputs("\n", s->fp); + fputc('\n', s->fp); } show_merge_in_progress(s, state_color); } else if (state->am_in_progress) base-commit: 063bcebf0c917140ca0e705cbe0fdea127e90086
-- gitgitgadget