[geany/geany] 21f071: Fix \b regex word boundary always matching at start of search

Nick Treleaven git-noreply at xxxxx
Thu Jul 26 00:02:26 UTC 2012


Branch:      refs/heads/document-messages
Author:      Nick Treleaven <nick.treleaven at btinternet.com>
Committer:   Nick Treleaven <nick.treleaven at btinternet.com>
Date:        Sun, 25 Dec 2011 13:42:19
Commit:      21f0715381a4a75298ca2fda2aa66c3003529070
             https://github.com/geany/geany/commit/21f0715381a4a75298ca2fda2aa66c3003529070

Log Message:
-----------
Fix \b regex word boundary always matching at start of search


Modified Paths:
--------------
    src/search.c

Modified: src/search.c
14 files changed, 5 insertions(+), 9 deletions(-)
===================================================================
@@ -1859,7 +1859,6 @@ static gchar *get_regex_match_string(const gchar *text, CharOffsets *match)
 static gint find_regex(ScintillaObject *sci, guint pos, GRegex *regex)
 {
 	const gchar *text;
-	gint flags = 0;
 	GMatchInfo *minfo;
 	gint ret = -1;
 
@@ -1868,14 +1867,11 @@ static gint find_regex(ScintillaObject *sci, guint pos, GRegex *regex)
 	/* clear old match */
 	setptr(regex_match_text, NULL);
 
-	if (sci_get_col_from_position(sci, pos) != 0)
-		flags = G_REGEX_MATCH_NOTBOL;
 	/* Warning: any SCI calls will invalidate 'text' after calling SCI_GETCHARACTERPOINTER */
 	text = (void*)scintilla_send_message(sci, SCI_GETCHARACTERPOINTER, 0, 0);
-	text += pos;
 
 	/* Warning: minfo will become invalid when 'text' does! */
-	if (g_regex_match(regex, text, flags, &minfo))
+	if (g_regex_match_full(regex, text, -1, pos, 0, &minfo, NULL))
 	{
 		gint i;
 
@@ -1890,7 +1886,7 @@ static gint find_regex(ScintillaObject *sci, guint pos, GRegex *regex)
 			regex_matches[i].start = start;
 			regex_matches[i].end = end;
 		}
-		ret = regex_matches[0].start + pos;
+		ret = regex_matches[0].start;
 	}
 	g_match_info_free(minfo);
 	return ret;
@@ -1913,7 +1909,7 @@ gint search_find_next(ScintillaObject *sci, const gchar *str, gint flags)
 	pos = sci_get_current_position(sci);
 	ret = find_regex(sci, pos, regex);
 	if (ret >= 0)
-		sci_set_selection(sci, ret, regex_matches[0].end + pos);
+		sci_set_selection(sci, ret, regex_matches[0].end);
 
 	g_regex_unref(regex);
 	return ret;
@@ -1983,8 +1979,8 @@ gint search_find_text(ScintillaObject *sci, gint flags, struct Sci_TextToFind *t
 
 	if (ret >= 0 && ret < ttf->chrg.cpMax)
 	{
-		ttf->chrgText.cpMin = regex_matches[0].start + pos;
-		ttf->chrgText.cpMax = regex_matches[0].end + pos;
+		ttf->chrgText.cpMin = regex_matches[0].start;
+		ttf->chrgText.cpMax = regex_matches[0].end;
 	}
 	g_regex_unref(regex);
 	return ret;


@@ Diff output truncated at 100000 characters. @@


--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).



More information about the Commits mailing list