Ticket #4450: shitty_pcre2.patch
File shitty_pcre2.patch, 8.2 KB (added by broly, 14 months ago) |
---|
-
config.h.in
6 6 /* Define to enable showing configure arguments in help */ 7 7 #undef ENABLE_CONFIGURE_ARGS 8 8 9 /* Define to enable support for ext2fs attributes */10 #undef ENABLE_EXT2FS_ATTR11 12 9 /* Define to 1 if translation of program messages to the user's native 13 10 language is requested. */ 14 11 #undef ENABLE_NLS … … 208 205 /* Define to 1 if you have the <OS.h> header file. */ 209 206 #undef HAVE_OS_H 210 207 208 /* Define to 1 if PCRE2 is found */ 209 #undef HAVE_PCRE2 210 211 211 /* Define to 1 if you have the `pmap_getmaps' function. */ 212 212 #undef HAVE_PMAP_GETMAPS 213 213 -
lib/search/internal.h
6 6 #ifdef SEARCH_TYPE_GLIB 7 7 #define mc_search_regex_t GRegex 8 8 #else 9 #ifdef HAVE_PCRE2 10 #define mc_search_regex_t pcre2_code 11 #else 9 12 #define mc_search_regex_t pcre 10 13 #endif 14 #endif 11 15 12 16 /*** enums ***************************************************************************************/ 13 17 -
lib/search/regex.c
342 342 } 343 343 lc_mc_search->num_results = g_match_info_get_match_count (lc_mc_search->regex_match_info); 344 344 #else /* SEARCH_TYPE_GLIB */ 345 #ifdef HAVE_PCRE2 346 lc_mc_search->num_results = pcre2_match (regex, 347 (unsigned char *) search_str->str, search_str->len, 0, 0, 348 lc_mc_search->regex_match_info, NULL); 349 #else 345 350 lc_mc_search->num_results = pcre_exec (regex, lc_mc_search->regex_match_info, 346 351 search_str->str, search_str->len, 0, 0, 347 lc_mc_search->iovector, MC_SEARCH__NUM_REPLACE_ARGS); 352 lc_mc_search->iovector, mc_search__num_replace_args); 353 #endif 348 354 if (lc_mc_search->num_results < 0) 349 355 { 350 356 return COND__NOT_FOUND; … … 832 838 return; 833 839 } 834 840 #else /* SEARCH_TYPE_GLIB */ 841 #ifdef HAVE_PCRE2 842 int errcode; 843 char *error = calloc(128, sizeof(char)); 844 size_t erroffset; 845 #else 835 846 const char *error; 836 847 int erroffset; 837 int pcre_options = PCRE_EXTRA | PCRE_MULTILINE; 848 #endif 838 849 850 int pcre_options = 851 #ifdef HAVE_PCRE2 852 PCRE2_MULTILINE; 853 #else 854 PCRE_EXTRA | PCRE_MULTILINE; 855 #endif 839 856 if (str_isutf8 (charset) && mc_global.utf8_display) 840 857 { 841 pcre_options |= PCRE_UTF8; 858 pcre_options |= 859 #ifdef HAVE_PCRE2 860 PCRE2_UTF; 861 #else 862 PCRE_UTF8; 863 #endif 842 864 if (!lc_mc_search->is_case_sensitive) 843 pcre_options |= PCRE_CASELESS; 865 pcre_options |= 866 #ifdef HAVE_PCRE2 867 PCRE2_CASELESS; 868 #else 869 PCRE_CASELESS; 870 #endif 844 871 } 845 872 else if (!lc_mc_search->is_case_sensitive) 846 873 { … … 851 878 g_string_free (tmp, TRUE); 852 879 } 853 880 881 #ifdef HAVE_PCRE2 854 882 mc_search_cond->regex_handle = 883 pcre2_compile ((unsigned char *) mc_search_cond->str->str, PCRE2_ZERO_TERMINATED, pcre_options, &errcode, &erroffset, NULL); 884 #else 885 mc_search_cond->regex_handle = 855 886 pcre_compile (mc_search_cond->str->str, pcre_options, &error, &erroffset, NULL); 887 #endif 856 888 if (mc_search_cond->regex_handle == NULL) 857 889 { 890 #ifdef HAVE_PCRE2 891 pcre2_get_error_message(errcode, (unsigned char *) error,128); 892 #endif 858 893 mc_search_set_error (lc_mc_search, MC_SEARCH_E_REGEX_COMPILE, "%s", error); 859 894 return; 860 895 } 896 #ifdef HAVE_PCRE2 897 if(pcre2_jit_compile(mc_search_cond->regex_handle, PCRE2_JIT_COMPLETE) && strlen(error)) 898 #else 861 899 lc_mc_search->regex_match_info = pcre_study (mc_search_cond->regex_handle, 0, &error); 862 900 if (lc_mc_search->regex_match_info == NULL && error != NULL) 901 #endif 863 902 { 864 903 mc_search_set_error (lc_mc_search, MC_SEARCH_E_REGEX_COMPILE, "%s", error); 865 904 MC_PTR_FREE (mc_search_cond->regex_handle); 905 #ifdef HAVE_PCRE2 906 MC_PTR_FREE (error); 907 #endif 866 908 return; 867 909 } 868 910 #endif /* SEARCH_TYPE_GLIB */ -
lib/search/search.c
67 67 mc_search_cond = g_malloc0 (sizeof (mc_search_cond_t)); 68 68 mc_search_cond->str = mc_g_string_dup (str); 69 69 mc_search_cond->charset = g_strdup (charset); 70 70 #ifdef HAVE_PCRE2 71 lc_mc_search->regex_match_info= pcre2_match_data_create(MC_SEARCH__NUM_REPLACE_ARGS, NULL); 72 lc_mc_search->iovector = pcre2_get_ovector_pointer(lc_mc_search->regex_match_info); 73 #endif 71 74 switch (lc_mc_search->search_type) 72 75 { 73 76 case MC_SEARCH_T_GLOB: -
lib/search.h
8 8 #include <sys/types.h> 9 9 10 10 #ifdef SEARCH_TYPE_PCRE 11 #ifdef HAVE_PCRE2 12 #define PCRE2_CODE_UNIT_WIDTH 8 13 #include <pcre2.h> 14 #else 11 15 #include <pcre.h> 12 16 #endif 13 17 #endif 14 18 /*** typedefs(not structures) and defined constants **********************************************/ 15 19 16 20 typedef enum mc_search_cbret_t mc_search_cbret_t; … … 24 28 #ifdef SEARCH_TYPE_GLIB 25 29 #define mc_search_matchinfo_t GMatchInfo 26 30 #else 31 #ifdef HAVE_PCRE2 32 /* no pcre_extra in PCRE2. pcre2_jit_compile (equivalent of pcre_study) handles 33 * all of this internally. but we can use this to hold the pcre2_matches data 34 * until the search is complete */ 35 #define mc_search_matchinfo_t pcre2_match_data 36 #else 27 37 #define mc_search_matchinfo_t pcre_extra 28 38 #endif 39 #endif 29 40 30 41 /*** enums ***************************************************************************************/ 31 42 … … 102 113 mc_search_matchinfo_t *regex_match_info; 103 114 GString *regex_buffer; 104 115 #ifdef SEARCH_TYPE_PCRE 116 #ifdef HAVE_PCRE2 117 /* pcre2 will provide a pointer to a match_data structure that can be manipulated like an iovector*/ 118 size_t *iovector; 119 #else 105 120 int iovector[MC_SEARCH__NUM_REPLACE_ARGS * 2]; 121 #endif 106 122 #endif /* SEARCH_TYPE_PCRE */ 107 123 108 124 /* private data */ -
m4.include/ax_path_lib_pcre.m4
37 37 38 38 OLDLDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $test_PCRE_LIBS" 39 39 OLDCPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $test_PCRE_CPPFLAGS" 40 41 AC_CHECK_LIB(pcre2-8, pcre2_compile_8, [#define PCRE2_CODE_UNIT_WIDTH 8]) 40 42 41 AC_CHECK_LIB(pcre, pcre_compile) 43 if test x"$ac_cv_lib_pcre2_8_pcre2_compile_8" = x"yes" ; then 44 AC_MSG_RESULT(setting PCRE_LIBS -L$with_pcre/lib -lpcre2-8) 42 45 43 if test x"$ac_cv_lib_pcre_pcre_compile" = x"yes" ; then44 AC_MSG_RESULT(setting PCRE_LIBS -L$with_pcre/lib -lpcre)45 46 46 PCRE_LIBS=$test_PCRE_LIBS 47 47 PCRE_CPPFLAGS=$test_PCRE_CPPFLAGS 48 48 49 AC_MSG_CHECKING([lib pcre ])49 AC_MSG_CHECKING([lib pcre2-8]) 50 50 AC_MSG_RESULT([$PCRE_LIBS]) 51 AC_DEFINE(HAVE_PCRE2, 1, [Define to 1 if PCRE2 is found]) 51 52 m4_ifval($1,$1) 52 53 else 53 AC_MSG_CHECKING([lib pcre ])54 AC_MSG_CHECKING([lib pcre2-8]) 54 55 AC_MSG_RESULT([no, (WARNING)]) 55 m4_ifval($2,$2)56 fi57 56 57 AC_CHECK_LIB(pcre, pcre_compile) 58 59 if test x"$ac_cv_lib_pcre_pcre_compile" = x"yes" ; then 60 AC_MSG_RESULT(setting PCRE_LIBS -L$with_pcre/lib -lpcre) 61 62 PCRE_LIBS=$test_PCRE_LIBS 63 PCRE_CPPFLAGS=$test_PCRE_CPPFLAGS 64 65 AC_MSG_CHECKING([lib pcre]) 66 AC_MSG_RESULT([$PCRE_LIBS]) 67 m4_ifval($1,$1) 68 else 69 AC_MSG_CHECKING([lib pcre]) 70 AC_MSG_RESULT([no, (WARNING)]) 71 m4_ifval($2,$2) 72 fi 73 fi 58 74 CPPFLAGS="$OLDCFPPLAGS" 59 75 LDFLAGS="$OLDLDFLAGS" 60 76