From dd8128f6cb11078bcdf46d7f82acf8d6d9ef7254 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Tue, 13 Jun 2006 00:40:43 -0500 Subject: [PATCH] Broken regex replacement handling --- moo/mooedit/mootextsearch.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/moo/mooedit/mootextsearch.c b/moo/mooedit/mootextsearch.c index 4123add5..8888fec5 100644 --- a/moo/mooedit/mootextsearch.c +++ b/moo/mooedit/mootextsearch.c @@ -427,16 +427,28 @@ moo_text_replace_regex_all_real (GtkTextIter *start, } else { - freeme = egg_regex_try_eval_replacement (regex, replacement, &error); + gboolean has_references = FALSE; - if (error) + if (!egg_regex_check_replacement (replacement, &has_references, &error)) { g_warning ("%s: %s", G_STRLOC, error->message); g_error_free (error); return 0; } - const_replacement = freeme; + if (!has_references) + { + freeme = egg_regex_try_eval_replacement (regex, replacement, &error); + + if (error) + { + g_warning ("%s: %s", G_STRLOC, error->message); + g_error_free (error); + return 0; + } + + const_replacement = freeme; + } } buffer = gtk_text_iter_get_buffer (start);