Namazu-devel-ja(旧)


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

Re: summary の展開でくずれる



<200203130704.QAA04574@xxxxxxxxxxxxx>の記事において
私は書きました。

>> # ちょっとパッチを書いてみます。

  これで直ったようなので commit しておきました。
-- 
NOKUBI Takatsugu
E-mail: knok@xxxxxxxxxxxxx
	knok@xxxxxxxxxx / knok@xxxxxxxxxx

Index: ChangeLog
===================================================================
RCS file: /storage/cvsroot/namazu/ChangeLog,v
retrieving revision 1.837.4.174
diff -u -r1.837.4.174 ChangeLog
--- ChangeLog	2002/03/06 06:20:45	1.837.4.174
+++ ChangeLog	2002/03/13 08:36:21
@@ -1,3 +1,11 @@
+2002-03-13  NOKUBI Takatsugu  <knok@xxxxxxxxxxxxx>
+
+	* src/output.c (print_hlist): Fixed excessive deletion of
+	HTML tags (namazu-devel-ja#02406).
+	(Reported by Seiji Yamashita, thanks.)
+	(unhtml_buffer): Splitted a new function from 
+	fputs_without_html_tag().
+
 2002-03-06  NOKUBI Takatsugu  <knok@xxxxxxxxxxxxx>
 
 	* filter/compress.pl (filter): Added trapping sigpipe (bugs-ja#111).
Index: src/output.c
===================================================================
RCS file: /storage/cvsroot/namazu/src/output.c,v
retrieving revision 1.80.4.12
diff -u -r1.80.4.12 output.c
--- src/output.c	2001/12/21 08:44:40	1.80.4.12
+++ src/output.c	2002/03/13 08:36:22
@@ -87,6 +87,7 @@
  */
 
 static void emprint( char *s, int entity_encode );
+static void unhtml_buffer( char *ostr );
 static void fputs_without_html_tag ( const char *str, FILE *fp );
 static char *load_nmz_result(const char *basedir);
 static void print_hitnum_each ( struct nmz_hitnumlist *hn );
@@ -146,12 +147,13 @@
 /*
  * Output string without HTML elements
  */
-static void 
-fputs_without_html_tag(const char *str, FILE *fp)
-{
+static void
+unhtml_buffer(char *ostr) {
     int f, i;
-    char buf[BUFSIZE];
-
+    char buf[BUFSIZE], *str;
+    int len;
+    len = strlen(ostr) + 1;
+    str = ostr;
     for (f = 0, i = 0; *str && i < BUFSIZE; str++) {
 
 	/* Iso-2022-jp handling */
@@ -211,10 +213,17 @@
 	}
     }
     buf[i] = '\0';
+    strncpy(ostr, buf, len);
+}
+static void 
+fputs_without_html_tag(const char *str, FILE *fp)
+{
+    char buf[BUFSIZE];
+    strncpy(buf, str, BUFSIZE);
+    unhtml_buffer(buf);
     fputs(buf, fp);
 }
 
-
 static void 
 print_hitnum_each (struct nmz_hitnumlist *hn)
 {
@@ -410,13 +419,25 @@
 	    }
 	}
 
-	compose_result(hlist.data[i], counter, template,  result);
+	if (is_htmlmode() || is_listmode()) {
+	    compose_result(hlist.data[i], counter, template,  result);
+	} else {
+	    char tmpbuf[BUFSIZE];
+	    strncpy(tmpbuf, template, BUFSIZE -1);
+	    tmpbuf[BUFSIZE - 1] = 0;
+	    unhtml_buffer(tmpbuf);
+	    compose_result(hlist.data[i], counter, tmpbuf,  result);	    
+	}
 	{
 	    char *converted = nmz_codeconv_external(result);
 	    if (converted == NULL) {
 		die(nmz_get_dyingmsg());
 	    }
-	    html_print(converted);
+	    if (is_htmlmode() || is_listmode()) {
+		html_print(converted);
+	    } else {
+		puts(converted+1); /* remove '\t' in the head of buffer */
+	    }
 	    free(converted);
 	    printf("\n");
 	}