Skip to content

Commit 6d4b574

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3485bea commit 6d4b574

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

grep.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,23 @@ static void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, st
178178

179179
case GREP_PATTERN_TYPE_BRE:
180180
opt->fixed = 0;
181-
opt->pcre = 0;
181+
opt->pcre1 = 0;
182182
break;
183183

184184
case GREP_PATTERN_TYPE_ERE:
185185
opt->fixed = 0;
186-
opt->pcre = 0;
186+
opt->pcre1 = 0;
187187
opt->regflags |= REG_EXTENDED;
188188
break;
189189

190190
case GREP_PATTERN_TYPE_FIXED:
191191
opt->fixed = 1;
192-
opt->pcre = 0;
192+
opt->pcre1 = 0;
193193
break;
194194

195195
case GREP_PATTERN_TYPE_PCRE:
196196
opt->fixed = 0;
197-
opt->pcre = 1;
197+
opt->pcre1 = 1;
198198
break;
199199
}
200200
}
@@ -334,39 +334,39 @@ static int has_null(const char *s, size_t len)
334334
}
335335

336336
#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)
338338
{
339339
const char *error;
340340
int erroffset;
341341
int options = PCRE_MULTILINE;
342342

343343
if (opt->ignore_case) {
344344
if (has_non_ascii(p->pattern))
345-
p->pcre_tables = pcre_maketables();
345+
p->pcre1_tables = pcre_maketables();
346346
options |= PCRE_CASELESS;
347347
}
348348
if (is_utf8_locale() && has_non_ascii(p->pattern))
349349
options |= PCRE_UTF8;
350350

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)
354354
compile_regexp_failed(p, error);
355355

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)
358358
die("%s", error);
359359
}
360360

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,
362362
regmatch_t *match, int eflags)
363363
{
364364
int ovector[30], ret, flags = 0;
365365

366366
if (eflags & REG_NOTBOL)
367367
flags |= PCRE_NOTBOL;
368368

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,
370370
0, flags, ovector, ARRAY_SIZE(ovector));
371371
if (ret < 0 && ret != PCRE_ERROR_NOMATCH)
372372
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,
379379
return ret;
380380
}
381381

382-
static void free_pcre_regexp(struct grep_pat *p)
382+
static void free_pcre1_regexp(struct grep_pat *p)
383383
{
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);
387387
}
388388
#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)
390390
{
391391
die("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE");
392392
}
393393

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,
395395
regmatch_t *match, int eflags)
396396
{
397397
return 1;
398398
}
399399

400-
static void free_pcre_regexp(struct grep_pat *p)
400+
static void free_pcre1_regexp(struct grep_pat *p)
401401
{
402402
}
403403
#endif /* !USE_LIBPCRE1 */
@@ -479,8 +479,8 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
479479
return;
480480
}
481481

482-
if (opt->pcre) {
483-
compile_pcre_regexp(p, opt);
482+
if (opt->pcre1) {
483+
compile_pcre1_regexp(p, opt);
484484
return;
485485
}
486486

@@ -836,8 +836,8 @@ void free_grep_patterns(struct grep_opt *opt)
836836
case GREP_PATTERN_BODY:
837837
if (p->kws)
838838
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);
841841
else
842842
regfree(&p->regexp);
843843
free(p->pattern);
@@ -916,8 +916,8 @@ static int patmatch(struct grep_pat *p, char *line, char *eol,
916916

917917
if (p->fixed)
918918
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);
921921
else
922922
hit = !regexec_buf(&p->regexp, line, eol - line, 1, match,
923923
eflags);

grep.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ struct grep_pat {
4646
size_t patternlen;
4747
enum grep_header_field field;
4848
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;
5252
kwset_t kws;
5353
unsigned fixed:1;
5454
unsigned ignore_case:1;
@@ -111,7 +111,7 @@ struct grep_opt {
111111
int allow_textconv;
112112
int extended;
113113
int use_reflog_filter;
114-
int pcre;
114+
int pcre1;
115115
int relative;
116116
int pathname;
117117
int null_following_name;

0 commit comments

Comments
 (0)