[PATCH] commit.c: use strchrnul() to scan for one line

Subsystems: the rest

DORMANTno replies

2 messages, 2 authors, 2016-06-16 · open the first message on its own page

[PATCH] commit.c: use strchrnul() to scan for one line

From: Junio C Hamano <hidden>
Date: 2016-06-16 02:19:24

Signed-off-by: Junio C Hamano <redacted>
---
 commit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/commit.c b/commit.c
index 3f4f371..1f9ee8a 100644
--- a/commit.c
+++ b/commit.c
@@ -415,8 +415,7 @@ int find_commit_subject(const char *commit_buffer, const char **subject)
 		p++;
 	if (*p) {
 		p += 2;
-		for (eol = p; *eol && *eol != '\n'; eol++)
-			; /* do nothing */
+		eol = strchrnul(p, '\n');
 	} else
 		eol = p;
 
-- 
2.8.2-748-gfb85f76

Re: [PATCH] commit.c: use strchrnul() to scan for one line

From: Johannes Schindelin <hidden>
Date: 2016-06-16 02:19:24

Hi Junio,

On Sun, 15 May 2016, Junio C Hamano wrote:
quoted hunk
diff --git a/commit.c b/commit.c
index 3f4f371..1f9ee8a 100644
--- a/commit.c
+++ b/commit.c
@@ -415,8 +415,7 @@ int find_commit_subject(const char *commit_buffer, const char **subject)
 		p++;
 	if (*p) {
 		p += 2;
-		for (eol = p; *eol && *eol != '\n'; eol++)
-			; /* do nothing */
+		eol = strchrnul(p, '\n');
 	} else
 		eol = p;
ACK. This was my fault, when I introduced the code in 9509af68 (Make
git-revert & git-cherry-pick a builtin, 2007-03-01). To be fair,
strchrnul() was introduced only later, in 659c69c (Add strchrnul(),
2007-11-09).

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help