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

[PATCH 1/6] Make read_one_header_line return a flag not a length.

From
Eric W. Biederman <ebiederm@xmission.com>
Date
May 23, 2006, 19:44 UTC
Message-ID
<m14pzgjzlg.fsf@ebiederm.dsl.xmission.com>
In-Reply-To
<m18xosjznu.fsf@ebiederm.dsl.xmission.com>

Currently we only use the return value from read_one_header line to tell if the line we have read is a header or not. So make it a flag. This paves the way for better email detection.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 mailinfo.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
40f4ca44ec851e435ce9453c682c71b9c67063b9
diff --git a/mailinfo.c b/mailinfo.c
index b276519..83a2986 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -331,7 +331,7 @@ struct header_def {
 	int namelen;
 };
 
-static void check_header(char *line, int len, struct header_def *header)
+static void check_header(char *line, struct header_def *header)
 {
 	int i;
 
@@ -349,7 +349,7 @@ static void check_header(char *line, int
 	}
 }
 
-static void check_subheader_line(char *line, int len)
+static void check_subheader_line(char *line)
 {
 	static struct header_def header[] = {
 		{ "Content-Type", handle_subcontent_type },
@@ -357,9 +357,9 @@ static void check_subheader_line(char *l
 		  handle_content_transfer_encoding },
 		{ NULL },
 	};
-	check_header(line, len, header);
+	check_header(line, header);
 }
-static void check_header_line(char *line, int len)
+static void check_header_line(char *line)
 {
 	static struct header_def header[] = {
 		{ "From", handle_from },
@@ -370,7 +370,7 @@ static void check_header_line(char *line
 		  handle_content_transfer_encoding },
 		{ NULL },
 	};
-	check_header(line, len, header);
+	check_header(line, header);
 }
 
 static int read_one_header_line(char *line, int sz, FILE *in)
@@ -709,8 +709,8 @@ static void handle_multipart_body(void)
 		return;
 	/* We are on boundary line.  Start slurping the subhead. */
 	while (1) {
-		int len = read_one_header_line(line, sizeof(line), stdin);
-		if (!len) {
+		int hdr = read_one_header_line(line, sizeof(line), stdin);
+		if (!hdr) {
 			if (handle_multipart_one_part() < 0)
 				return;
 			/* Reset per part headers */
@@ -718,7 +718,7 @@ static void handle_multipart_body(void)
 			charset[0] = 0;
 		}
 		else
-			check_subheader_line(line, len);
+			check_subheader_line(line);
 	}
 	fclose(patchfile);
 	if (!patch_lines) {
@@ -787,15 +787,15 @@ int main(int argc, char **argv)
 		exit(1);
 	}
 	while (1) {
-		int len = read_one_header_line(line, sizeof(line), stdin);
-		if (!len) {
+		int hdr = read_one_header_line(line, sizeof(line), stdin);
+		if (!hdr) {
 			if (multipart_boundary[0])
 				handle_multipart_body();
 			else
 				handle_body();
 			break;
 		}
-		check_header_line(line, len);
+		check_header_line(line);
 	}
 	return 0;
 }
-- 
1.3.2.g5041c-dirty
Previous: Eric W. BiedermanNext: Eric W. Biederman
Message 2 of 10 in “Detect non email patches in git-mailinfo”
  1. 0/6 Detect non email patches in git-mailinfoEric W. Biederman, May 23, 2006
  2. 1/6 Make read_one_header_line return a flag not a length.Eric W. Biederman, May 23, 2006
  3. 2/6 Move B and Q decoding into check header.Eric W. Biederman, May 23, 2006
  4. 3/6 Refactor commit messge handling.Eric W. Biederman, May 23, 2006
  5. 4/6 In handle_body only read a line if we don't already have one.Eric W. Biederman, May 23, 2006
  6. 5/6 More accurately detect header lines in read_one_header_lineEric W. Biederman, May 23, 2006
  7. 6/6 Allow in body headers beyond the in body header prefix.Eric W. Biederman, May 23, 2006
  8. Junio C HamanoMay 26, 2006
  9. Junio C HamanoMay 23, 2006
  10. Eric W. BiedermanMay 26, 2006

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.