[Kazehakase-devel 1957] Re: Migemoを使うとFindがwrapしない

Back to archive index

Kouhei Sutou kou****@cozmi*****
2005年 2月 25日 (金) 18:30:50 JST


須藤です.

In <20050****@ikezo*****>
  "[Kazehakase-devel 1956] Re: Migemoを使うとFindがwrapしない" on Fri, 25 Feb 2005 14:17:05 +0900,
  Hiroyuki Ikezoe <poinc****@ikezo*****> wrote:

> > Migemoを使ったFindがwrapしません.
> > 
> このパッチだと逆方向がうまく行ってないと思います。

むむ.
これでどうでしょう.

> # もともと逆向きは微妙にバグってんですが…

これも直った気がします.
# 文書中で一番先頭でマッチしたキーワードしか検索対象にならな
# いやつですよね?

> またいつでも御世話しますんで遠慮なくどうぞ。

それは楽しみです. :)
-------------- next part --------------
Index: src/mozilla/kz-mozembed.cpp
===================================================================
RCS file: /cvsroot/kazehakase/kazehakase/src/mozilla/kz-mozembed.cpp,v
retrieving revision 1.42.2.4
diff -u -p -r1.42.2.4 kz-mozembed.cpp
--- src/mozilla/kz-mozembed.cpp	15 Feb 2005 06:09:39 -0000	1.42.2.4
+++ src/mozilla/kz-mozembed.cpp	25 Feb 2005 09:27:01 -0000
@@ -1409,7 +1409,20 @@ kz_moz_embed_find (KzEmbed *kzembed, con
 		if (mozembed->priv->migemo_keyword)
 			g_free(mozembed->priv->migemo_keyword);
 		mozembed->priv->migemo_keyword =
-			migemo_get_matched_text(body_string, keyword);
+			migemo_get_matched_text(body_string, keyword, backward);
+
+		if (!mozembed->priv->migemo_keyword)
+		{
+			gchar *last_keyword = NULL;
+			g_free(body_string);
+			rv = mozembed->priv->wrapper->GetBodyString(text);
+			if (NS_FAILED(rv))
+				goto START_SEARCH;
+			mozembed->priv->wrapper->GetBodyString(text);
+			body_string = g_strdup(NS_ConvertUCS2toUTF8(text).get());
+			mozembed->priv->migemo_keyword =
+				migemo_get_matched_text(body_string, keyword, backward);
+		}
 		
 		if (mozembed->priv->migemo_keyword)
 		{
@@ -1481,7 +1494,7 @@ kz_moz_embed_incremental_search (KzEmbed
 		if (mozembed->priv->migemo_keyword)
 			g_free(mozembed->priv->migemo_keyword);
 		mozembed->priv->migemo_keyword =
-			migemo_get_matched_text(body_string, keyword);
+			migemo_get_matched_text(body_string, keyword, backward);
 
 		if (mozembed->priv->migemo_keyword) 
 		{
Index: src/utils/migemo.c
===================================================================
RCS file: /cvsroot/kazehakase/kazehakase/src/utils/migemo.c,v
retrieving revision 1.13.2.1
diff -u -p -r1.13.2.1 migemo.c
--- src/utils/migemo.c	6 Feb 2005 11:24:26 -0000	1.13.2.1
+++ src/utils/migemo.c	25 Feb 2005 09:27:02 -0000
@@ -144,7 +144,7 @@ migemo_get_regex(const gchar *text)
 }
 
 gchar *
-migemo_get_matched_text(const gchar *body, const gchar *text)
+migemo_get_matched_text(const gchar *body, const gchar *text, const gboolean last)
 {
 	gchar *matched_text = NULL;
 	gchar *regex;
@@ -172,9 +172,12 @@ migemo_get_matched_text(const gchar *bod
 		return NULL;
 	}
 
-	if (egg_regex_match(egg_regex, body, -1, 0) > 0)
+	while (egg_regex_match_next(egg_regex, body, -1, 0) > 0)
 	{
+		if (matched_text)
+			g_free(matched_text);
 		matched_text = egg_regex_fetch(egg_regex, body, 0);
+		if (!last) break;
 	}
 	egg_regex_free(egg_regex);
 	return matched_text;
Index: src/utils/migemo.h
===================================================================
RCS file: /cvsroot/kazehakase/kazehakase/src/utils/migemo.h,v
retrieving revision 1.9.2.1
diff -u -p -r1.9.2.1 migemo.h
--- src/utils/migemo.h	6 Feb 2005 11:24:26 -0000	1.9.2.1
+++ src/utils/migemo.h	25 Feb 2005 09:27:02 -0000
@@ -49,7 +49,8 @@ gboolean migemo_init                 (vo
 void     migemo_exit                 (void);
 gchar   *migemo_get_regex            (const gchar *text);
 gchar   *migemo_get_matched_text     (const gchar *body,
-				      const gchar *text);
+				      const gchar *text,
+				      const gboolean last);
 
 G_END_DECLS
 


Kazehakase-devel メーリングリストの案内
Back to archive index