git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Prefer fgetc over fgets where possible

From
AGAtariDreams via GitGitGadget <gitgitgadget@gmail.com>
Date
Jul 17, 2023, 15:38 UTC
Message-ID
<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.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1550%2FAtariDreams%2Ffgetc-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1550/AtariDreams/fgetc-v1
Pull-Request: https://github.com/git/git/pull/1550
 wt-status.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 8a1a4fb1f04..4c267395cdf 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1215,7 +1215,7 @@ static void wt_longstatus_print_tracking(struct wt_status *s)
 		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
 				 comment_line_char);
 	else
-		fputs("\n", s->fp);
+		fputc('\n', s->fp);
 	strbuf_release(&sb);
 }
 
@@ -1814,7 +1814,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: 830b4a04c45bf0a6db26defe02ed1f490acd18ee
-- 
gitgitgadget
Next: Junio C Hamano
Message 1 of 4 in “Prefer fgetc over fgets where possible”
  1. Prefer fgetc over fgets where possibleAtariDreams via GitGitGadget, Jul 17, 2023
  2. Junio C HamanoJul 17, 2023
  3. Taylor BlauJul 17, 2023
  4. Prefer fgetc over fgets where possibleAreaZR via GitGitGadget, Dec 18, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.