[gnome-commander/gcmd-1-2-8] Fixed problem #616891 (build error on RHEL 5.5)
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/gcmd-1-2-8] Fixed problem #616891 (build error on RHEL 5.5)
- Date: Mon, 31 May 2010 22:37:51 +0000 (UTC)
commit 40a7dbba0f8eb71b0d7f43c6c7fc4f12ed283f79
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Tue Jun 1 00:34:40 2010 +0200
Fixed problem #616891 (build error on RHEL 5.5)
NEWS | 1 +
doc/C/gnome-commander.xml | 3 ++
src/dialogs/gnome-cmd-advrename-regex-dialog.cc | 6 ++--
src/gnome-cmd-advrename-dialog.cc | 25 -----------------------
src/gnome-cmd-regex.h | 25 ++++++++++++++++++++++-
5 files changed, 31 insertions(+), 29 deletions(-)
---
diff --git a/NEWS b/NEWS
index d774749..495d36b 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Bug fixes:
* Fixed problem #602795 (file content search)
* Fixed problem #609912 (build error with --as-needed)
* Fixed problem #612685 (crashes when double-clicking on a bookmark)
+ * Fixed problem #616891 (build error on RHEL 5.5)
New features:
* New translations: ko
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index d831425..70c2544 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -6031,6 +6031,9 @@
<listitem>
<para>Fixed problem #612685 (crashes when double-clicking on a bookmark)</para>
</listitem>
+ <listitem>
+ <para>Fixed problem #616891 (build error on RHEL 5.5)</para>
+ </listitem>
</itemizedlist>
</para>
<para>New features:</para>
diff --git a/src/dialogs/gnome-cmd-advrename-regex-dialog.cc b/src/dialogs/gnome-cmd-advrename-regex-dialog.cc
index 919f1d7..dfbe4b8 100644
--- a/src/dialogs/gnome-cmd-advrename-regex-dialog.cc
+++ b/src/dialogs/gnome-cmd-advrename-regex-dialog.cc
@@ -109,9 +109,9 @@ gboolean gnome_cmd_advrename_regex_dialog_new (const gchar *title, GtkWindow *pa
gtk_container_add (GTK_CONTAINER (align), check);
#if !GLIB_CHECK_VERSION (2, 14, 0)
- box = gnome_cmd_hint_box_new (_("Some regular expressions functionality is disabled. "
- "To enable it's necessary to build GNOME Commander with GLib â?¥ 2.14. "
- "Please contact your package maintainer about that."));
+ GtkWidget *box = gnome_cmd_hint_box_new (_("Some regular expressions functionality is disabled. "
+ "To enable it's necessary to build GNOME Commander with GLib â?¥ 2.14. "
+ "Please contact your package maintainer about that."));
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
#endif
diff --git a/src/gnome-cmd-advrename-dialog.cc b/src/gnome-cmd-advrename-dialog.cc
index 8f38b93..73c2bb9 100644
--- a/src/gnome-cmd-advrename-dialog.cc
+++ b/src/gnome-cmd-advrename-dialog.cc
@@ -613,10 +613,6 @@ void GnomeCmdAdvrenameDialog::update_new_filenames()
rx.push_back(r);
}
-#if !GLIB_CHECK_VERSION (2, 14, 0)
- vector<pair<int,int> > match;
-#endif
-
for (gboolean valid_iter=gtk_tree_model_get_iter_first (files, &i); valid_iter; valid_iter=gtk_tree_model_iter_next (files, &i))
{
GnomeCmdFile *f;
@@ -635,29 +631,8 @@ void GnomeCmdAdvrenameDialog::update_new_filenames()
gchar *prev_fname = fname;
-#if GLIB_CHECK_VERSION (2, 14, 0)
fname = r->replace(prev_fname);
-#else
- match.clear();
-
- for (gchar *s=prev_fname; *s && r->match(s); s+=r->end())
- if (r->length()>0)
- match.push_back(make_pair(r->start(), r->end()));
-
- gchar *src = prev_fname;
- gchar *dest = fname = (gchar *) g_malloc (strlen(prev_fname) + match.size()*r->to.size() + 1); // allocate new fname big enough to hold all data
-
- for (vector<pair<int,int> >::const_iterator i=match.begin(); i!=match.end(); ++i)
- {
- memcpy(dest, src, i->first);
- dest += i->first;
- src += i->second;
- memcpy(dest, r->to.c_str(), r->to.size());
- dest += r->to.size();
- }
- strcpy(dest, src);
-#endif
g_free (prev_fname);
}
diff --git a/src/gnome-cmd-regex.h b/src/gnome-cmd-regex.h
index eb53d5c..1051276 100644
--- a/src/gnome-cmd-regex.h
+++ b/src/gnome-cmd-regex.h
@@ -229,7 +229,30 @@ namespace GnomeCmd
#if GLIB_CHECK_VERSION (2, 14, 0)
return g_regex_replace (re, s, -1, 0, replacement.c_str(), G_REGEX_MATCH_NOTEMPTY, NULL);
#else
- return NULL;
+ regmatch_t pmatch;
+
+ memset(&pmatch, 0, sizeof(pmatch));
+
+ std::vector<std::pair<int,int> > match;
+
+ for (const gchar *i=s; *i && regexec(&re,i,1,&pmatch,0)==0; i+=pmatch.rm_eo)
+ if (pmatch.rm_so!=pmatch.rm_eo)
+ match.push_back(std::make_pair(pmatch.rm_so,pmatch.rm_eo));
+
+ gchar *dest = (gchar *) g_malloc (strlen(s) + match.size()*replacement.size() + 1), // allocate new string big enough to hold all data
+ *retval = dest;
+
+ for (std::vector<std::pair<int,int> >::const_iterator i=match.begin(); i!=match.end(); ++i)
+ {
+ dest += i->first;
+ src += i->second;
+ memcpy(dest, replacement.c_str(), replacement.size());
+ dest += replacement.size();
+ }
+
+ strcpy(dest, src);
+
+ return retval;
#endif
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]