commit.c: use strchrnul() to scan for one line
PATCH 1/1 commit.c: use strchrnul() to scan for one line
--- commit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
commit.c +1 -2
@@ -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;
Signature · 1 line
2.8.2-748-gfb85f76
Hi Junio,
commit.c int find_commit_subject(const char *commit_buffer, const char **subject) · line 420
Quoted 13 lines · Junio C Hamano
commit.c +1
-2@@ -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
Quoted 12 lines · Johannes Schindelin
Quoted 10 lines · Junio C Hamano
commit.c +0
-2@@ -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 */
Quoted 8 lines
commit.c int find_commit_subject(const char *commit_buffer, const char **subject) · line 420
Quoted 3 lines
commit.c +1
-0+ 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 (Addstrchrnul(), 2007-11-09).
Oh, there is no fault.
I was reading through attr.c to see how bad a work to revamp attribute lookup would look like, found a hand-rolled strchrnul() that predates the widespread use of the function, and looked for similar patterns while I was updating it. As there were many false positives (i.e. "Yes, this loop is looking for the end of line, but it does something else to the characters on the line while doing so, so it cannot become strchrnul()") that I needed eyeballing in order to reject and avoid incorrect conversion, it is very much appreciated that you double-checked this one that I spotted.
Thanks.