@@ -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,90 +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-
404- if (p -> pcre1_jit_on )
405- study_options = PCRE_STUDY_JIT_COMPILE ;
406- #endif
407-
408- p -> pcre1_extra_info = pcre_study (p -> pcre1_regexp , study_options , & error );
409- if (!p -> pcre1_extra_info && error )
410- die ("%s" , error );
411- }
412-
413- static int pcre1match (struct grep_pat * p , const char * line , const char * eol ,
414- regmatch_t * match , int eflags )
415- {
416- int ovector [30 ], ret , flags = PCRE_NO_UTF8_CHECK ;
417-
418- if (eflags & REG_NOTBOL )
419- flags |= PCRE_NOTBOL ;
420-
421- ret = pcre_exec (p -> pcre1_regexp , p -> pcre1_extra_info , line ,
422- eol - line , 0 , flags , ovector ,
423- ARRAY_SIZE (ovector ));
424-
425- if (ret < 0 && ret != PCRE_ERROR_NOMATCH )
426- die ("pcre_exec failed with error code %d" , ret );
427- if (ret > 0 ) {
428- ret = 0 ;
429- match -> rm_so = ovector [0 ];
430- match -> rm_eo = ovector [1 ];
431- }
432-
433- return ret ;
434- }
435-
436- static void free_pcre1_regexp (struct grep_pat * p )
437- {
438- pcre_free (p -> pcre1_regexp );
439- #ifdef PCRE_CONFIG_JIT
440- if (p -> pcre1_jit_on )
441- pcre_free_study (p -> pcre1_extra_info );
442- else
443- #endif
444- pcre_free (p -> pcre1_extra_info );
445- pcre_free ((void * )p -> pcre1_tables );
446- }
447- #else /* !USE_LIBPCRE1 */
448- static void compile_pcre1_regexp (struct grep_pat * p , const struct grep_opt * opt )
449- {
450- die ("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE" );
451- }
452-
453- static int pcre1match (struct grep_pat * p , const char * line , const char * eol ,
454- regmatch_t * match , int eflags )
455- {
456- return 1 ;
457- }
458-
459- static void free_pcre1_regexp (struct grep_pat * p )
460- {
461- }
462- #endif /* !USE_LIBPCRE1 */
463-
464365#ifdef USE_LIBPCRE2
465366static void compile_pcre2_pattern (struct grep_pat * p , const struct grep_opt * opt )
466367{
@@ -581,11 +482,6 @@ static void free_pcre2_pattern(struct grep_pat *p)
581482#else /* !USE_LIBPCRE2 */
582483static void compile_pcre2_pattern (struct grep_pat * p , const struct grep_opt * opt )
583484{
584- /*
585- * Unreachable until USE_LIBPCRE2 becomes synonymous with
586- * USE_LIBPCRE. See the sibling comment in
587- * grep_set_pattern_type_option().
588- */
589485 die ("cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE" );
590486}
591487
@@ -684,11 +580,6 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
684580 return ;
685581 }
686582
687- if (opt -> pcre1 ) {
688- compile_pcre1_regexp (p , opt );
689- return ;
690- }
691-
692583 if (p -> ignore_case )
693584 regflags |= REG_ICASE ;
694585 if (opt -> extended_regexp_option )
@@ -954,9 +845,7 @@ void free_grep_patterns(struct grep_opt *opt)
954845 case GREP_PATTERN : /* atom */
955846 case GREP_PATTERN_HEAD :
956847 case GREP_PATTERN_BODY :
957- if (p -> pcre1_regexp )
958- free_pcre1_regexp (p );
959- else if (p -> pcre2_pattern )
848+ if (p -> pcre2_pattern )
960849 free_pcre2_pattern (p );
961850 else
962851 regfree (& p -> regexp );
@@ -1019,9 +908,7 @@ static int patmatch(struct grep_pat *p, char *line, char *eol,
1019908{
1020909 int hit ;
1021910
1022- if (p -> pcre1_regexp )
1023- hit = !pcre1match (p , line , eol , match , eflags );
1024- else if (p -> pcre2_pattern )
911+ if (p -> pcre2_pattern )
1025912 hit = !pcre2match (p , line , eol , match , eflags );
1026913 else
1027914 hit = !regexec_buf (& p -> regexp , line , eol - line , 1 , match ,
0 commit comments