ganglia/ganglia-3.7.2-pcre2.patch

127 lines
4.6 KiB
Diff
Raw Normal View History

From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1000041
--- ganglia.orig/configure.ac
+++ ganglia/configure.ac
@@ -520,14 +520,20 @@
echo "Added -L$libpcrepath/${LIB_SUFFIX} to LDFLAGS"
fi
if test x"$libpcre" == xyes ; then
- AC_CHECK_HEADERS([pcre/pcre.h pcre.h])
- AC_CHECK_LIB(pcre, pcre_compile)
- if test x"$ac_cv_lib_pcre_pcre_compile" = xyes; then
- echo "Found a suitable pcre library"
- else
- echo "libpcre not found, specify --with-libpcre=no to build without PCRE support"
- exit 1;
- fi
+ AC_CHECK_HEADERS([pcre2.h], [], [], [[#define PCRE2_CODE_UNIT_WIDTH 8]])
+ LIBS="$LIBS -lpcre2-8"
+ AC_MSG_CHECKING([for pcre2_match_data_create in -lpcre2-8])
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[#define PCRE2_CODE_UNIT_WIDTH 8
+ #include <pcre2.h>
+ ]],
+ [[pcre2_match_data *md;
+ md = pcre2_match_data_create (16, NULL);]])],
+ [AC_DEFINE([HAVE_LIBPCRE], [1], [Define if the PCRE2 library is available])
+ AC_MSG_RESULT([yes])
+ AC_MSG_RESULT([Found a suitable pcre library])],
+ [AC_MSG_RESULT([no])
+ AC_MSG_FAILURE([libpcre not found, specify --with-libpcre=no to build without PCRE support], [1])])
else
echo "building without PCRE support"
fi
--- ganglia.orig/gmond/gmond.c
+++ ganglia/gmond/gmond.c
@@ -38,11 +38,8 @@
#include <apr_version.h>
#ifdef HAVE_LIBPCRE
-#if defined (HAVE_PCRE_PCRE_H)
-#include <pcre/pcre.h>
-#else
-#include <pcre.h>
-#endif
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
#endif
#include "cmdline.h" /* generated by cmdline.sh which runs gengetopt */
@@ -2650,10 +2647,11 @@
if(name_match != NULL)
{
- pcre *pcre_re;
- const char *pcre_err_ptr;
- int pcre_err_offset;
- int pcre_ovector[PCRE_OVECCOUNT];
+ pcre2_code *pcre_re;
+ pcre2_match_data *pcre_md;
+ int pcre_err_ptr;
+ size_t pcre_err_offset;
+ size_t *pcre_ovector;
int pcre_rc;
apr_hash_index_t *hi;
@@ -2662,9 +2660,9 @@
const char *key;
int found = 0;
- if((pcre_re = pcre_compile(name_match, 0, &pcre_err_ptr, &pcre_err_offset, NULL)) == NULL)
+ if((pcre_re = pcre2_compile((PCRE2_SPTR)name_match, PCRE2_ZERO_TERMINATED, 0, &pcre_err_ptr, &pcre_err_offset, NULL)) == NULL)
{
- err_msg ("pcre_compile failed on %s\n", name_match);
+ err_msg ("pcre2_compile failed on %s\n", name_match);
exit (1);
}
@@ -2676,6 +2674,8 @@
exit(EXIT_FAILURE);
}
+ pcre_md = pcre2_match_data_create(PCRE_OVECCOUNT, NULL);
+
for(hi = apr_hash_first(p, metric_callbacks);
hi;
hi = apr_hash_next(hi))
@@ -2683,17 +2683,17 @@
Ganglia_metric_callback *cb;
apr_hash_this(hi, (const void**)&key, NULL, &val);
- if((pcre_rc = pcre_exec(pcre_re, NULL, key, strlen(key), 0, 0, pcre_ovector, PCRE_OVECCOUNT)) < 1)
+ if((pcre_rc = pcre2_match(pcre_re, (PCRE2_SPTR)key, strlen(key), 0, 0, pcre_md, NULL)) < 1)
{
switch(pcre_rc)
{
- case PCRE_ERROR_NOMATCH:
+ case PCRE2_ERROR_NOMATCH:
break;
case 0:
/* output vector not big enough */
default:
/* unexpected error */
- err_msg ("unexpected pcre_exec error\n");
+ err_msg ("unexpected pcre2_match error\n");
exit (1);
}
}
@@ -2703,6 +2703,8 @@
char *title_tmpl = cfg_getstr ( metric, "title");
float value_threshold = cfg_getfloat( metric, "value_threshold");
+ pcre_ovector = pcre2_get_ovector_pointer(pcre_md);
+
if(title_tmpl != NULL)
{
struct iovec *ptrs;
@@ -2772,6 +2774,8 @@
if (!found)
err_msg("Unable to find any metric information for '%s'. Possible that a module has not been loaded.\n", name_match);
+ pcre2_match_data_free(pcre_md);
+ pcre2_code_free(pcre_re);
}
else
#endif