git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 4/7] diff.c: refactor fn_out_diff_words_write_helper()
Date: Thu, 31 Dec 2015 19:37:34 +0700	[thread overview]
Message-ID: <1451565457-18756-5-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1451565457-18756-1-git-send-email-pclouds@gmail.com>

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 diff.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/diff.c b/diff.c
index 1354368..8a9e42f 100644
--- a/diff.c
+++ b/diff.c
@@ -807,12 +807,13 @@ static void diff_words_append(struct diff_words_data *diff_words,
 	buffer->text.ptr[buffer->text.size] = '\0';
 }
 
-static int fn_out_diff_words_write_helper(FILE *fp,
+static int fn_out_diff_words_write_helper(struct diff_words_data *dw,
 					  struct diff_words_style_elem *st_el,
 					  const char *newline,
 					  size_t count, const char *buf,
 					  const char *line_prefix)
 {
+	FILE *fp = dw->opt->file;
 	int print = 0;
 
 	while (count) {
@@ -919,7 +920,7 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)
 		fputs(line_prefix, diff_words->opt->file);
 	}
 	if (diff_words->current_plus != plus_begin) {
-		fn_out_diff_words_write_helper(diff_words->opt->file,
+		fn_out_diff_words_write_helper(diff_words,
 				&style->ctx, style->newline,
 				plus_begin - diff_words->current_plus,
 				diff_words->current_plus, line_prefix);
@@ -927,13 +928,13 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)
 			fputs(line_prefix, diff_words->opt->file);
 	}
 	if (minus_begin != minus_end) {
-		fn_out_diff_words_write_helper(diff_words->opt->file,
+		fn_out_diff_words_write_helper(diff_words,
 				&style->old, style->newline,
 				minus_end - minus_begin, minus_begin,
 				line_prefix);
 	}
 	if (plus_begin != plus_end) {
-		fn_out_diff_words_write_helper(diff_words->opt->file,
+		fn_out_diff_words_write_helper(diff_words,
 				&style->new, style->newline,
 				plus_end - plus_begin, plus_begin,
 				line_prefix);
@@ -1030,7 +1031,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
 	/* special case: only removal */
 	if (!diff_words->plus.text.size) {
 		fputs(line_prefix, diff_words->opt->file);
-		fn_out_diff_words_write_helper(diff_words->opt->file,
+		fn_out_diff_words_write_helper(diff_words,
 			&style->old, style->newline,
 			diff_words->minus.text.size,
 			diff_words->minus.text.ptr, line_prefix);
@@ -1040,7 +1041,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
 	/* special case: only addition */
 	if (!diff_words->minus.text.size) {
 		fputs(line_prefix, diff_words->opt->file);
-		fn_out_diff_words_write_helper(diff_words->opt->file,
+		fn_out_diff_words_write_helper(diff_words,
 			&style->new, style->newline,
 			diff_words->plus.text.size,
 			diff_words->plus.text.ptr, line_prefix);
@@ -1067,7 +1068,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
 			diff_words->plus.text.size) {
 		if (color_words_output_graph_prefix(diff_words))
 			fputs(line_prefix, diff_words->opt->file);
-		fn_out_diff_words_write_helper(diff_words->opt->file,
+		fn_out_diff_words_write_helper(diff_words,
 			&style->ctx, style->newline,
 			diff_words->plus.text.ptr + diff_words->plus.text.size
 			- diff_words->current_plus, diff_words->current_plus,
-- 
2.3.0.rc1.137.g477eb31

  parent reply	other threads:[~2015-12-31 12:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-31 12:37 A failed attempt to integrate diff-highlight to the core Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 1/7] diff.c: keep all word diff structs together Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 2/7] diff.c: refactor diff_words_append() Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 3/7] diff --color-words: another special diff case Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` Nguyễn Thái Ngọc Duy [this message]
2015-12-31 12:37 ` [PATCH 5/7] diff: unified diff with colored words, step 1, unified diff only Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 6/7] diff.c: add new arguments to emit_line_0() Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 7/7] diff --highlight-words: actually highlight words Nguyễn Thái Ngọc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1451565457-18756-5-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).