apply: rename 'try' variables
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Feb 14, 2018 at 10:59 UTC
6cbc7cfdfed54c060db663374ccad45758c7e718
1 file changed
+34
-34
apply.c
+34
-34
@@ -2386,8 +2386,8 @@ static void update_pre_post_images(struct image *preimage,
2386
static int line_by_line_fuzzy_match(struct image *img,
2387
struct image *preimage,
2388
struct image *postimage,
2389
- unsigned long try,
2390
- int try_lno,
2389
+ unsigned long current,
2390
+ int current_lno,
2391
int preimage_limit)
2392
{
2393
int i;
@@ -2404,9 +2404,9 @@ static int line_by_line_fuzzy_match(struct image *img,
2404
2405
for (i = 0; i < preimage_limit; i++) {
2406
size_t prelen = preimage->line[i].len;
2407
- size_t imglen = img->line[try_lno+i].len;
2407
+ size_t imglen = img->line[current_lno+i].len;
2408
2409
- if (!fuzzy_matchlines(img->buf + try + imgoff, imglen,
2409
+ if (!fuzzy_matchlines(img->buf + current + imgoff, imglen,
2410
preimage->buf + preoff, prelen))
2411
return 0;
2412
if (preimage->line[i].flag & LINE_COMMON)
@@ -2443,7 +2443,7 @@ static int line_by_line_fuzzy_match(struct image *img,
2443
*/
2444
extra_chars = preimage_end - preimage_eof;
2445
strbuf_init(&fixed, imgoff + extra_chars);
2446
- strbuf_add(&fixed, img->buf + try, imgoff);
2446
+ strbuf_add(&fixed, img->buf + current, imgoff);
2447
strbuf_add(&fixed, preimage_eof, extra_chars);
2448
fixed_buf = strbuf_detach(&fixed, &fixed_len);
2449
update_pre_post_images(preimage, postimage,
@@ -2455,8 +2455,8 @@ static int match_fragment(struct apply_state *state,
2455
struct image *img,
2456
struct image *preimage,
2457
struct image *postimage,
2458
- unsigned long try,
2459
- int try_lno,
2458
+ unsigned long current,
2459
+ int current_lno,
2460
unsigned ws_rule,
2461
int match_beginning, int match_end)
2462
{
@@ -2466,12 +2466,12 @@ static int match_fragment(struct apply_state *state,
2466
size_t fixed_len, postlen;
2467
int preimage_limit;
2468
2469
- if (preimage->nr + try_lno <= img->nr) {
2469
+ if (preimage->nr + current_lno <= img->nr) {
2470
/*
2471
* The hunk falls within the boundaries of img.
2472
*/
2473
preimage_limit = preimage->nr;
2474
- if (match_end && (preimage->nr + try_lno != img->nr))
2474
+ if (match_end && (preimage->nr + current_lno != img->nr))
2475
return 0;
2476
} else if (state->ws_error_action == correct_ws_error &&
2477
(ws_rule & WS_BLANK_AT_EOF)) {
@@ -2482,7 +2482,7 @@ static int match_fragment(struct apply_state *state,
2482
* match with img, and the remainder of the preimage
2483
* must be blank.
2484
*/
2485
- preimage_limit = img->nr - try_lno;
2485
+ preimage_limit = img->nr - current_lno;
2486
} else {
2487
/*
2488
* The hunk extends beyond the end of the img and
@@ -2492,27 +2492,27 @@ static int match_fragment(struct apply_state *state,
2492
return 0;
2493
}
2494
2495
- if (match_beginning && try_lno)
2495
+ if (match_beginning && current_lno)
2496
return 0;
2497
2498
/* Quick hash check */
2499
for (i = 0; i < preimage_limit; i++)
2500
- if ((img->line[try_lno + i].flag & LINE_PATCHED) ||
2501
- (preimage->line[i].hash != img->line[try_lno + i].hash))
2500
+ if ((img->line[current_lno + i].flag & LINE_PATCHED) ||
2501
+ (preimage->line[i].hash != img->line[current_lno + i].hash))
2502
return 0;
2503
2504
if (preimage_limit == preimage->nr) {
2505
/*
2506
* Do we have an exact match? If we were told to match
2507
- * at the end, size must be exactly at try+fragsize,
2508
- * otherwise try+fragsize must be still within the preimage,
2507
+ * at the end, size must be exactly at current+fragsize,
2508
+ * otherwise current+fragsize must be still within the preimage,
2509
* and either case, the old piece should match the preimage
2510
* exactly.
2511
*/
2512
if ((match_end
2513
- ? (try + preimage->len == img->len)
2514
- : (try + preimage->len <= img->len)) &&
2515
- !memcmp(img->buf + try, preimage->buf, preimage->len))
2513
+ ? (current + preimage->len == img->len)
2514
+ : (current + preimage->len <= img->len)) &&
2515
+ !memcmp(img->buf + current, preimage->buf, preimage->len))
2516
return 1;
2517
} else {
2518
/*
@@ -2543,7 +2543,7 @@ static int match_fragment(struct apply_state *state,
2543
*/
2544
if (state->ws_ignore_action == ignore_ws_change)
2545
return line_by_line_fuzzy_match(img, preimage, postimage,
2546
- try, try_lno, preimage_limit);
2546
+ current, current_lno, preimage_limit);
2547
2548
if (state->ws_error_action != correct_ws_error)
2549
return 0;
@@ -2577,10 +2577,10 @@ static int match_fragment(struct apply_state *state,
2577
*/
2578
strbuf_init(&fixed, preimage->len + 1);
2579
orig = preimage->buf;
2580
- target = img->buf + try;
2580
+ target = img->buf + current;
2581
for (i = 0; i < preimage_limit; i++) {
2582
size_t oldlen = preimage->line[i].len;
2583
- size_t tgtlen = img->line[try_lno + i].len;
2583
+ size_t tgtlen = img->line[current_lno + i].len;
2584
size_t fixstart = fixed.len;
2585
struct strbuf tgtfix;
2586
int match;
@@ -2666,8 +2666,8 @@ static int find_pos(struct apply_state *state,
2666
int match_beginning, int match_end)
2667
{
2668
int i;
2669
- unsigned long backwards, forwards, try;
2670
- int backwards_lno, forwards_lno, try_lno;
2669
+ unsigned long backwards, forwards, current;
2670
+ int backwards_lno, forwards_lno, current_lno;
2671
2672
/*
2673
* If match_beginning or match_end is specified, there is no
@@ -2687,25 +2687,25 @@ static int find_pos(struct apply_state *state,
2687
if ((size_t) line > img->nr)
2688
line = img->nr;
2689
2690
- try = 0;
2690
+ current = 0;
2691
for (i = 0; i < line; i++)
2692
- try += img->line[i].len;
2692
+ current += img->line[i].len;
2693
2694
/*
2695
* There's probably some smart way to do this, but I'll leave
2696
* that to the smart and beautiful people. I'm simple and stupid.
2697
*/
2698
- backwards = try;
2698
+ backwards = current;
2699
backwards_lno = line;
2700
- forwards = try;
2700
+ forwards = current;
2701
forwards_lno = line;
2702
- try_lno = line;
2702
+ current_lno = line;
2703
2704
for (i = 0; ; i++) {
2705
if (match_fragment(state, img, preimage, postimage,
2706
- try, try_lno, ws_rule,
2706
+ current, current_lno, ws_rule,
2707
match_beginning, match_end))
2708
- return try_lno;
2708
+ return current_lno;
2709
2710
again:
2711
if (backwards_lno == 0 && forwards_lno == img->nr)
@@ -2718,8 +2718,8 @@ static int find_pos(struct apply_state *state,
2718
}
2719
backwards_lno--;
2720
backwards -= img->line[backwards_lno].len;
2721
- try = backwards;
2722
- try_lno = backwards_lno;
2721
+ current = backwards;
2722
+ current_lno = backwards_lno;
2723
} else {
2724
if (forwards_lno == img->nr) {
2725
i++;
@@ -2727,8 +2727,8 @@ static int find_pos(struct apply_state *state,
2727
}
2728
forwards += img->line[forwards_lno].len;
2729
forwards_lno++;
2730
- try = forwards;
2731
- try_lno = forwards_lno;
2730
+ current = forwards;
2731
+ current_lno = forwards_lno;
2732
}
2733
2734
}