grep: change internal *pcre* variable & function names to be *pcre1*

Change the internal PCRE variable & function names to have a "1" suffix. This is for preparation for libpcre2 support, where having non-versioned names would be confusing. An earlier change in this series ("grep: change the internal PCRE macro names to be PCRE1", 2017-04-07) elaborates on the motivations behind this change. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed May 25, 2017 at 19:45 UTC 6d4b5747f06754efd467d3dde32367f27615fa7b
2 files changed +30 -30
grep.c
+26 -26
@@ -178,23 +178,23 @@ static void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, st
178
179 case GREP_PATTERN_TYPE_BRE:
180 opt->fixed = 0;
181 - opt->pcre = 0;
181 + opt->pcre1 = 0;
182 break;
183
184 case GREP_PATTERN_TYPE_ERE:
185 opt->fixed = 0;
186 - opt->pcre = 0;
186 + opt->pcre1 = 0;
187 opt->regflags |= REG_EXTENDED;
188 break;
189
190 case GREP_PATTERN_TYPE_FIXED:
191 opt->fixed = 1;
192 - opt->pcre = 0;
192 + opt->pcre1 = 0;
193 break;
194
195 case GREP_PATTERN_TYPE_PCRE:
196 opt->fixed = 0;
197 - opt->pcre = 1;
197 + opt->pcre1 = 1;
198 break;
199 }
200 }
@@ -334,7 +334,7 @@ static int has_null(const char *s, size_t len)
334 }
335
336 #ifdef USE_LIBPCRE1
337 -static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)
337 +static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
338 {
339 const char *error;
340 int erroffset;
@@ -342,23 +342,23 @@ static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)
342
343 if (opt->ignore_case) {
344 if (has_non_ascii(p->pattern))
345 - p->pcre_tables = pcre_maketables();
345 + p->pcre1_tables = pcre_maketables();
346 options |= PCRE_CASELESS;
347 }
348 if (is_utf8_locale() && has_non_ascii(p->pattern))
349 options |= PCRE_UTF8;
350
351 - p->pcre_regexp = pcre_compile(p->pattern, options, &error, &erroffset,
352 - p->pcre_tables);
353 - if (!p->pcre_regexp)
351 + p->pcre1_regexp = pcre_compile(p->pattern, options, &error, &erroffset,
352 + p->pcre1_tables);
353 + if (!p->pcre1_regexp)
354 compile_regexp_failed(p, error);
355
356 - p->pcre_extra_info = pcre_study(p->pcre_regexp, 0, &error);
357 - if (!p->pcre_extra_info && error)
356 + p->pcre1_extra_info = pcre_study(p->pcre1_regexp, 0, &error);
357 + if (!p->pcre1_extra_info && error)
358 die("%s", error);
359 }
360
361 -static int pcrematch(struct grep_pat *p, const char *line, const char *eol,
361 +static int pcre1match(struct grep_pat *p, const char *line, const char *eol,
362 regmatch_t *match, int eflags)
363 {
364 int ovector[30], ret, flags = 0;
@@ -366,7 +366,7 @@ static int pcrematch(struct grep_pat *p, const char *line, const char *eol,
366 if (eflags & REG_NOTBOL)
367 flags |= PCRE_NOTBOL;
368
369 - ret = pcre_exec(p->pcre_regexp, p->pcre_extra_info, line, eol - line,
369 + ret = pcre_exec(p->pcre1_regexp, p->pcre1_extra_info, line, eol - line,
370 0, flags, ovector, ARRAY_SIZE(ovector));
371 if (ret < 0 && ret != PCRE_ERROR_NOMATCH)
372 die("pcre_exec failed with error code %d", ret);
@@ -379,25 +379,25 @@ static int pcrematch(struct grep_pat *p, const char *line, const char *eol,
379 return ret;
380 }
381
382 -static void free_pcre_regexp(struct grep_pat *p)
382 +static void free_pcre1_regexp(struct grep_pat *p)
383 {
384 - pcre_free(p->pcre_regexp);
385 - pcre_free(p->pcre_extra_info);
386 - pcre_free((void *)p->pcre_tables);
384 + pcre_free(p->pcre1_regexp);
385 + pcre_free(p->pcre1_extra_info);
386 + pcre_free((void *)p->pcre1_tables);
387 }
388 #else /* !USE_LIBPCRE1 */
389 -static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)
389 +static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)
390 {
391 die("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE");
392 }
393
394 -static int pcrematch(struct grep_pat *p, const char *line, const char *eol,
394 +static int pcre1match(struct grep_pat *p, const char *line, const char *eol,
395 regmatch_t *match, int eflags)
396 {
397 return 1;
398 }
399
400 -static void free_pcre_regexp(struct grep_pat *p)
400 +static void free_pcre1_regexp(struct grep_pat *p)
401 {
402 }
403 #endif /* !USE_LIBPCRE1 */
@@ -479,8 +479,8 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
479 return;
480 }
481
482 - if (opt->pcre) {
483 - compile_pcre_regexp(p, opt);
482 + if (opt->pcre1) {
483 + compile_pcre1_regexp(p, opt);
484 return;
485 }
486
@@ -836,8 +836,8 @@ void free_grep_patterns(struct grep_opt *opt)
836 case GREP_PATTERN_BODY:
837 if (p->kws)
838 kwsfree(p->kws);
839 - else if (p->pcre_regexp)
840 - free_pcre_regexp(p);
839 + else if (p->pcre1_regexp)
840 + free_pcre1_regexp(p);
841 else
842 regfree(&p->regexp);
843 free(p->pattern);
@@ -916,8 +916,8 @@ static int patmatch(struct grep_pat *p, char *line, char *eol,
916
917 if (p->fixed)
918 hit = !fixmatch(p, line, eol, match);
919 - else if (p->pcre_regexp)
920 - hit = !pcrematch(p, line, eol, match, eflags);
919 + else if (p->pcre1_regexp)
920 + hit = !pcre1match(p, line, eol, match, eflags);
921 else
922 hit = !regexec_buf(&p->regexp, line, eol - line, 1, match,
923 eflags);
grep.h
+4 -4
@@ -46,9 +46,9 @@ struct grep_pat {
46 size_t patternlen;
47 enum grep_header_field field;
48 regex_t regexp;
49 - pcre *pcre_regexp;
50 - pcre_extra *pcre_extra_info;
51 - const unsigned char *pcre_tables;
49 + pcre *pcre1_regexp;
50 + pcre_extra *pcre1_extra_info;
51 + const unsigned char *pcre1_tables;
52 kwset_t kws;
53 unsigned fixed:1;
54 unsigned ignore_case:1;
@@ -111,7 +111,7 @@ struct grep_opt {
111 int allow_textconv;
112 int extended;
113 int use_reflog_filter;
114 - int pcre;
114 + int pcre1;
115 int relative;
116 int pathname;
117 int null_following_name;