@@ -269,7 +269,6 @@ mc_search__cond_struct_new_regex_ci_str (const char *charset, const GString *ast
269269
270270/* --------------------------------------------------------------------------------------------- */
271271
272- #ifdef SEARCH_TYPE_GLIB
273272/* A thin wrapper above g_regex_match_full that makes sure the string passed
274273 * to it is valid UTF-8 (unless G_REGEX_RAW compile flag was set), as it is a
275274 * requirement by glib and it might crash otherwise. See: mc ticket 3449.
@@ -319,15 +318,12 @@ mc_search__g_regex_match_full_safe (const GRegex *regex, const gchar *string, gs
319318 g_free (string_safe );
320319 return ret ;
321320}
322- #endif
323321
324322/* --------------------------------------------------------------------------------------------- */
325323
326324static mc_search__found_cond_t
327- mc_search__regex_found_cond_one (mc_search_t * lc_mc_search , mc_search_regex_t * regex ,
328- GString * search_str )
325+ mc_search__regex_found_cond_one (mc_search_t * lc_mc_search , GRegex * regex , GString * search_str )
329326{
330- #ifdef SEARCH_TYPE_GLIB
331327 GError * mcerror = NULL ;
332328
333329 if (!mc_search__g_regex_match_full_safe (regex , search_str -> str , search_str -> len , 0 ,
@@ -348,21 +344,7 @@ mc_search__regex_found_cond_one (mc_search_t *lc_mc_search, mc_search_regex_t *r
348344 return COND__NOT_FOUND ;
349345 }
350346 lc_mc_search -> num_results = g_match_info_get_match_count (lc_mc_search -> regex_match_info );
351- #else // SEARCH_TYPE_GLIB
352-
353- lc_mc_search -> num_results =
354- # ifdef HAVE_PCRE2
355- pcre2_match (regex , (unsigned char * ) search_str -> str , search_str -> len , 0 , 0 ,
356- lc_mc_search -> regex_match_info , NULL );
357- # else
358- pcre_exec (regex , lc_mc_search -> regex_match_info , search_str -> str , search_str -> len , 0 , 0 ,
359- lc_mc_search -> iovector , MC_SEARCH__NUM_REPLACE_ARGS );
360- # endif
361- if (lc_mc_search -> num_results < 0 )
362- {
363- return COND__NOT_FOUND ;
364- }
365- #endif
347+
366348 return COND__FOUND_OK ;
367349}
368350
@@ -443,12 +425,7 @@ mc_search_regex__get_token_by_num (const mc_search_t *lc_mc_search, gsize lc_ind
443425{
444426 int fnd_start = 0 , fnd_end = 0 ;
445427
446- #ifdef SEARCH_TYPE_GLIB
447428 g_match_info_fetch_pos (lc_mc_search -> regex_match_info , lc_index , & fnd_start , & fnd_end );
448- #else // SEARCH_TYPE_GLIB
449- fnd_start = lc_mc_search -> iovector [lc_index * 2 + 0 ];
450- fnd_end = lc_mc_search -> iovector [lc_index * 2 + 1 ];
451- #endif
452429
453430 if (fnd_end == fnd_start )
454431 return g_strdup ("" );
@@ -807,7 +784,6 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t *lc_mc_s
807784 }
808785
809786 {
810- #ifdef SEARCH_TYPE_GLIB
811787 GError * mcerror = NULL ;
812788 GRegexCompileFlags g_regex_options = G_REGEX_OPTIMIZE | G_REGEX_DOTALL ;
813789
@@ -842,67 +818,6 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t *lc_mc_s
842818 g_error_free (mcerror );
843819 return ;
844820 }
845- #else // SEARCH_TYPE_GLIB
846-
847- # ifdef HAVE_PCRE2
848- int errcode ;
849- char error [BUF_SMALL ] = "" ;
850- size_t erroffset ;
851- int pcre_options = PCRE2_MULTILINE ;
852- # else
853- const char * error ;
854- int erroffset ;
855- int pcre_options = PCRE_EXTRA | PCRE_MULTILINE ;
856- # endif
857-
858- if (str_isutf8 (charset ) && mc_global .utf8_display )
859- {
860- # ifdef HAVE_PCRE2
861- pcre_options |= PCRE2_UTF ;
862- if (!lc_mc_search -> is_case_sensitive )
863- pcre_options |= PCRE2_CASELESS ;
864- # else
865- pcre_options |= PCRE_UTF8 ;
866- if (!lc_mc_search -> is_case_sensitive )
867- pcre_options |= PCRE_CASELESS ;
868- # endif
869- }
870- else if (!lc_mc_search -> is_case_sensitive )
871- {
872- GString * tmp ;
873-
874- tmp = mc_search_cond -> str ;
875- mc_search_cond -> str = mc_search__cond_struct_new_regex_ci_str (charset , tmp );
876- g_string_free (tmp , TRUE);
877- }
878-
879- mc_search_cond -> regex_handle =
880- # ifdef HAVE_PCRE2
881- pcre2_compile ((unsigned char * ) mc_search_cond -> str -> str , PCRE2_ZERO_TERMINATED ,
882- pcre_options , & errcode , & erroffset , NULL );
883- # else
884- pcre_compile (mc_search_cond -> str -> str , pcre_options , & error , & erroffset , NULL );
885- # endif
886- if (mc_search_cond -> regex_handle == NULL )
887- {
888- # ifdef HAVE_PCRE2
889- pcre2_get_error_message (errcode , (unsigned char * ) error , sizeof (error ));
890- # endif
891- mc_search_set_error (lc_mc_search , MC_SEARCH_E_REGEX_COMPILE , "%s" , error );
892- return ;
893- }
894- # ifdef HAVE_PCRE2
895- if (pcre2_jit_compile (mc_search_cond -> regex_handle , PCRE2_JIT_COMPLETE ) && * error != '\0' )
896- # else
897- lc_mc_search -> regex_match_info = pcre_study (mc_search_cond -> regex_handle , 0 , & error );
898- if (lc_mc_search -> regex_match_info == NULL && error != NULL )
899- # endif
900- {
901- mc_search_set_error (lc_mc_search , MC_SEARCH_E_REGEX_COMPILE , "%s" , error );
902- MC_PTR_FREE (mc_search_cond -> regex_handle );
903- return ;
904- }
905- #endif
906821 }
907822
908823 lc_mc_search -> is_utf8 = str_isutf8 (charset );
@@ -985,12 +900,7 @@ mc_search__run_regex (mc_search_t *lc_mc_search, const void *user_data, off_t st
985900 switch (mc_search__regex_found_cond (lc_mc_search , lc_mc_search -> regex_buffer ))
986901 {
987902 case COND__FOUND_OK :
988- #ifdef SEARCH_TYPE_GLIB
989903 g_match_info_fetch_pos (lc_mc_search -> regex_match_info , 0 , & start_pos , & end_pos );
990- #else // SEARCH_TYPE_GLIB
991- start_pos = lc_mc_search -> iovector [0 ];
992- end_pos = lc_mc_search -> iovector [1 ];
993- #endif
994904 if (found_len != NULL )
995905 * found_len = end_pos - start_pos ;
996906 lc_mc_search -> normal_offset = lc_mc_search -> start_buffer + start_pos ;
0 commit comments