Show 69 quoted lines
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> ---
> grep.c | 12 ++++++------
> grep.h | 4 +++-
> 2 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/grep.c b/grep.c
> index 63c4280..b8eda9e 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -70,7 +70,7 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
> if (p->fixed)
> return;
>
> - err = regcomp(&p->regexp, p->pattern, opt->regflags);
> + err = regcomp(&p->u.regexp, p->pattern, opt->regflags);
> if (err) {
> char errbuf[1024];
> char where[1024];
> @@ -81,8 +81,8 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
> sprintf(where, "%s, ", p->origin);
> else
> where[0] = 0;
> - regerror(err, &p->regexp, errbuf, 1024);
> - regfree(&p->regexp);
> + regerror(err, &p->u.regexp, errbuf, 1024);
> + regfree(&p->u.regexp);
> die("%s'%s': %s", where, p->pattern, errbuf);
> }
> }
> @@ -320,7 +320,7 @@ void free_grep_patterns(struct grep_opt *opt)
> case GREP_PATTERN: /* atom */
> case GREP_PATTERN_HEAD:
> case GREP_PATTERN_BODY:
> - regfree(&p->regexp);
> + regfree(&p->u.regexp);
> break;
> default:
> break;
> @@ -464,7 +464,7 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
> if (p->fixed)
> hit = !fixmatch(p, bol, eol, pmatch);
> else
> - hit = !regmatch(&p->regexp, bol, eol, pmatch, eflags);
> + hit = !regmatch(&p->u.regexp, bol, eol, pmatch, eflags);
>
> if (hit && p->word_regexp) {
> if ((pmatch[0].rm_so < 0) ||
> @@ -794,7 +794,7 @@ static int look_ahead(struct grep_opt *opt,
> if (p->fixed)
> hit = !fixmatch(p, bol, bol + *left_p, &m);
> else
> - hit = !regmatch(&p->regexp, bol, bol + *left_p, &m, 0);
> + hit = !regmatch(&p->u.regexp, bol, bol + *left_p, &m, 0);
> if (!hit || m.rm_so < 0 || m.rm_eo < 0)
> continue;
> if (earliest < 0 || m.rm_so < earliest)
> diff --git a/grep.h b/grep.h
> index 06621fe..9912c11 100644
> --- a/grep.h
> +++ b/grep.h
> @@ -32,7 +32,9 @@ struct grep_pat {
> const char *pattern;
> size_t patternlen;
> enum grep_header_field field;
> - regex_t regexp;
> + union {
> + regex_t regexp;
> + } u;