git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "AreaZR via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: AreaZR <gfunni234@gmail.com>, Seija Kijin <doremylover123@gmail.com>
Subject: [PATCH v2] Prefer fgetc over fgets where possible
Date: Wed, 18 Dec 2024 01:16:41 +0000	[thread overview]
Message-ID: <pull.1550.v2.git.git.1734484601471.gitgitgadget@gmail.com> (raw)
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

      parent reply	other threads:[~2024-12-18  1:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 15:38 [PATCH] Prefer fgetc over fgets where possible AtariDreams via GitGitGadget
2023-07-17 16:51 ` Junio C Hamano
2023-07-17 20:14 ` Taylor Blau
2024-12-18  1:16 ` AreaZR via GitGitGadget [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.1550.v2.git.git.1734484601471.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=doremylover123@gmail.com \
    --cc=gfunni234@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).