From 2e792c45db5c7308935cfdf7a0f1336d83670b0c Mon Sep 17 00:00:00 2001 From: sgranjoux Date: Mon, 2 Jun 2008 19:36:23 +0000 Subject: [PATCH] * plugins/cvs-plugin/Makefile.am, plugins/cvs-plugin/cvs-execute.c, plugins/sourceview/anjuta-document.c, plugins/sourceview/Makefile.am, plugins/subversion/Makefile.am, plugins/search/search-replace.h, plugins/search/Makefile.am, plugins/build-basic-autotools/build-basic-autotools.c, plugins/build-basic-autotools/Makefile.am, plugins/editor/Makefile.am, plugins/document-manager/Makefile.am, plugins/macro/Makefile.am, configure.in: Fix #514620: Port anjuta to GRegex git-svn-id: http://svn.gnome.org/svn/anjuta/trunk@3977 1dbfb86a-d425-0410-a06b-cb591aac69f6 --- ChangeLog | 18 ++++++++ configure.in | 17 +------- plugins/build-basic-autotools/Makefile.am | 2 - .../build-basic-autotools/build-basic-autotools.c | 51 +++++++++++----------- plugins/cvs-plugin/Makefile.am | 5 +-- plugins/cvs-plugin/cvs-execute.c | 31 ++++++------- plugins/document-manager/Makefile.am | 2 - plugins/editor/Makefile.am | 2 - plugins/macro/Makefile.am | 5 +-- plugins/search/Makefile.am | 2 - plugins/search/search-replace.h | 1 - plugins/sourceview/Makefile.am | 2 - plugins/sourceview/anjuta-document.c | 1 - plugins/subversion/Makefile.am | 5 +-- 14 files changed, 64 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index f64a130f..2ae45cb3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2008-06-02 Yuriy Penkin + + Reviewed by Sébastien Granjoux : + * plugins/cvs-plugin/Makefile.am, + plugins/cvs-plugin/cvs-execute.c, + plugins/sourceview/anjuta-document.c, + plugins/sourceview/Makefile.am, + plugins/subversion/Makefile.am, + plugins/search/search-replace.h, + plugins/search/Makefile.am, + plugins/build-basic-autotools/build-basic-autotools.c, + plugins/build-basic-autotools/Makefile.am, + plugins/editor/Makefile.am, + plugins/document-manager/Makefile.am, + plugins/macro/Makefile.am, + configure.in: + Fix #514620: Port anjuta to GRegex + 2008-06-02 Sébastien Granjoux * plugins/debug-manager/anjuta-marshal.list, diff --git a/configure.in b/configure.in index cfaebdac..fec5879c 100644 --- a/configure.in +++ b/configure.in @@ -19,7 +19,7 @@ AC_SUBST(ANJUTA_MICRO_VERSION, anjuta_micro_version) AC_DEFINE(ANJUTA_VERSION, anjuta_version, [Anjuta version]) AC_SUBST(ANJUTA_VERSION) -GLIB_REQUIRED=2.8.0 +GLIB_REQUIRED=2.14.0 GOBJECT_REQUIRED=2.8.0 GMODULE_REQUIRED=2.8.0 GTHREAD_REQUIRED=2.8.0 @@ -38,7 +38,6 @@ VTE_REQUIRED=0.9.0 VTE_NEW_REQUIRED=0.13.1 LIBXML_REQUIRED=2.4.23 PANGO_REQUIRED=1.1.1 -PCRE_REQUIRED=3.9 LIBDEVHELP_REQUIRED=0.13 GDL_REQUIRED=0.7.3 GNOMEBUILD_REQUIRED=0.3.0 @@ -73,7 +72,6 @@ AC_SUBST(VTE_REQUIRED) AC_SUBST(LIBXML_REQUIRED) AC_SUBST(PANGO_REQUIRED) AC_SUBST(VTE_NEW_REQUIRED) -AC_SUBST(PCRE_REQUIRED) AC_SUBST(LIBDEVHELP_REQUIRED) AC_SUBST(GDL_REQUIRED) AC_SUBST(GNOMEBUILD_REQUIRED) @@ -638,19 +636,6 @@ dnl fi dnl AC_SUBST(SCROLLKEEPER_VERSION_NUM) dnl *************************************************************************** -dnl Check for PCRE -dnl *************************************************************************** -dnl Check for PCRE -AC_PATH_PROG(PCRE_CONFIG, pcre-config,no) -if test x$PCRE_CONFIG = xno; then - AC_MSG_ERROR(Please install the PCRE package from http://www.pcre.org/) -fi -PCRE_CFLAGS=`pcre-config --cflags` -PCRE_LIBS=`pcre-config --libs` -AC_SUBST(PCRE_LIBS) -AC_SUBST(PCRE_CFLAGS) - -dnl *************************************************************************** dnl Tagmanager checks. dnl *************************************************************************** diff --git a/plugins/build-basic-autotools/Makefile.am b/plugins/build-basic-autotools/Makefile.am index 668a3f41..55f680b5 100644 --- a/plugins/build-basic-autotools/Makefile.am +++ b/plugins/build-basic-autotools/Makefile.am @@ -28,7 +28,6 @@ build_data_DATA = automake-c.filters AM_CPPFLAGS = \ $(WARN_CFLAGS) \ $(DEPRECATED_FLAGS) \ - $(PCRE_CFLAGS) \ $(LIBANJUTA_CFLAGS) # Where to install the plugin @@ -48,7 +47,6 @@ libanjuta_build_basic_autotools_la_SOURCES = \ # Plugin dependencies libanjuta_build_basic_autotools_la_LIBADD = \ - $(PCRE_LIBS) \ $(GLADE_LIBS) \ $(GNOME_LIBS) \ $(LIBANJUTA_LIBS) diff --git a/plugins/build-basic-autotools/build-basic-autotools.c b/plugins/build-basic-autotools/build-basic-autotools.c index cbd7c903..4a561ec2 100644 --- a/plugins/build-basic-autotools/build-basic-autotools.c +++ b/plugins/build-basic-autotools/build-basic-autotools.c @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -79,7 +78,7 @@ typedef struct gchar *pattern; int options; gchar *replace; - pcre *regex; + GRegex *regex; } BuildPattern; typedef struct @@ -424,8 +423,7 @@ static void build_regex_init () { GList *node; - const char *error; - int erroffset; + GError *error = NULL; build_regex_load (); if (!patterns_list) @@ -441,15 +439,15 @@ build_regex_init () pattern = node->data; pattern->regex = - pcre_compile( + g_regex_new( pattern->pattern, pattern->options, - &error, /* for error message */ - &erroffset, /* for error offset */ - NULL); /* use default character tables */ - if (pattern->regex == NULL) { - DEBUG_PRINT ("PCRE compilation failed: %s: regex \"%s\" at char %d", - pattern->pattern, error, erroffset); + 0, + &error); /* for error message */ + if (error != NULL) { + DEBUG_PRINT ("GRegex compilation failed: pattern \"%s\": error %s", + pattern->pattern, error->message); + g_error_free (error); } node = g_list_next (node); } @@ -459,8 +457,8 @@ build_regex_init () static gchar* build_get_summary (const gchar *details, BuildPattern* bp) { - int rc; - int ovector[30]; + gboolean matched; + GMatchInfo *match_info; const gchar *iter; GString *ret; gchar *final; @@ -468,17 +466,13 @@ build_get_summary (const gchar *details, BuildPattern* bp) if (!bp || !bp->regex) return NULL; - rc = pcre_exec( - bp->regex, /* result of pcre_compile() */ - NULL, /* we didn’t study the pattern */ - details, /* the subject string */ - strlen (details),/* the length of the subject string */ - 0, /* start at offset 0 in the subject */ - bp->options, /* default options */ - ovector, /* vector for substring information */ - 30); /* number of elements in the vector */ - - if (rc < 0) + matched = g_regex_match( + bp->regex, /* result of g_regex_new() */ + details, /* the subject string */ + 0, + &match_info); + + if (!matched) return NULL; ret = g_string_new (""); @@ -488,11 +482,15 @@ build_get_summary (const gchar *details, BuildPattern* bp) if (*iter == '\\' && isdigit(*(iter + 1))) { char temp[2] = {0, 0}; + gint start_pos, end_pos; temp[0] = *(iter + 1); int idx = atoi (temp); - ret = g_string_append_len (ret, details + ovector[2*idx], - ovector[2*idx+1] - ovector[2*idx]); + + g_match_info_fetch_pos (match_info, idx, &start_pos, &end_pos); + + ret = g_string_append_len (ret, details + start_pos, + end_pos - start_pos); iter += 2; } else @@ -507,6 +505,7 @@ build_get_summary (const gchar *details, BuildPattern* bp) ret = g_string_append_len (ret, start, end - start); } } + g_match_info_free (match_info); final = g_string_free (ret, FALSE); if (strlen (final) <= 0) { diff --git a/plugins/cvs-plugin/Makefile.am b/plugins/cvs-plugin/Makefile.am index e32a7547..3d730670 100644 --- a/plugins/cvs-plugin/Makefile.am +++ b/plugins/cvs-plugin/Makefile.am @@ -19,8 +19,7 @@ cvs_plugin_plugin_DATA = $(plugin_in_files:.plugin.in=.plugin) AM_CPPFLAGS= \ $(WARN_CFLAGS) \ $(DEPRECATED_FLAGS) \ - $(LIBANJUTA_CFLAGS) \ - $(PCRE_CFLAGS) + $(LIBANJUTA_CFLAGS) plugindir = $(anjuta_plugin_dir) plugin_LTLIBRARIES = libanjuta-cvs-plugin.la @@ -30,7 +29,7 @@ libanjuta_cvs_plugin_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS) libanjuta_cvs_plugin_la_LIBADD = \ $(GLADE_LIBS) \ $(GNOME_VFS_LIBS) \ - $(LIBANJUTA_LIBS) $(PCRE_LIBS) + $(LIBANJUTA_LIBS) libanjuta_cvs_plugin_la_SOURCES = \ plugin.c \ diff --git a/plugins/cvs-plugin/cvs-execute.c b/plugins/cvs-plugin/cvs-execute.c index acbee93b..c129aa77 100644 --- a/plugins/cvs-plugin/cvs-execute.c +++ b/plugins/cvs-plugin/cvs-execute.c @@ -28,7 +28,6 @@ #include #include -#include #define CVS_ICON "" #define CVS_INFO_REGEXP "(cvs update:.|cvs server:.)" @@ -48,39 +47,37 @@ on_cvs_mesg_format (IAnjutaMessageView *view, const gchar *line, AnjutaPlugin *plugin) { IAnjutaMessageViewType type; - pcre *info, *err; - const gchar *err_buf; - int err_ptr, output[16]; + GRegex *info, *err; + GError *error = NULL; g_return_if_fail (line != NULL); /* Compile the regexps for message types. */ - if (!(info = pcre_compile(CVS_INFO_REGEXP, 0, &err_buf, &err_ptr, NULL))) + info = g_regex_new (CVS_INFO_REGEXP, 0, 0, &error); + if (error != NULL) { - g_free((gchar *) err_buf); + g_error_free (error); return; } - if (!(err = pcre_compile(CVS_ERR_REGEXP, 0, &err_buf, &err_ptr, NULL))) + err = g_regex_new (CVS_ERR_REGEXP, 0, 0, &error); + if (error != NULL) { - g_free((gchar *) err_buf); + g_error_free (error); return; } /* Match against type regexps to find the message type. */ - if (pcre_exec(info, NULL, line, strlen(line), 0, 0, output, 16) >= 0) - { + if (g_regex_match (info, line, 0, NULL)) type = IANJUTA_MESSAGE_VIEW_TYPE_INFO; - } - else if (pcre_exec(err, NULL, line, strlen(line), 0, 0, output, 16) >= 0) - { + else if (g_regex_match (info, line, 0, NULL)) type = IANJUTA_MESSAGE_VIEW_TYPE_ERROR; - } - else type = IANJUTA_MESSAGE_VIEW_TYPE_NORMAL; + else + type = IANJUTA_MESSAGE_VIEW_TYPE_NORMAL; ianjuta_message_view_append (view, type, line, "", NULL); - pcre_free(info); - pcre_free(err); + g_regex_unref (info); + g_regex_unref (err); } static void diff --git a/plugins/document-manager/Makefile.am b/plugins/document-manager/Makefile.am index 8ac06758..b313fba7 100644 --- a/plugins/document-manager/Makefile.am +++ b/plugins/document-manager/Makefile.am @@ -21,7 +21,6 @@ plugin_LTLIBRARIES = libanjuta-document-manager.la AM_CPPFLAGS = \ $(WARN_CFLAGS) \ $(DEPRECATED_FLAGS) \ - $(PCRE_CFLAGS) \ $(GDL_CFLAGS) \ $(GNOME_PRINT_UI_CFLAGS) \ $(GNOME_VFS_CFLAGS) \ @@ -31,7 +30,6 @@ libanjuta_document_manager_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS) libanjuta_document_manager_la_LIBADD = \ $(GDL_LIBS) \ - $(PCRE_LIBS) \ $(GNOME_PRINT_UI_LIBS) \ $(GNOME_VFS_LIBS) \ $(LIBANJUTA_LIBS) diff --git a/plugins/editor/Makefile.am b/plugins/editor/Makefile.am index 3b3cbe17..93aa06c1 100644 --- a/plugins/editor/Makefile.am +++ b/plugins/editor/Makefile.am @@ -22,7 +22,6 @@ plugindir = $(anjuta_plugin_dir) plugin_LTLIBRARIES = libanjuta-editor.la AM_CPPFLAGS = \ - $(PCRE_CFLAGS) \ $(GNOME_PRINT_UI_CFLAGS) \ $(GNOME_VFS_CFLAGS) \ $(LIBANJUTA_CFLAGS) \ @@ -33,7 +32,6 @@ AM_CPPFLAGS = \ libanjuta_editor_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS) libanjuta_editor_la_LIBADD = \ - $(PCRE_LIBS) \ $(GNOME_PRINT_UI_LIBS) \ $(GNOME_VFS_LIBS) \ $(LIBANJUTA_LIBS) \ diff --git a/plugins/macro/Makefile.am b/plugins/macro/Makefile.am index b86085ea..c62893a2 100644 --- a/plugins/macro/Makefile.am +++ b/plugins/macro/Makefile.am @@ -21,8 +21,7 @@ macro_plugin_DATA = $(plugin_in_files:.plugin.in=.plugin) AM_CPPFLAGS= \ $(WARN_CFLAGS) \ $(DEPRECATED_FLAGS) \ - $(LIBANJUTA_CFLAGS) \ - $(PCRE_CFLAGS) + $(LIBANJUTA_CFLAGS) plugindir = $(anjuta_plugin_dir) plugin_LTLIBRARIES = libanjuta-macro.la @@ -32,7 +31,7 @@ libanjuta_macro_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS) libanjuta_macro_la_LIBADD = \ $(GLADE_LIBS) \ $(GNOME_VFS_LIBS) \ - $(LIBANJUTA_LIBS) $(PCRE_LIBS) + $(LIBANJUTA_LIBS) libanjuta_macro_la_SOURCES = \ plugin.c\ diff --git a/plugins/search/Makefile.am b/plugins/search/Makefile.am index f0d92bca..977f4be5 100644 --- a/plugins/search/Makefile.am +++ b/plugins/search/Makefile.am @@ -28,7 +28,6 @@ search_ui_DATA = anjuta-search.ui AM_CPPFLAGS = \ $(WARN_CFLAGS) \ $(DEPRECATED_FLAGS) \ - $(PCRE_CFLAGS) \ $(GNOME_PRINT_UI_CFLAGS) \ $(GNOME_VFS_CFLAGS) \ $(LIBANJUTA_CFLAGS) \ @@ -37,7 +36,6 @@ AM_CPPFLAGS = \ libanjuta_search_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS) libanjuta_search_la_LIBADD = \ - $(PCRE_LIBS) \ $(GNOME_PRINT_UI_LIBS) \ $(GNOME_UI_LIBS) \ $(GLADE_LIBS) \ diff --git a/plugins/search/search-replace.h b/plugins/search/search-replace.h index 0eb91ee7..a8be08a1 100644 --- a/plugins/search/search-replace.h +++ b/plugins/search/search-replace.h @@ -7,7 +7,6 @@ extern "C" #endif #include -#include #include typedef enum _GUIElementType diff --git a/plugins/sourceview/Makefile.am b/plugins/sourceview/Makefile.am index c22dd083..cb70c5ad 100644 --- a/plugins/sourceview/Makefile.am +++ b/plugins/sourceview/Makefile.am @@ -24,7 +24,6 @@ sourceview_plugin_DATA = $(plugin_in_files:.plugin.in=.plugin) AM_CPPFLAGS = \ $(WARN_CFLAGS) \ $(DEPRECATED_FLAGS) \ - $(PCRE_CFLAGS) \ $(GNOME_PRINT_UI_CFLAGS) \ $(GNOME_VFS_CFLAGS) \ $(PLUGIN_SOURCEVIEW_CFLAGS) \ @@ -82,7 +81,6 @@ libanjuta_sourceview_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS) # Plugin dependencies libanjuta_sourceview_la_LIBADD = \ - $(PCRE_LIBS) \ $(GNOME_PRINT_UI_LIBS) \ $(GNOME_VFS_LIBS) \ $(PLUGIN_SOURCEVIEW_LIBS) \ diff --git a/plugins/sourceview/anjuta-document.c b/plugins/sourceview/anjuta-document.c index edbcc6db..aacefd60 100644 --- a/plugins/sourceview/anjuta-document.c +++ b/plugins/sourceview/anjuta-document.c @@ -50,7 +50,6 @@ #include "anjuta-utils.h" #include -#include #define ANJUTA_MAX_PATH_LEN 2048 diff --git a/plugins/subversion/Makefile.am b/plugins/subversion/Makefile.am index 0bbadf61..eda51008 100644 --- a/plugins/subversion/Makefile.am +++ b/plugins/subversion/Makefile.am @@ -24,8 +24,7 @@ AM_CPPFLAGS= \ $(DEPRECATED_FLAGS) \ $(LIBANJUTA_CFLAGS) \ $(SVN_CFLAGS) \ - $(SVN_INCLUDE)\ - $(PCRE_CFLAGS) + $(SVN_INCLUDE) plugindir = $(anjuta_plugin_dir) @@ -35,7 +34,7 @@ libanjuta_subversion_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS) libanjuta_subversion_la_LIBADD = \ $(GLADE_LIBS) $(GNOME_VFS_LIBS) \ - $(LIBANJUTA_LIBS) $(PCRE_LIBS) $(SVN_LIB) + $(LIBANJUTA_LIBS) $(SVN_LIB) libanjuta_subversion_la_SOURCES = \ plugin.c \ -- 2.11.4.GIT