From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>,
Vegard Nossum <vegard.nossum@oracle.com>
Subject: [PATCH 2/6] xdiff: factor out is_func_rec()
Date: Sat, 18 Nov 2017 19:04:40 +0100 [thread overview]
Message-ID: <4efcd033-ab8d-7b0c-0c2f-8e5b5cdd5e0c@web.de> (raw)
In-Reply-To: <790c2344-a71e-7089-9000-f9b37a4a5cd9@web.de>
Add a helper for checking if a given record is a function line. It
frees callers from having to deal with the buffer arguments of
match_func_rec().
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
xdiff/xemit.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index 6881445e4a..c2d5bd004c 100644
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
@@ -121,6 +121,12 @@ static long match_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri,
return xecfg->find_func(rec, len, buf, sz, xecfg->find_func_priv);
}
+static int is_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri)
+{
+ char dummy[1];
+ return match_func_rec(xdf, xecfg, ri, dummy, sizeof(dummy)) >= 0;
+}
+
struct func_line {
long len;
char buf[80];
@@ -178,7 +184,6 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
/* Appended chunk? */
if (i1 >= xe->xdf1.nrec) {
- char dummy[1];
long i2 = xch->i2;
/*
@@ -186,8 +191,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
* a whole function was added.
*/
while (i2 < xe->xdf2.nrec) {
- if (match_func_rec(&xe->xdf2, xecfg, i2,
- dummy, sizeof(dummy)) >= 0)
+ if (is_func_rec(&xe->xdf2, xecfg, i2))
goto post_context_calculation;
i2++;
}
--
2.15.0
next prev parent reply other threads:[~2017-11-18 18:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-18 18:01 [PATCH 0/6] show non-empty lines before functions with diff/grep -W René Scharfe
2017-11-18 18:04 ` [PATCH 1/6] t4051: add test for comments preceding function lines René Scharfe
2017-11-19 1:18 ` Eric Sunshine
2017-11-19 10:02 ` René Scharfe
2017-11-20 0:36 ` Junio C Hamano
2017-11-20 17:28 ` René Scharfe
2017-11-21 0:37 ` Junio C Hamano
2017-11-18 18:04 ` René Scharfe [this message]
2017-11-18 18:05 ` [PATCH 3/6] xdiff: show non-empty lines before functions with -W René Scharfe
2017-11-18 18:06 ` [PATCH 4/6] t7810: improve check of -W with user-defined function lines René Scharfe
2017-11-18 18:07 ` [PATCH 5/6] grep: update boundary variable for pre-context René Scharfe
2017-11-18 18:08 ` [PATCH 6/6] grep: show non-empty lines before functions with -W René Scharfe
2017-11-20 20:39 ` Stefan Beller
2017-11-20 22:07 ` René Scharfe
2017-11-21 23:35 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4efcd033-ab8d-7b0c-0c2f-8e5b5cdd5e0c@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=vegard.nossum@oracle.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).