git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brandon Williams <bmwill@google.com>
To: git@vger.kernel.org
Cc: j6t@kdbg.org, sbeller@google.com, avarab@gmail.com,
	pclouds@gmail.com, Brandon Williams <bmwill@google.com>
Subject: [PATCH v2 07/37] apply: rename 'try' variables
Date: Wed, 14 Feb 2018 10:59:29 -0800	[thread overview]
Message-ID: <20180214185959.221906-8-bmwill@google.com> (raw)
In-Reply-To: <20180214185959.221906-1-bmwill@google.com>

Rename C++ keyword in order to bring the codebase closer to being able
to be compiled with a C++ compiler.

Signed-off-by: Brandon Williams <bmwill@google.com>
---
 apply.c | 68 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/apply.c b/apply.c
index 321a9fa68..071f653c6 100644
--- a/apply.c
+++ b/apply.c
@@ -2386,8 +2386,8 @@ static void update_pre_post_images(struct image *preimage,
 static int line_by_line_fuzzy_match(struct image *img,
 				    struct image *preimage,
 				    struct image *postimage,
-				    unsigned long try,
-				    int try_lno,
+				    unsigned long current,
+				    int current_lno,
 				    int preimage_limit)
 {
 	int i;
@@ -2404,9 +2404,9 @@ static int line_by_line_fuzzy_match(struct image *img,
 
 	for (i = 0; i < preimage_limit; i++) {
 		size_t prelen = preimage->line[i].len;
-		size_t imglen = img->line[try_lno+i].len;
+		size_t imglen = img->line[current_lno+i].len;
 
-		if (!fuzzy_matchlines(img->buf + try + imgoff, imglen,
+		if (!fuzzy_matchlines(img->buf + current + imgoff, imglen,
 				      preimage->buf + preoff, prelen))
 			return 0;
 		if (preimage->line[i].flag & LINE_COMMON)
@@ -2443,7 +2443,7 @@ static int line_by_line_fuzzy_match(struct image *img,
 	 */
 	extra_chars = preimage_end - preimage_eof;
 	strbuf_init(&fixed, imgoff + extra_chars);
-	strbuf_add(&fixed, img->buf + try, imgoff);
+	strbuf_add(&fixed, img->buf + current, imgoff);
 	strbuf_add(&fixed, preimage_eof, extra_chars);
 	fixed_buf = strbuf_detach(&fixed, &fixed_len);
 	update_pre_post_images(preimage, postimage,
@@ -2455,8 +2455,8 @@ static int match_fragment(struct apply_state *state,
 			  struct image *img,
 			  struct image *preimage,
 			  struct image *postimage,
-			  unsigned long try,
-			  int try_lno,
+			  unsigned long current,
+			  int current_lno,
 			  unsigned ws_rule,
 			  int match_beginning, int match_end)
 {
@@ -2466,12 +2466,12 @@ static int match_fragment(struct apply_state *state,
 	size_t fixed_len, postlen;
 	int preimage_limit;
 
-	if (preimage->nr + try_lno <= img->nr) {
+	if (preimage->nr + current_lno <= img->nr) {
 		/*
 		 * The hunk falls within the boundaries of img.
 		 */
 		preimage_limit = preimage->nr;
-		if (match_end && (preimage->nr + try_lno != img->nr))
+		if (match_end && (preimage->nr + current_lno != img->nr))
 			return 0;
 	} else if (state->ws_error_action == correct_ws_error &&
 		   (ws_rule & WS_BLANK_AT_EOF)) {
@@ -2482,7 +2482,7 @@ static int match_fragment(struct apply_state *state,
 		 * match with img, and the remainder of the preimage
 		 * must be blank.
 		 */
-		preimage_limit = img->nr - try_lno;
+		preimage_limit = img->nr - current_lno;
 	} else {
 		/*
 		 * The hunk extends beyond the end of the img and
@@ -2492,27 +2492,27 @@ static int match_fragment(struct apply_state *state,
 		return 0;
 	}
 
-	if (match_beginning && try_lno)
+	if (match_beginning && current_lno)
 		return 0;
 
 	/* Quick hash check */
 	for (i = 0; i < preimage_limit; i++)
-		if ((img->line[try_lno + i].flag & LINE_PATCHED) ||
-		    (preimage->line[i].hash != img->line[try_lno + i].hash))
+		if ((img->line[current_lno + i].flag & LINE_PATCHED) ||
+		    (preimage->line[i].hash != img->line[current_lno + i].hash))
 			return 0;
 
 	if (preimage_limit == preimage->nr) {
 		/*
 		 * Do we have an exact match?  If we were told to match
-		 * at the end, size must be exactly at try+fragsize,
-		 * otherwise try+fragsize must be still within the preimage,
+		 * at the end, size must be exactly at current+fragsize,
+		 * otherwise current+fragsize must be still within the preimage,
 		 * and either case, the old piece should match the preimage
 		 * exactly.
 		 */
 		if ((match_end
-		     ? (try + preimage->len == img->len)
-		     : (try + preimage->len <= img->len)) &&
-		    !memcmp(img->buf + try, preimage->buf, preimage->len))
+		     ? (current + preimage->len == img->len)
+		     : (current + preimage->len <= img->len)) &&
+		    !memcmp(img->buf + current, preimage->buf, preimage->len))
 			return 1;
 	} else {
 		/*
@@ -2543,7 +2543,7 @@ static int match_fragment(struct apply_state *state,
 	 */
 	if (state->ws_ignore_action == ignore_ws_change)
 		return line_by_line_fuzzy_match(img, preimage, postimage,
-						try, try_lno, preimage_limit);
+						current, current_lno, preimage_limit);
 
 	if (state->ws_error_action != correct_ws_error)
 		return 0;
@@ -2577,10 +2577,10 @@ static int match_fragment(struct apply_state *state,
 	 */
 	strbuf_init(&fixed, preimage->len + 1);
 	orig = preimage->buf;
-	target = img->buf + try;
+	target = img->buf + current;
 	for (i = 0; i < preimage_limit; i++) {
 		size_t oldlen = preimage->line[i].len;
-		size_t tgtlen = img->line[try_lno + i].len;
+		size_t tgtlen = img->line[current_lno + i].len;
 		size_t fixstart = fixed.len;
 		struct strbuf tgtfix;
 		int match;
@@ -2666,8 +2666,8 @@ static int find_pos(struct apply_state *state,
 		    int match_beginning, int match_end)
 {
 	int i;
-	unsigned long backwards, forwards, try;
-	int backwards_lno, forwards_lno, try_lno;
+	unsigned long backwards, forwards, current;
+	int backwards_lno, forwards_lno, current_lno;
 
 	/*
 	 * If match_beginning or match_end is specified, there is no
@@ -2687,25 +2687,25 @@ static int find_pos(struct apply_state *state,
 	if ((size_t) line > img->nr)
 		line = img->nr;
 
-	try = 0;
+	current = 0;
 	for (i = 0; i < line; i++)
-		try += img->line[i].len;
+		current += img->line[i].len;
 
 	/*
 	 * There's probably some smart way to do this, but I'll leave
 	 * that to the smart and beautiful people. I'm simple and stupid.
 	 */
-	backwards = try;
+	backwards = current;
 	backwards_lno = line;
-	forwards = try;
+	forwards = current;
 	forwards_lno = line;
-	try_lno = line;
+	current_lno = line;
 
 	for (i = 0; ; i++) {
 		if (match_fragment(state, img, preimage, postimage,
-				   try, try_lno, ws_rule,
+				   current, current_lno, ws_rule,
 				   match_beginning, match_end))
-			return try_lno;
+			return current_lno;
 
 	again:
 		if (backwards_lno == 0 && forwards_lno == img->nr)
@@ -2718,8 +2718,8 @@ static int find_pos(struct apply_state *state,
 			}
 			backwards_lno--;
 			backwards -= img->line[backwards_lno].len;
-			try = backwards;
-			try_lno = backwards_lno;
+			current = backwards;
+			current_lno = backwards_lno;
 		} else {
 			if (forwards_lno == img->nr) {
 				i++;
@@ -2727,8 +2727,8 @@ static int find_pos(struct apply_state *state,
 			}
 			forwards += img->line[forwards_lno].len;
 			forwards_lno++;
-			try = forwards;
-			try_lno = forwards_lno;
+			current = forwards;
+			current_lno = forwards_lno;
 		}
 
 	}
-- 
2.16.1.291.g4437f3f132-goog


  parent reply	other threads:[~2018-02-14 19:02 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 22:36 [PATCH 00/37] removal of some c++ keywords Brandon Williams
2018-01-29 22:36 ` [PATCH 01/37] object_info: change member name from 'typename' to 'type_name' Brandon Williams
2018-01-29 22:36 ` [PATCH 02/37] object: rename function " Brandon Williams
2018-01-29 22:36 ` [PATCH 03/37] blame: rename 'this' variables Brandon Williams
2018-01-29 22:36 ` [PATCH 04/37] pack-objects: " Brandon Williams
2018-01-29 22:36 ` [PATCH 05/37] rev-parse: rename 'this' variable Brandon Williams
2018-01-29 22:36 ` [PATCH 06/37] diff: rename 'this' variables Brandon Williams
2018-01-29 22:36 ` [PATCH 07/37] apply: rename 'try' variables Brandon Williams
2018-01-29 22:36 ` [PATCH 08/37] apply: rename 'new' variables Brandon Williams
2018-01-29 22:37 ` [PATCH 09/37] checkout: " Brandon Williams
2018-01-29 22:37 ` [PATCH 10/37] help: " Brandon Williams
2018-01-29 22:37 ` [PATCH 11/37] pack-redundant: " Brandon Williams
2018-01-29 22:37 ` [PATCH 12/37] reflog: " Brandon Williams
2018-01-29 22:37 ` [PATCH 13/37] remote: " Brandon Williams
2018-01-29 22:37 ` [PATCH 14/37] combine-diff: " Brandon Williams
2018-01-29 22:37 ` [PATCH 15/37] commit: " Brandon Williams
2018-01-29 22:37 ` [PATCH 16/37] diff-lib: rename 'new' variable Brandon Williams
2018-01-29 22:37 ` [PATCH 17/37] diff: rename 'new' variables Brandon Williams
2018-01-29 22:37 ` [PATCH 18/37] diffcore-delta: " Brandon Williams
2018-01-29 22:37 ` [PATCH 19/37] entry: " Brandon Williams
2018-01-29 22:37 ` [PATCH 20/37] http: " Brandon Williams
2018-01-29 22:37 ` [PATCH 21/37] imap-send: " Brandon Williams
2018-01-29 22:37 ` [PATCH 22/37] line-log: " Brandon Williams
2018-01-29 22:37 ` [PATCH 23/37] read-cache: " Brandon Williams
2018-01-29 22:37 ` [PATCH 24/37] ref-filter: " Brandon Williams
2018-01-29 22:37 ` [PATCH 25/37] remote: " Brandon Williams
2018-01-29 22:37 ` [PATCH 26/37] split-index: " Brandon Williams
2018-01-29 22:37 ` [PATCH 27/37] submodule: " Brandon Williams
2018-01-29 22:37 ` [PATCH 28/37] trailer: " Brandon Williams
2018-01-29 22:37 ` [PATCH 29/37] unpack-trees: " Brandon Williams
2018-01-29 22:37 ` [PATCH 30/37] init-db: rename 'template' variables Brandon Williams
2018-01-29 22:37 ` [PATCH 31/37] environment: " Brandon Williams
2018-01-29 22:37 ` [PATCH 32/37] diff: " Brandon Williams
2018-01-29 22:37 ` [PATCH 33/37] environment: rename 'namespace' variables Brandon Williams
2018-01-29 22:37 ` [PATCH 34/37] wrapper: rename 'template' variables Brandon Williams
2018-01-29 22:37 ` [PATCH 35/37] tempfile: " Brandon Williams
2018-01-29 22:37 ` [PATCH 36/37] trailer: " Brandon Williams
2018-01-29 22:37 ` [PATCH 37/37] replace: rename 'new' variables Brandon Williams
2018-01-30 22:58   ` Stefan Beller
2018-01-30 23:21     ` Junio C Hamano
2018-01-30  0:13 ` [PATCH 00/37] removal of some c++ keywords Duy Nguyen
2018-01-30 22:36   ` Junio C Hamano
2018-01-30 23:01     ` Stefan Beller
2018-01-31  0:48       ` Duy Nguyen
2018-01-31  0:57         ` Stefan Beller
2018-01-31  1:05           ` Duy Nguyen
2018-01-30 20:54 ` Johannes Sixt
2018-02-14 18:59 ` [PATCH v2 " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 01/37] object_info: change member name from 'typename' to 'type_name' Brandon Williams
2018-02-14 18:59   ` [PATCH v2 02/37] object: rename function " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 03/37] blame: rename 'this' variables Brandon Williams
2018-02-14 18:59   ` [PATCH v2 04/37] pack-objects: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 05/37] rev-parse: rename 'this' variable Brandon Williams
2018-02-14 18:59   ` [PATCH v2 06/37] diff: rename 'this' variables Brandon Williams
2018-02-14 21:19     ` Junio C Hamano
2018-02-14 21:24       ` Brandon Williams
2018-02-14 18:59   ` Brandon Williams [this message]
2018-02-14 18:59   ` [PATCH v2 08/37] apply: rename 'new' variables Brandon Williams
2018-02-14 21:40     ` Stefan Beller
2018-02-14 18:59   ` [PATCH v2 09/37] checkout: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 10/37] help: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 11/37] pack-redundant: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 12/37] reflog: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 13/37] remote: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 14/37] combine-diff: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 15/37] commit: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 16/37] diff-lib: rename 'new' variable Brandon Williams
2018-02-14 18:59   ` [PATCH v2 17/37] diff: rename 'new' variables Brandon Williams
2018-02-14 18:59   ` [PATCH v2 18/37] diffcore-delta: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 19/37] entry: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 20/37] http: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 21/37] imap-send: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 22/37] line-log: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 23/37] read-cache: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 24/37] ref-filter: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 25/37] remote: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 26/37] split-index: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 27/37] submodule: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 28/37] trailer: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 29/37] unpack-trees: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 30/37] init-db: rename 'template' variables Brandon Williams
2018-02-14 18:59   ` [PATCH v2 31/37] environment: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 32/37] diff: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 33/37] environment: rename 'namespace' variables Brandon Williams
2018-02-14 18:59   ` [PATCH v2 34/37] wrapper: rename 'template' variables Brandon Williams
2018-02-14 18:59   ` [PATCH v2 35/37] tempfile: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 36/37] trailer: " Brandon Williams
2018-02-14 18:59   ` [PATCH v2 37/37] replace: rename 'new' variables Brandon Williams
2018-02-14 22:41   ` [PATCH v2 00/37] removal of some c++ keywords Stefan Beller

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=20180214185959.221906-8-bmwill@google.com \
    --to=bmwill@google.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=pclouds@gmail.com \
    --cc=sbeller@google.com \
    /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).