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

[PATCH v2] grep: simplify is_empty_line

From
RGRose via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 29, 2022, 17:18 UTC
Message-ID
<pull.1418.v2.git.git.1672334314401.gitgitgadget@gmail.com>
In-Reply-To
<pull.1418.git.git.1672333122193.gitgitgadget@gmail.com>
From: Seija Kijin <doremylover123@gmail.com>
Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    grep: simplify is_empty_line
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1418%2FAtariDreams%2FisEmpty-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1418/AtariDreams/isEmpty-v2
Pull-Request: https://github.com/git/git/pull/1418
Range-diff vs v1:
 1:  03a97005a67 ! 1:  b193c9537de grep: simplify is_empty_line
     @@ grep.c: static int fill_textconv_grep(struct repository *r,
       static int is_empty_line(const char *bol, const char *eol)
       {
      -	while (bol < eol && isspace(*bol))
     --		bol++;
     --	return bol == eol;
     -+	while (bol < eol)
     ++	while (bol < eol) {
      +		if (!isspace(*bol))
      +			return 0;
     + 		bol++;
     +-	return bol == eol;
     ++	}
      +	return 1;
       }
       
 grep.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/grep.c b/grep.c
index 06eed694936..d78ee08da6f 100644
--- a/grep.c
+++ b/grep.c
@@ -1483,9 +1483,12 @@ static int fill_textconv_grep(struct repository *r,
 
 static int is_empty_line(const char *bol, const char *eol)
 {
-	while (bol < eol && isspace(*bol))
+	while (bol < eol) {
+		if (!isspace(*bol))
+			return 0;
 		bol++;
-	return bol == eol;
+	}
+	return 1;
 }
 
 static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int collect_hits)

base-commit: 6bae53b138a1f38d8887f6b46d17661357a1468b
-- 
gitgitgadget
Previous: Eric SunshineNext: Eric Sunshine
Message 3 of 4 in “grep: simplify is_empty_line”
  1. grep: simplify is_empty_lineRose via GitGitGadget, Dec 29, 2022
  2. Eric SunshineDec 29, 2022
  3. grep: simplify is_empty_lineRose via GitGitGadget, Dec 29, 2022
  4. Eric SunshineDec 29, 2022

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.