[gtksourceview/wip/regex-search] search: add debug messages for the regex search



commit 192d7d3b869bd78d7d04a5e1cbc73b2a984abcad
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jul 20 19:45:54 2013 +0200

    search: add debug messages for the regex search

 gtksourceview/gtksourcesearch.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearch.c b/gtksourceview/gtksourcesearch.c
index 0067b4c..bcd4e04 100644
--- a/gtksourceview/gtksourcesearch.c
+++ b/gtksourceview/gtksourcesearch.c
@@ -23,6 +23,7 @@
 #include "gtksourcebuffer.h"
 #include "gtksourcestylescheme.h"
 #include "gtksourcestyle-private.h"
+#include "gtksourceutils.h"
 #include "gtktextregion.h"
 
 #include <string.h>
@@ -1687,24 +1688,47 @@ regex_search_scan_segment (GtkSourceSearch   *search,
                                     &real_start,
                                     &start_pos);
 
+       DEBUG ({
+              g_print ("\n*** regex search - scan segment ***\n");
+              g_print ("start position in the subject: %d\n", start_pos);
+       });
+
        if (!gtk_text_iter_starts_line (&real_start))
        {
                match_options |= G_REGEX_MATCH_NOTBOL;
+
+               DEBUG ({
+                      g_print ("match notbol\n");
+               });
        }
 
        if (!gtk_text_iter_ends_line (segment_end))
        {
                match_options |= G_REGEX_MATCH_NOTEOL;
+
+               DEBUG ({
+                      g_print ("match noteol\n");
+               });
        }
 
        if (!gtk_text_iter_is_end (segment_end))
        {
                match_options |= G_REGEX_MATCH_PARTIAL_HARD;
+
+               DEBUG ({
+                      g_print ("match partial hard\n");
+               });
        }
 
        subject = gtk_text_iter_get_visible_text (&real_start, segment_end);
        subject_length = strlen (subject);
 
+       DEBUG ({
+              gchar *subject_escaped = gtk_source_utils_escape_search_text (subject);
+              g_print ("subject (escaped): %s\n", subject_escaped);
+              g_free (subject_escaped);
+       });
+
        g_regex_match_full (search->priv->regex,
                            subject,
                            subject_length,
@@ -1729,6 +1753,14 @@ regex_search_scan_segment (GtkSourceSearch   *search,
                                           &match_start,
                                           &match_end);
 
+               DEBUG ({
+                        gchar *match_text = gtk_text_iter_get_visible_text (&match_start, &match_end);
+                        gchar *match_escaped = gtk_source_utils_escape_search_text (match_text);
+                        g_print ("match found (escaped): %s\n", match_escaped);
+                        g_free (match_text);
+                        g_free (match_escaped);
+               });
+
                search->priv->occurrences_count++;
 
                g_match_info_next (match_info, &error);
@@ -1744,6 +1776,10 @@ regex_search_scan_segment (GtkSourceSearch   *search,
        {
                *stopped_at = iter;
                segment_finished = FALSE;
+
+               DEBUG ({
+                      g_print ("partial match\n");
+               });
        }
        else
        {


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