Yamashiro, Jun
yamaj****@ofug*****
2005年 5月 20日 (金) 02:36:43 JST
はじめまして、 山城@OFUG です。 私は pkgsrc-wip-jp プロジェクトでanthyのパッケージングを行っています。 http://pkgsrc-wip.sourceforge.jp/ 当プロジェクトのメーリングリストの [pkgsrc-wip-discuss 52] 以降のスレッドで anthy-dic-tool のバグが発見されました。 http://lists.sourceforge.jp/mailman/archives/pkgsrc-wip-discuss/2005-May/000051.html このバグの原因についての説明と、修正パッチを送ります。 説明: NetBSD/i386 上で anthy-6300 の anthy-dic-tool --load を利用した時に、 やましろじゅん 1 山城潤 -> やましろじゅん 1 しろじゅん 1 山城潤 などの辞書登録ミスが発生します。 このバグはFreeBSD/i386 と anthy-6300d(anthy-dic-toolsの該当部分に変化なし) の組合せでは発生しません。また、NetBSDとanthy-5900の組合せでも このバグは発生しません。 原因を調査したところ、今年の2〜3月ごろのバグ修正に原因がありました。 [pkgsrc-wip-discuss 58] より: http://lists.sourceforge.jp/mailman/archives/pkgsrc-wip-discuss/2005-May/000057.html | [Anthy-dev 1901] Re: 半角スペースを含む単語が辞書登録できない | http://lists.sourceforge.jp/mailman/archives/anthy-dev/2005-February/001900.html | で、NetBSDでも有効なコードが提示されたのですが、 | (今回の修正では、このコードを修正するパッチを追加しました) | sscanf(buf, "%s %s %[^\n]",yomi, freq, w) | というコードの移植性を心配した開発者が、 | もう少し移植性に気を配ったコードに変更して commit したようです。 | [Anthy-dev 1908] Re: 半角スペースを含む単語が辞書登録できない | http://lists.sourceforge.jp/mailman/archives/anthy-dev/2005-March/001907.html | | 今回の修正では 現在のコードを [Anthy-dev 1901] で紹介された方法に | 直すという方法で修正を行いました。 移植性が問題になった [Anthy-dev 1901] のコードですが、 scanfフォーマット文字列中の %[^\n] というコードは、Seventh Edition の時代から有効でした。 [pkgsrc-wip-discuss 61] Re: anthy-dic-tool http://lists.sourceforge.jp/mailman/archives/pkgsrc-wip-discuss/2005-May/000060.html | これを使って検索したところ、scanf("%[^\n]")は | UNIX Seventh Edition(1979年!)以降、BSD/SunOS/Linux等で問題なく使えるようです。 | http://www.freebsd.org/cgi/man.cgi?query=scanf&apropos=0&sektion=0&manpath=Unix+Seventh+Edition&format=html パッチ: 以下のパッチを src-util/dic-tool.c に適用してください。 よろしくお願いします。 --- src-util/dic-tool.c.orig 2005-02-28 22:35:44.000000000 +0900 +++ src-util/dic-tool.c 2005-05-18 03:23:42.000000000 +0900 @@ -16,7 +16,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <ctype.h> #include <dicutil.h> #include <config.h> @@ -287,24 +286,11 @@ find_head(char *yomi, char *freq, char *w) { char buf[256]; - char *p; - int i; do { if (!read_line(buf, 256, fp_in)) { return -1; } - } while (sscanf(buf, "%s %s %s",yomi, freq, w) != 3); - /* 単語はspaceを含みうるので、切り直し */ - p = buf; - for (i = 0; i < 2; i++) { - while (!isspace(p[0]) || - isspace(p[1])) { - p++; - } - p++; - } - /* pは3つめのトークンの先頭*/ - strncpy(w, p, 256); + } while (sscanf(buf, "%s %s %[^\n]", yomi, freq, w) != 3); return 0; } -- Okinawa FreeBSD Users Group 山城 潤(Yamashiro, Jun) E-mail: yamaj****@ofug***** ── このメッセージは自動的に消滅しません。