From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/3] grep: make pcre1_tables version agnostic
Date: Sun, 28 Jul 2019 01:47:34 +0200 [thread overview]
Message-ID: <875znn6nvt.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <20190727202759.22310-2-carenas@gmail.com>
On Sat, Jul 27 2019, Carlo Marcelo Arenas Belón wrote:
> 6d4b5747f0 ("grep: change internal *pcre* variable & function names
> to be *pcre1*", 2017-05-25), renamed most variables to be PCRE1
> specific to give space to similarly named variables for PCRE2, but
> in this case the change wasn't needed as the types were compatible
> enough (const unsigned char* vs const uint8_t*) to be shared.
Both the v1 and v2 functions return const unsigned char *. I don't know
where I got the uint8_t from. This makes more sense.
This series looks good to me. Thanks for the fix. Just one caveat:
The point of 6d4b5747f0 was not to only split out those variables we
couldn't get away with re-using. Then I would have later re-used
e.g. pcre1_jit_on & pcre2_jit_on as just pcre_jit_on. We could also do
that now.
I think doing that & this part of the your changes makes things less
readable. The two code branches we compile with ifdefs are mutually
exclusive, so having the variables be unique helps with eyeballing /
reasoning when changing the code.
> Revert that change, as 94da9193a6 ("grep: add support for PCRE v2",
> 2017-06-01) failed to create an equivalent PCRE2 version.
>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
> grep.c | 6 +++---
> grep.h | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/grep.c b/grep.c
> index f7c3a5803e..cc65f7a987 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -389,14 +389,14 @@ static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
>
> if (opt->ignore_case) {
> if (has_non_ascii(p->pattern))
> - p->pcre1_tables = pcre_maketables();
> + p->pcre_tables = pcre_maketables();
> options |= PCRE_CASELESS;
> }
> if (is_utf8_locale() && has_non_ascii(p->pattern))
> options |= PCRE_UTF8;
>
> p->pcre1_regexp = pcre_compile(p->pattern, options, &error, &erroffset,
> - p->pcre1_tables);
> + p->pcre_tables);
> if (!p->pcre1_regexp)
> compile_regexp_failed(p, error);
>
> @@ -462,7 +462,7 @@ static void free_pcre1_regexp(struct grep_pat *p)
> {
> pcre_free(p->pcre1_extra_info);
> }
> - pcre_free((void *)p->pcre1_tables);
> + pcre_free((void *)p->pcre_tables);
> }
> #else /* !USE_LIBPCRE1 */
> static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
> diff --git a/grep.h b/grep.h
> index 1875880f37..d34f66b384 100644
> --- a/grep.h
> +++ b/grep.h
> @@ -89,7 +89,7 @@ struct grep_pat {
> pcre *pcre1_regexp;
> pcre_extra *pcre1_extra_info;
> pcre_jit_stack *pcre1_jit_stack;
> - const unsigned char *pcre1_tables;
> + const unsigned char *pcre_tables;
> int pcre1_jit_on;
> pcre2_code *pcre2_pattern;
> pcre2_match_data *pcre2_match_data;
next prev parent reply other threads:[~2019-07-27 23:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-27 20:27 [PATCH 0/3] grep: memory leak in PCRE2 Carlo Marcelo Arenas Belón
2019-07-27 20:27 ` [PATCH 1/3] grep: make pcre1_tables version agnostic Carlo Marcelo Arenas Belón
2019-07-27 23:47 ` Ævar Arnfjörð Bjarmason [this message]
2019-07-28 2:50 ` Carlo Arenas
2019-07-27 20:27 ` [PATCH 2/3] grep: use pcre_tables also for PCRE2 Carlo Marcelo Arenas Belón
2019-07-27 20:27 ` [PATCH 3/3] grep: plug leak of pcre chartables in PCRE2 Carlo Marcelo Arenas Belón
2019-07-27 23:48 ` Ævar Arnfjörð Bjarmason
2019-07-28 1:41 ` Carlo Arenas
2019-07-29 20:34 ` René Scharfe
2019-07-30 0:08 ` Carlo Arenas
2019-07-30 16:52 ` René Scharfe
2019-08-01 17:09 ` [PATCH v2] grep: avoid leak of " Carlo Marcelo Arenas Belón
2019-08-02 16:19 ` Junio C Hamano
2019-08-03 18:50 ` Carlo Arenas
2019-08-05 19:34 ` Junio C Hamano
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=875znn6nvt.fsf@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=carenas@gmail.com \
--cc=git@vger.kernel.org \
/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).