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

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

From
Junio C Hamano <gitster@pobox.com>
Date
May 15, 2016, 22:28 UTC
Message-ID
<xmqqr3d33qit.fsf@gitster.mtv.corp.google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 attr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/attr.c b/attr.c
index a19946a..a7f2c3f 100644
--- a/attr.c
+++ b/attr.c
@@ -407,8 +407,8 @@ static struct attr_stack *read_attr_from_index(const char *path, int macro_ok)
 	for (sp = buf; *sp; ) {
 		char *ep;
 		int more;
-		for (ep = sp; *ep && *ep != '\n'; ep++)
-			;
+
+		ep = strchrnul(sp, '\n');
 		more = (*ep == '\n');
 		*ep = '\0';
 		handle_attr_line(res, sp, path, ++lineno, macro_ok);
-- 
2.8.2-748-gfb85f76
Message 1 of 1 in “attr.c: use strchrnul() to scan for one line”
  1. attr.c: use strchrnul() to scan for one lineJunio C Hamano, May 15, 2016

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.