On Mon, May 2, 2011 at 8:39 AM, Bert Wesarg <bert.wesarg@xxxxxxxxxxxxxx> wrote: > Signed-off-by: Bert Wesarg <bert.wesarg@xxxxxxxxxxxxxx> > --- > Âgrep.c |  42 +++++++++++++++++++++--------------------- > Â1 files changed, 21 insertions(+), 21 deletions(-) > > diff --git a/grep.c b/grep.c > index b8eda9e..f21b022 100644 > --- a/grep.c > +++ b/grep.c > @@ -437,7 +437,7 @@ static struct { > Â}; > > Âstatic int match_one_pattern(struct grep_pat *p, char *bol, char *eol, > -              Âenum grep_context ctx, > +              Âunsigned lno, enum grep_context ctx, I'd rename lno to line_nr, so it's more clearer. Also, I'd add the new paramenter at the end, not in some random position (or was there some particular reason to put here but not in the end?). >               regmatch_t *pmatch, int eflags) > Â{ >    Âint hit = 0; > @@ -516,7 +516,7 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol, > Â} > > Âstatic int match_expr_eval(struct grep_expr *x, char *bol, char *eol, > -             Âenum grep_context ctx, int collect_hits) > +             Âunsigned lno, enum grep_context ctx, int collect_hits) > Â{ >    Âint h = 0; >    Âregmatch_t match; > @@ -528,25 +528,25 @@ static int match_expr_eval(struct grep_expr *x, char *bol, char *eol, >        Âh = 1; >        Âbreak; >    Âcase GREP_NODE_ATOM: > -        h = match_one_pattern(x->u.atom, bol, eol, ctx, &match, 0); > +        h = match_one_pattern(x->u.atom, bol, eol, lno, ctx, &match, 0); >        Âbreak; >    Âcase GREP_NODE_NOT: > -        h = !match_expr_eval(x->u.unary, bol, eol, ctx, 0); > +        h = !match_expr_eval(x->u.unary, bol, eol, lno, ctx, 0); >        Âbreak; >    Âcase GREP_NODE_AND: > -        if (!match_expr_eval(x->u.binary.left, bol, eol, ctx, 0)) > +        if (!match_expr_eval(x->u.binary.left, bol, eol, lno, ctx, 0)) >            Âreturn 0; > -        h = match_expr_eval(x->u.binary.right, bol, eol, ctx, 0); > +        h = match_expr_eval(x->u.binary.right, bol, eol, lno, ctx, 0); >        Âbreak; >    Âcase GREP_NODE_OR: >        Âif (!collect_hits) >            Âreturn (match_expr_eval(x->u.binary.left, > -                        bol, eol, ctx, 0) || > +                        bol, eol, lno, ctx, 0) || >                Âmatch_expr_eval(x->u.binary.right, > -                        bol, eol, ctx, 0)); > -        h = match_expr_eval(x->u.binary.left, bol, eol, ctx, 0); > +                        bol, eol, lno, ctx, 0)); > +        h = match_expr_eval(x->u.binary.left, bol, eol, lno, ctx, 0); >        Âx->u.binary.left->hit |= h; > -        h |= match_expr_eval(x->u.binary.right, bol, eol, ctx, 1); > +        h |= match_expr_eval(x->u.binary.right, bol, eol, lno, ctx, 1); >        Âbreak; >    Âdefault: >        Âdie("Unexpected node type (internal error) %d", x->node); > @@ -557,36 +557,36 @@ static int match_expr_eval(struct grep_expr *x, char *bol, char *eol, > Â} > > Âstatic int match_expr(struct grep_opt *opt, char *bol, char *eol, > -           enum grep_context ctx, int collect_hits) > +           unsigned lno, enum grep_context ctx, int collect_hits) > Â{ >    Âstruct grep_expr *x = opt->pattern_expression; > -    return match_expr_eval(x, bol, eol, ctx, collect_hits); > +    return match_expr_eval(x, bol, eol, lno, ctx, collect_hits); > Â} > > Âstatic int match_line(struct grep_opt *opt, char *bol, char *eol, > -           enum grep_context ctx, int collect_hits) > +           unsigned lno, enum grep_context ctx, int collect_hits) > Â{ >    Âstruct grep_pat *p; >    Âregmatch_t match; > >    Âif (opt->extended) > -        return match_expr(opt, bol, eol, ctx, collect_hits); > +        return match_expr(opt, bol, eol, lno, ctx, collect_hits); > >    Â/* we do not call with collect_hits without being extended */ >    Âfor (p = opt->pattern_list; p; p = p->next) { > -        if (match_one_pattern(p, bol, eol, ctx, &match, 0)) > +        if (match_one_pattern(p, bol, eol, lno, ctx, &match, 0)) >            Âreturn 1; >    Â} >    Âreturn 0; > Â} > > Âstatic int match_next_pattern(struct grep_pat *p, char *bol, char *eol, > -               enum grep_context ctx, > +               unsigned lno, enum grep_context ctx, >               Âregmatch_t *pmatch, int eflags) > Â{ >    Âregmatch_t match; > > -    if (!match_one_pattern(p, bol, eol, ctx, &match, eflags)) > +    if (!match_one_pattern(p, bol, eol, lno, ctx, &match, eflags)) >        Âreturn 0; >    Âif (match.rm_so < 0 || match.rm_eo < 0) >        Âreturn 0; > @@ -601,7 +601,7 @@ static int match_next_pattern(struct grep_pat *p, char *bol, char *eol, >    Âreturn 1; > Â} > > -static int next_match(struct grep_opt *opt, char *bol, char *eol, > +static int next_match(struct grep_opt *opt, char *bol, char *eol, unsigned lno, >           Âenum grep_context ctx, regmatch_t *pmatch, int eflags) > Â{ >    Âstruct grep_pat *p; > @@ -614,7 +614,7 @@ static int next_match(struct grep_opt *opt, char *bol, char *eol, >            Âcase GREP_PATTERN: /* atom */ >            Âcase GREP_PATTERN_HEAD: >            Âcase GREP_PATTERN_BODY: > -                hit |= match_next_pattern(p, bol, eol, ctx, > +                hit |= match_next_pattern(p, bol, eol, lno, ctx, >                             Âpmatch, eflags); >                Âbreak; >            Âdefault: > @@ -667,7 +667,7 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol, >        Âelse if (sign == '=') >            Âline_color = opt->color_function; >        Â*eol = '\0'; > -        while (next_match(opt, bol, eol, ctx, &match, eflags)) { > +        while (next_match(opt, bol, eol, lno, ctx, &match, eflags)) { >            Âif (match.rm_so == match.rm_eo) >                Âbreak; > > @@ -911,7 +911,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name, >        Âif ((ctx == GREP_CONTEXT_HEAD) && (eol == bol)) >            Âctx = GREP_CONTEXT_BODY; > > -        hit = match_line(opt, bol, eol, ctx, collect_hits); > +        hit = match_line(opt, bol, eol, lno, ctx, collect_hits); >        Â*eol = ch; > >        Âif (collect_hits) > -- > 1.7.5.349.gfeb1a > > -- > To unsubscribe from this list: send the line "unsubscribe git" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html > ÿô.nÇ·®+%˱é¥wÿº{.nÇ· ßØnr¡öë¨è&£ûz¹Þúzf£¢·h§~Ûÿÿïÿê_èæ+v¨þ)ßø