From 80e03855413c7ac3727df572d44131656e467426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 21 Sep 2018 17:57:34 +0200 Subject: line-range.c: remove implicit dependency on the_index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- line-range.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'line-range.c') diff --git a/line-range.c b/line-range.c index 7fa0d8bba5..9b50583dc0 100644 --- a/line-range.c +++ b/line-range.c @@ -163,9 +163,10 @@ static const char *find_funcname_matching_regexp(xdemitconf_t *xecfg, const char } } -static const char *parse_range_funcname(const char *arg, nth_line_fn_t nth_line_cb, - void *cb_data, long lines, long anchor, long *begin, long *end, - const char *path) +static const char *parse_range_funcname( + const char *arg, nth_line_fn_t nth_line_cb, + void *cb_data, long lines, long anchor, long *begin, long *end, + const char *path, struct index_state *istate) { char *pattern; const char *term; @@ -198,7 +199,7 @@ static const char *parse_range_funcname(const char *arg, nth_line_fn_t nth_line_ anchor--; /* input is in human terms */ start = nth_line_cb(cb_data, anchor); - drv = userdiff_find_by_path(&the_index, path); + drv = userdiff_find_by_path(istate, path); if (drv && drv->funcname.pattern) { const struct userdiff_funcname *pe = &drv->funcname; xecfg = xcalloc(1, sizeof(*xecfg)); @@ -244,7 +245,8 @@ static const char *parse_range_funcname(const char *arg, nth_line_fn_t nth_line_ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb, void *cb_data, long lines, long anchor, - long *begin, long *end, const char *path) + long *begin, long *end, + const char *path, struct index_state *istate) { *begin = *end = 0; @@ -254,7 +256,9 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb, anchor = lines + 1; if (*arg == ':' || (*arg == '^' && *(arg + 1) == ':')) { - arg = parse_range_funcname(arg, nth_line_cb, cb_data, lines, anchor, begin, end, path); + arg = parse_range_funcname(arg, nth_line_cb, cb_data, + lines, anchor, begin, end, + path, istate); if (!arg || *arg) return -1; return 0; @@ -275,10 +279,12 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb, return 0; } -const char *skip_range_arg(const char *arg) +const char *skip_range_arg(const char *arg, struct index_state *istate) { if (*arg == ':' || (*arg == '^' && *(arg + 1) == ':')) - return parse_range_funcname(arg, NULL, NULL, 0, 0, NULL, NULL, NULL); + return parse_range_funcname(arg, NULL, NULL, + 0, 0, NULL, NULL, + NULL, istate); arg = parse_loc(arg, NULL, NULL, 0, -1, NULL); -- cgit v1.2.3