@@ -166,11 +166,6 @@ void grep_init(struct grep_opt *opt, struct repository *repo, const char *prefix
166166 pcre2_malloc , pcre2_free , NULL );
167167#endif
168168
169- #ifdef USE_LIBPCRE1
170- pcre_malloc = malloc ;
171- pcre_free = free ;
172- #endif
173-
174169 * opt = grep_defaults ;
175170
176171 opt -> repo = repo ;
@@ -223,17 +218,7 @@ static void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, st
223218 break ;
224219
225220 case GREP_PATTERN_TYPE_PCRE :
226- #ifdef USE_LIBPCRE2
227221 opt -> pcre2 = 1 ;
228- #else
229- /*
230- * It's important that pcre1 always be assigned to
231- * even when there's no USE_LIBPCRE* defined. We still
232- * call the PCRE stub function, it just dies with
233- * "cannot use Perl-compatible regexes[...]".
234- */
235- opt -> pcre1 = 1 ;
236- #endif
237222 break ;
238223 }
239224}
@@ -377,92 +362,6 @@ static int is_fixed(const char *s, size_t len)
377362 return 1 ;
378363}
379364
380- #ifdef USE_LIBPCRE1
381- static void compile_pcre1_regexp (struct grep_pat * p , const struct grep_opt * opt )
382- {
383- const char * error ;
384- int erroffset ;
385- int options = PCRE_MULTILINE ;
386- int study_options = 0 ;
387-
388- if (opt -> ignore_case ) {
389- if (!opt -> ignore_locale && has_non_ascii (p -> pattern ))
390- p -> pcre1_tables = pcre_maketables ();
391- options |= PCRE_CASELESS ;
392- }
393- if (!opt -> ignore_locale && is_utf8_locale () && has_non_ascii (p -> pattern ))
394- options |= PCRE_UTF8 ;
395-
396- p -> pcre1_regexp = pcre_compile (p -> pattern , options , & error , & erroffset ,
397- p -> pcre1_tables );
398- if (!p -> pcre1_regexp )
399- compile_regexp_failed (p , error );
400-
401- #if defined(PCRE_CONFIG_JIT ) && !defined(NO_LIBPCRE1_JIT )
402- pcre_config (PCRE_CONFIG_JIT , & p -> pcre1_jit_on );
403- if (opt -> debug )
404- fprintf (stderr , "pcre1_jit_on=%d\n" , p -> pcre1_jit_on );
405-
406- if (p -> pcre1_jit_on )
407- study_options = PCRE_STUDY_JIT_COMPILE ;
408- #endif
409-
410- p -> pcre1_extra_info = pcre_study (p -> pcre1_regexp , study_options , & error );
411- if (!p -> pcre1_extra_info && error )
412- die ("%s" , error );
413- }
414-
415- static int pcre1match (struct grep_pat * p , const char * line , const char * eol ,
416- regmatch_t * match , int eflags )
417- {
418- int ovector [30 ], ret , flags = PCRE_NO_UTF8_CHECK ;
419-
420- if (eflags & REG_NOTBOL )
421- flags |= PCRE_NOTBOL ;
422-
423- ret = pcre_exec (p -> pcre1_regexp , p -> pcre1_extra_info , line ,
424- eol - line , 0 , flags , ovector ,
425- ARRAY_SIZE (ovector ));
426-
427- if (ret < 0 && ret != PCRE_ERROR_NOMATCH )
428- die ("pcre_exec failed with error code %d" , ret );
429- if (ret > 0 ) {
430- ret = 0 ;
431- match -> rm_so = ovector [0 ];
432- match -> rm_eo = ovector [1 ];
433- }
434-
435- return ret ;
436- }
437-
438- static void free_pcre1_regexp (struct grep_pat * p )
439- {
440- pcre_free (p -> pcre1_regexp );
441- #ifdef PCRE_CONFIG_JIT
442- if (p -> pcre1_jit_on )
443- pcre_free_study (p -> pcre1_extra_info );
444- else
445- #endif
446- pcre_free (p -> pcre1_extra_info );
447- pcre_free ((void * )p -> pcre1_tables );
448- }
449- #else /* !USE_LIBPCRE1 */
450- static void compile_pcre1_regexp (struct grep_pat * p , const struct grep_opt * opt )
451- {
452- die ("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE" );
453- }
454-
455- static int pcre1match (struct grep_pat * p , const char * line , const char * eol ,
456- regmatch_t * match , int eflags )
457- {
458- return 1 ;
459- }
460-
461- static void free_pcre1_regexp (struct grep_pat * p )
462- {
463- }
464- #endif /* !USE_LIBPCRE1 */
465-
466365#ifdef USE_LIBPCRE2
467366static void compile_pcre2_pattern (struct grep_pat * p , const struct grep_opt * opt )
468367{
@@ -588,11 +487,6 @@ static void free_pcre2_pattern(struct grep_pat *p)
588487#else /* !USE_LIBPCRE2 */
589488static void compile_pcre2_pattern (struct grep_pat * p , const struct grep_opt * opt )
590489{
591- /*
592- * Unreachable until USE_LIBPCRE2 becomes synonymous with
593- * USE_LIBPCRE. See the sibling comment in
594- * grep_set_pattern_type_option().
595- */
596490 die ("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE" );
597491}
598492
@@ -693,11 +587,6 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
693587 return ;
694588 }
695589
696- if (opt -> pcre1 ) {
697- compile_pcre1_regexp (p , opt );
698- return ;
699- }
700-
701590 if (p -> ignore_case )
702591 regflags |= REG_ICASE ;
703592 if (opt -> extended_regexp_option )
@@ -1051,9 +940,7 @@ void free_grep_patterns(struct grep_opt *opt)
1051940 case GREP_PATTERN : /* atom */
1052941 case GREP_PATTERN_HEAD :
1053942 case GREP_PATTERN_BODY :
1054- if (p -> pcre1_regexp )
1055- free_pcre1_regexp (p );
1056- else if (p -> pcre2_pattern )
943+ if (p -> pcre2_pattern )
1057944 free_pcre2_pattern (p );
1058945 else
1059946 regfree (& p -> regexp );
@@ -1116,9 +1003,7 @@ static int patmatch(struct grep_pat *p, char *line, char *eol,
11161003{
11171004 int hit ;
11181005
1119- if (p -> pcre1_regexp )
1120- hit = !pcre1match (p , line , eol , match , eflags );
1121- else if (p -> pcre2_pattern )
1006+ if (p -> pcre2_pattern )
11221007 hit = !pcre2match (p , line , eol , match , eflags );
11231008 else
11241009 hit = !regexec_buf (& p -> regexp , line , eol - line , 1 , match ,
0 commit comments