[Namazu-cvs 752] r213 - Search-Namazu/trunk

cvsd @ vaj.namazu.org cvsd @ vaj.namazu.org
2006年 3月 27日 (月) 11:16:22 JST


Author: knok
Date: 2006-03-27 11:16:21 +0900 (Mon, 27 Mar 2006)
New Revision: 213

Modified:
   Search-Namazu/trunk/ChangeLog
   Search-Namazu/trunk/Namazu.xs
Log:
Splitted common code from call_search_main.


Modified: Search-Namazu/trunk/ChangeLog
===================================================================
--- Search-Namazu/trunk/ChangeLog	2006-03-27 00:26:14 UTC (rev 212)
+++ Search-Namazu/trunk/ChangeLog	2006-03-27 02:16:21 UTC (rev 213)
@@ -1,6 +1,7 @@
 2006-03-27  NOKUBI Takatsugu  <knok @ daionet.gr.jp>
 
 	* Namazu.xs: Fixed prototype.
+	  Splitted common code from call_search_main.
 
 2006-03-24  NOKUBI Takatsugu  <knok @ daionet.gr.jp>
 

Modified: Search-Namazu/trunk/Namazu.xs
===================================================================
--- Search-Namazu/trunk/Namazu.xs	2006-03-27 00:26:14 UTC (rev 212)
+++ Search-Namazu/trunk/Namazu.xs	2006-03-27 02:16:21 UTC (rev 213)
@@ -58,6 +58,46 @@
 
 static int status = 0;
 
+AV * call_search_main_c(char *query)
+{
+	AV *retar;
+	NmzResult hlist;
+	char result[SEARCH_NAMAZU_FIELDS][BUFSIZE];
+	int i;
+	status = 0;
+	retar = newAV();
+	hlist = nmz_search(query);
+	status = hlist.stat;
+	for (i = 0; i < hlist.num; i ++) {
+		SV *ohlist = perl_eval_pv("new Search::Namazu::Result", TRUE);
+		dSP;
+		nmz_get_field_data(hlist.data[i].idxid, hlist.data[i].docid, "uri", result[0]);
+		nmz_get_field_data(hlist.data[i].idxid, hlist.data[i].docid, "summary", result[1]);
+		nmz_get_field_data(hlist.data[i].idxid, hlist.data[i].docid, "title", result[2]);
+		nmz_get_field_data(hlist.data[i].idxid, hlist.data[i].docid, "author", result[3]);
+		nmz_get_field_data(hlist.data[i].idxid, hlist.data[i].docid, "size", result[4]);
+		ENTER;
+		SAVETMPS;
+		PUSHMARK(SP);
+		PUSHs(ohlist);
+		PUSHs(sv_2mortal(newSViv(hlist.data[i].score)));
+		PUSHs(sv_2mortal(newSVpv(result[0], strlen(result[0]))));
+		PUSHs(sv_2mortal(newSViv(hlist.data[i].date)));
+		PUSHs(sv_2mortal(newSViv(hlist.data[i].rank)));
+		PUSHs(sv_2mortal(newSVpv(result[1], strlen(result[1]))));
+		PUSHs(sv_2mortal(newSVpv(result[2], strlen(result[2]))));
+		PUSHs(sv_2mortal(newSVpv(result[3], strlen(result[3]))));
+		PUSHs(sv_2mortal(newSVpv(result[4], strlen(result[4]))));
+		PUTBACK;
+		perl_call_method("set", G_DISCARD);
+		av_push(retar, ohlist);
+		FREETMPS;
+		LEAVE;
+	}
+	nmz_free_hlist(hlist);
+	return retar;
+}
+
 MODULE = Search::Namazu		PACKAGE = Search::Namazu
 
 PROTOTYPES: DISABLE
@@ -69,52 +109,20 @@
 	PPCODE:
 		char *qstr;
 		char cqstr[BUFSIZE * 2];
+		AV *retar;
 		int i;
-		AV *retar;
-		NmzResult hlist;
-		char result[SEARCH_NAMAZU_FIELDS][BUFSIZE];
 
-		status = 0;
 		qstr = SvPV(query, PL_na);
 		nmz_codeconv_query(qstr);
 		strcpy(cqstr, qstr);
-		retar = newAV();
-		hlist = nmz_search(cqstr);
-		status = hlist.stat;
-		for (i = 0; i < hlist.num; i ++) {
-			SV *ohlist = perl_eval_pv("new Search::Namazu::Result", TRUE);
-			dSP;
-			nmz_get_field_data(hlist.data[i].idxid, hlist.data[i].docid, "uri", result[0]);
-			nmz_get_field_data(hlist.data[i].idxid, hlist.data[i].docid, "summary", result[1]);
-			nmz_get_field_data(hlist.data[i].idxid, hlist.data[i].docid, "title", result[2]);
-			nmz_get_field_data(hlist.data[i].idxid, hlist.data[i].docid, "author", result[3]);
-			nmz_get_field_data(hlist.data[i].idxid, hlist.data[i].docid, "size", result[4]);
-			ENTER;
-			SAVETMPS;
-			PUSHMARK(SP);
-			PUSHs(ohlist);
-			PUSHs(sv_2mortal(newSViv(hlist.data[i].score)));
-			PUSHs(sv_2mortal(newSVpv(result[0], strlen(result[0]))));
-			PUSHs(sv_2mortal(newSViv(hlist.data[i].date)));
-			PUSHs(sv_2mortal(newSViv(hlist.data[i].rank)));
-			PUSHs(sv_2mortal(newSVpv(result[1], strlen(result[1]))));
-			PUSHs(sv_2mortal(newSVpv(result[2], strlen(result[2]))));
-			PUSHs(sv_2mortal(newSVpv(result[3], strlen(result[3]))));
-			PUSHs(sv_2mortal(newSVpv(result[4], strlen(result[4]))));
-			PUTBACK;
-			perl_call_method("set", G_DISCARD);
-			av_push(retar, ohlist);
-			FREETMPS;
-			LEAVE;
-		}
-		nmz_free_hlist(hlist);
+		retar = call_search_main_c(cqstr);
 #if ! defined(PERL_VERSION)
 		{ /* workaround for only one result */
 			SV *ohlist = perl_eval_pv("new Search::Namazu::Result", TRUE);
 			XPUSHs(ohlist);
 		}
 #endif /* PERL_VERSION */
-		for (i = 0; i < hlist.num; i ++) {
+		for (i = 0; i <= av_len(retar); i ++) {
 			XPUSHs(av_pop(retar));
 		}
 		nmz_free_internal();




Namazu-cvs メーリングリストの案内