# HG changeset patch # User Mikael Berthe # Date 1222797046 -7200 # Node ID 33f8f795abd2440e65ed5ec149cadc85484071c0 # Parent 41d3457af8158c01becd53d82f288905a80f4ecb Check for regex support in glib This is needed for the "url_regex" option. diff -r 41d3457af815 -r 33f8f795abd2 mcabber/configure.ac --- a/mcabber/configure.ac Tue Sep 30 09:05:05 2008 +0200 +++ b/mcabber/configure.ac Tue Sep 30 19:50:46 2008 +0200 @@ -130,6 +130,12 @@ # Check for glib AM_PATH_GLIB_2_0(2.0.0, , AC_MSG_ERROR([glib is required]),[g_list_append]) +# Check for regex support in glib +AM_PATH_GLIB_2_0(2.14.0, + AC_DEFINE(HAVE_GLIB_REGEX, 1, + [Define if your glib2 version has regex support]), , + [g_regex_new]) + # Check for gpgme AC_ARG_ENABLE(gpgme, AC_HELP_STRING([--disable-gpgme], [disable GPGME support]), [ if test x"$enableval" = x"no"; then diff -r 41d3457af815 -r 33f8f795abd2 mcabber/src/screen.c --- a/mcabber/src/screen.c Tue Sep 30 09:05:05 2008 +0200 +++ b/mcabber/src/screen.c Tue Sep 30 19:50:46 2008 +0200 @@ -144,7 +144,9 @@ gint value; } keyseq; +#ifdef HAVE_GLIB_REGEX static GRegex *url_regex; +#endif GSList *keyseqlist; static void add_keyseq(char *seqstr, guint mkeycode, gint value); @@ -747,9 +749,15 @@ inputLine[0] = 0; ptr_inputline = inputLine; - if (settings_opt_get("url_regex")) + if (settings_opt_get("url_regex")) { +#ifdef HAVE_GLIB_REGEX url_regex = g_regex_new(settings_opt_get("url_regex"), G_REGEX_OPTIMIZE, 0, NULL); +#else + scr_LogPrint(LPRINT_LOGNORM, "ERROR: Your glib version is too old, " + "cannot use url_regex."); +#endif // HAVE_GLIB_REGEX + } Curses = TRUE; return; @@ -761,8 +769,10 @@ clear(); refresh(); endwin(); +#ifdef HAVE_GLIB_REGEX if (url_regex) g_regex_unref(url_regex); +#endif Curses = FALSE; return; } @@ -1998,7 +2008,8 @@ } } -inline void scr_LogUrls(const gchar *string) +#ifdef HAVE_GLIB_REGEX +static inline void scr_LogUrls(const gchar *string) { GMatchInfo *match_info; GError *error = NULL; @@ -2012,6 +2023,7 @@ } g_match_info_free(match_info); } +#endif inline void scr_WriteMessage(const char *bjid, const char *text, time_t timestamp, guint prefix_flags, @@ -2038,8 +2050,10 @@ ~HBB_PREFIX_PGPCRYPT & ~HBB_PREFIX_OTRCRYPT)) prefix |= HBB_PREFIX_IN; +#ifdef HAVE_GLIB_REGEX if (url_regex) scr_LogUrls(text); +#endif scr_WriteMessage(jidfrom, text, timestamp, prefix, mucnicklen); }