[gnote] The last bits of replacement with PCRE.



commit 171be692e5d374d66f8f5a1af96484205528de2d
Author: Hubert Figuiere <hub figuiere net>
Date:   Fri Jun 5 23:46:45 2009 -0400

    The last bits of replacement with PCRE.
---
 NEWS                                      |    1 +
 configure.ac                              |    1 -
 src/Makefile.am                           |    2 +-
 src/addins/bugzilla/bugzillanoteaddin.cpp |   29 +++++++++++++----------------
 src/watchers.cpp                          |    3 ---
 5 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/NEWS b/NEWS
index 4f0360b..10bfb17 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+  * Replace the regex support from Boost.Regex with PCRE.
   * WikiWord now support non ASCII (Closes #581495)
 
 0.5.0 -
diff --git a/configure.ac b/configure.ac
index 2f5fc15..03d9582 100644
--- a/configure.ac
+++ b/configure.ac
@@ -137,7 +137,6 @@ BOOST_BIND
 BOOST_CONVERSION
 BOOST_FILESYSTEM
 BOOST_FORMAT
-BOOST_REGEX
 BOOST_TEST([s])
 
 AC_LANG_PUSH(C++)
diff --git a/src/Makefile.am b/src/Makefile.am
index 573cb84..f23036c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,7 +16,7 @@ AM_CPPFLAGS= LIBGTKMM_CFLAGS@ @LIBGLIBMM_CFLAGS@ \
 AM_LDFLAGS=-Wl,--export-dynamic
 
 GNOTE_LIBS = libgnote.a @LIBGLIBMM_LIBS@ @LIBGTKMM_LIBS@ \
-	@GCONF_LIBS@ @BOOST_FILESYSTEM_LIBS@ @BOOST_REGEX_LIBS@ \
+	@GCONF_LIBS@ @BOOST_FILESYSTEM_LIBS@ \
 	@LIBXSLT_LIBS@ \
 	@PCRE_LIBS@ \
 	@GTKSPELL_LIBS@ @GTK_LIBS@ \
diff --git a/src/addins/bugzilla/bugzillanoteaddin.cpp b/src/addins/bugzilla/bugzillanoteaddin.cpp
index 8d792d3..bee1155 100644
--- a/src/addins/bugzilla/bugzillanoteaddin.cpp
+++ b/src/addins/bugzilla/bugzillanoteaddin.cpp
@@ -19,9 +19,10 @@
 
 
 
-#include <boost/regex.hpp>
 #include <boost/lexical_cast.hpp>
 
+#include <pcrecpp.h>
+
 #include <glibmm/i18n.h>
 
 
@@ -122,21 +123,17 @@ namespace bugzilla {
 
     const char * regexString = "\\bhttps?://.*/show_bug\\.cgi\\?(\\S+\\&){0,1}id=(\\d{1,})";
 
-    boost::regex re(regexString, boost::regex::extended|boost::regex_constants::icase);
-    boost::match_results<std::string::const_iterator> m;
-    if(regex_match(uriString, m, re) && m[2].matched) {
-      try {
-        int bugId = boost::lexical_cast<int>(std::string(m[2].first, m[2].second));
-
-        if (insert_bug (x, y, uriString, bugId)) {
-          context->drag_finish(true, false, time);
-          g_signal_stop_emission_by_name(get_window()->editor()->gobj(),
-                                         "drag_data_received");
-        }
-      }
-      catch(const std::exception & e) {
-        ERR_OUT("exception while converting URL '%s': %s",
-                uriString.c_str(), e.what());
+    pcrecpp::RE re(regexString, pcrecpp::RE_Options(PCRE_CASELESS|PCRE_UTF8));
+    int m;
+
+    if(re.FullMatch(uriString, (void*)NULL, &m)) {
+
+      int bugId = m;
+
+      if (insert_bug (x, y, uriString, bugId)) {
+        context->drag_finish(true, false, time);
+        g_signal_stop_emission_by_name(get_window()->editor()->gobj(),
+                                       "drag_data_received");
       }
     }
   }
diff --git a/src/watchers.cpp b/src/watchers.cpp
index b76148b..86100a7 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -510,14 +510,11 @@ namespace gnote {
     std::string s(start.get_slice(end));
     std::string match1;
 
-    DBG_OUT("input is %s", s.c_str());
     const char *p = s.c_str();
     pcrecpp::StringPiece input(p);
 
     while(m_regex.FindAndConsume(&input, &match1)) {
 
-      DBG_OUT("match1 '%s'", match1.c_str());
-
       Gtk::TextIter start_cpy = start;
       // must construct the Glib::ustring from a char *.
       // otherwise it expect the num of chars (UTF-8) instead of bytes.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]