[PATCH v4 00/35] libify mailinfo and call it directly from am

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The change in the endgame since v3 ($gmane/279832) is almost none
(interdiff attached at the end), so I won't be sending the patches
themselves.  The bulk out of the miniscule interdiff comes from the
fifth "plug strbuf leak" patch.

The patches have been reordered to make the structure of the series
clearer:

Preliminary fixes:

  mailinfo: remove a no-op call convert_to_utf8(it, "")
  mailinfo: fold decode_header_bq() into decode_header()
  mailinfo: fix an off-by-one error in the boundary stack
  mailinfo: explicitly close file handle to the patch output
  mailinfo: plug strbuf leak during continuation line handling

Group related things together and remove forward declarations:

  mailinfo: move handle_boundary() lower
  mailinfo: move read_one_header_line() closer to its callers
  mailinfo: move check_header() after the helpers it uses
  mailinfo: move cleanup_space() before its users
  mailinfo: move definition of MAX_HDR_PARSED closer to its use

Preliminary logic clean-up:

  mailinfo: get rid of function-local static states
  mailinfo: do not let handle_body() touch global "line" directly
  mailinfo: do not let handle_boundary() touch global "line" directly
  mailinfo: do not let find_boundary() touch global "line" directly
  mailinfo: move global "line" into mailinfo() function

Getting rid of the globals:

  mailinfo: introduce "struct mailinfo" to hold globals
  mailinfo: move keep_subject & keep_non_patch_bracket to struct mailinfo
  mailinfo: move global "FILE *fin, *fout" to struct mailinfo
  mailinfo: move filter/header stage to struct mailinfo
  mailinfo: move patch_lines to struct mailinfo
  mailinfo: move add_message_id and message_id to struct mailinfo
  mailinfo: move use_scissors and use_inbody_headers to struct mailinfo
  mailinfo: move metainfo_charset to struct mailinfo
  mailinfo: move check for metainfo_charset to convert_to_utf8()
  mailinfo: move transfer_encoding to struct mailinfo
  mailinfo: move charset to struct mailinfo
  mailinfo: move cmitmsg and patchfile to struct mailinfo
  mailinfo: move [ps]_hdr_data to struct mailinfo
  mailinfo: move content/content_top to struct mailinfo

Libify:

  mailinfo: handle_commit_msg() shouldn't be called after finding patchbreak
  mailinfo: keep the parsed log message in a strbuf
  mailinfo: libify

Lifting the error handling to the caller:

  mailinfo: handle charset conversion errors in the caller
  mailinfo: remove calls to exit() and die() deep in the callchain

Endgame:

  am: make direct call to mailinfo

 Makefile           |    1 +
 builtin/am.c       |   42 ++-
 builtin/mailinfo.c | 1055 +---------------------------------------------------
 mailinfo.c         | 1037 +++++++++++++++++++++++++++++++++++++++++++++++++++
 mailinfo.h         |   41 ++
 5 files changed, 1122 insertions(+), 1054 deletions(-)
 create mode 100644 mailinfo.c
 create mode 100644 mailinfo.h

-- 
2.6.2-377-g450896c


(Interdiff)

diff --git a/mailinfo.c b/mailinfo.c
index 49eaa99..e157ca6 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -729,6 +729,8 @@ static int is_rfc2822_header(const struct strbuf *line)
 
 static int read_one_header_line(struct strbuf *line, FILE *in)
 {
+	struct strbuf continuation = STRBUF_INIT;
+
 	/* Get the first part of the line. */
 	if (strbuf_getline(line, in, '\n'))
 		return 0;
@@ -750,7 +752,6 @@ static int read_one_header_line(struct strbuf *line, FILE *in)
 	 */
 	for (;;) {
 		int peek;
-		struct strbuf continuation = STRBUF_INIT;
 
 		peek = fgetc(in); ungetc(peek, in);
 		if (peek != ' ' && peek != '\t')
@@ -761,6 +762,7 @@ static int read_one_header_line(struct strbuf *line, FILE *in)
 		strbuf_rtrim(&continuation);
 		strbuf_addbuf(line, &continuation);
 	}
+	strbuf_release(&continuation);
 
 	return 1;
 }
diff --git a/mailinfo.h b/mailinfo.h
index 5bf257d..93776a7 100644
--- a/mailinfo.h
+++ b/mailinfo.h
@@ -14,7 +14,7 @@ struct mailinfo {
 	int keep_non_patch_brackets_in_subject;
 	int add_message_id;
 	int use_scissors;
-	int use_inbody_headers; /* defaults to 1 */
+	int use_inbody_headers;
 	const char *metainfo_charset;
 
 	struct strbuf *content[MAX_BOUNDARIES];
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]