[Namazu-devel-ja 1662] Re: Emphasis tagが閉じない問題
Tadamasa Teranishi
yw3t-trns @ asahi-net.or.jp
2008年 1月 31日 (木) 18:13:18 JST
寺西です。
実はこのパッチは問題ありありでして、コンパイルが通りませんでした。
NOKUBI Takatsugu wrote:
>
> diff -u -r1.80.4.17 output.c
> --- src/output.c 20 Mar 2004 15:02:51 -0000 1.80.4.17
> +++ src/output.c 10 Oct 2007 05:48:16 -0000
> @@ -117,11 +117,14 @@
> emprint(char *s, int entity_encode)
> {
> int i;
> + int nestedtags = 0;
> for (i = 0; i < BUFSIZE * 16 && *s; s++) {
> if (*s == EM_START_MARK) {
> + nestedtags++:
> fputs(emphasis_start_tag, stdout);
> continue;
> } else if (*s == EM_END_MARK) {
> + nestedtags--:
2つとも ';' と ':' の間違いです。
> + for (; nestedtags < 0; nestedtags--) {
> + fputs(emphasis_end_tag, stdout);
> + }
nestedtags が正の場合ループは通らず、負の場合無限ループに入ります。
正解は
for (; nestedtags > 0; nestedtags--) {
です。これらは修正してコミットしました。
ところで、この方法の場合、次のようなパターンには無力です。
</EM></EM><EM><EM>
nestedtags は、-1, -2, -1, 0 となりますが、<EM> 状態で終わります。
さてどうしたものでしょうかね。
正の値の時だけ、nestedtags-- するようにすれば良いだけでしょうか。
if (nestedtags > 0) nestedtags--;
--
=====================================================================
寺西 忠勝(TADAMASA TERANISHI) yw3t-trns @ asahi-net.or.jp
http://www.asahi-net.or.jp/~yw3t-trns/index.htm
Key fingerprint = 474E 4D93 8E97 11F6 662D 8A42 17F5 52F4 10E7 D14E
Namazu-devel-ja メーリングリストの案内