2008年1月10日木曜日

続:ja-plain2が……

結論: portsっていうレベルじゃないぞ!?

とりあえずデバッグしてみましょう。


--- plain2.org/Makefile 2008-01-09 21:35:05.000000000 +0900
+++ plain2/Makefile 2008-01-09 23:51:01.000000000 +0900
@@ -22,15 +22,11 @@
WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION:R}p${PORTVERSION:E}.orig
BUILD_WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION:R}p${PORTVERSION:E}.orig/src

-MAKE_ARGS= CC="${CC}" CFLAGS="${CFLAGS} -DBSD -DKANJI -DPICTURE -DHTML -fwritable-strings"
+MAKE_ARGS= CC="${CC}" CFLAGS="-g -DBSD -DKANJI -DPICTURE -DHTML"
ALL_TARGET= ${PORTNAME}

.include

-.if ${OSVERSION} >= 700042
-BROKEN= Broken with gcc 4.2
-.endif
-
post-patch:
@${REINPLACE_CMD} -e \
's|/usr/lib/plain2|${DATADIR}|g' ${BUILD_WRKSRC}/plain2.h


まあわざわざ書くまでもないところですか。


vmbsd7# make
(中略)
cc -g -DBSD -DKANJI -DPICTURE -DHTML -o plain2 plain2.o readfile.o miscutil.o section.o example.o list.o plaintxt.o spacing.o headfoot.o hint.o justify.o texout.o output.o renumout.o macro.o htmlout.o roffout.o analyze.o table.o title.o picture.o ftitle.o


順当順当。


vmfbsd7# cd work/plain2-2.54p1.orig/src/
vmfbsd7# gdb ./plain2
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) run -tex ./plain2.h

Starting program: /usr/ports/japanese/plain2/work/plain2-2.54p1.orig/src/plain2 -tex ./plain2.h

Program received signal SIGSEGV, Segmentation fault.
0x0805253d in macroParse (
s=0x805affd "$2]{j-article}\n\\else\\documentstyle[$3]{jarticle}\\fi\n\\setcounter{secnumdepth}{6}\n\\setcounter{tocdepth}{6}\n\\topsep=0.1cm\n\\parsep=0.1cm\n\\itemsep=0.0cm\n%\\renewcommand{\\bf}{\\protect\\pbf\\protect\\pdg}\n\\begin"..., macroNum=0,
orig=0x805af98 "\\newif\\ifNTT\\NTTfalse\n\\ifx\\gtfam\\undefined\\ifx\\gtfamily\\undefined\\NTTtrue\\fi\\fi\n\\ifNTT\\documentstyle[$2]{j-article}\n\\else\\documentstyle[$3]{jarticle}\\fi\n\\setcounter{secnumdepth}{6}\n\\setcounter{tocdept"...) at macro.c:121
121 *s = '\0';
(gdb)


macro.c で、ポインタsが指してる先に '\0' を書こうとしてますね。
んでそれは文字列の一部、と。え、文字列?


(gdb) list
116 != def_type) {
117 fprintf(stderr,"Improper argtype in \"%s %s\"\n",
118 macNames[macroNum].mname_name, orig);
119 exit(1);
120 }
121 *s = '\0';
122 if (*(s + 2) == '\0')
123 return mip;;
124 new_mip->cmac_next = macroParse(s + 2, macroNum, orig);
125 break;


これでは分からない……。該当する文字列はどこで設定しているか、macro.c を見てみると、


28 struct macDefs texMacros[] = {
29 M_DOC_BEGIN, STR_DOC_BEGIN,
30 M_DOC_END, "\\end{document}\n",
31 M_PLAIN_BEGIN, "\\par\n",
32 M_PLAIN_END, "",


とかやっていて、STR_DOC_BEGIN にあの長ったらしい文字列がdefineされていました。
で、macDefsの定義はというと、grep したらば macro.h にあるという。曰く、


75 struct macDefs {
76 int mdef_number;
77 char *mdef_def;
78 };


こ、これではダメだ……書けるはずがない。というかこれを無理やり? 書けるようにするためのコンパイルオプションが -fwritable-strings だった、というわけですね。

えー、これ直すのー?(実はすぐ直せるんだけど…)

ja-plain2がbrokenなんですけど……(未解決)

実況:ハマる ports いじり。




ja-mhの件で、過去自分が使ったことのあるものでBROKENなものが他にあるのか、調べてみると……
(参考: http://portsmon.freebsd.org/portsconcordanceforbroken.py
なんと懐かしのplain2が壊れている。
FreeBSD 7.0 では gcc4.2.1 なわけだけど、コンパイラオプションの -fwritable-strings が無いため、らしい。

なら外してみればいいじゃない!(ぉ

(本当はrootでやっちゃいけません。たぶん。)



vmbsd7# cd /usr/ports/japanese
vmbsd7# cp -r plain2 plain2.org
vmbsd7# cd plain2


こちゃこちゃとMakefileを書いてみよう。




vmfbsd7# diff -u plain2.org/Makefile plain2/Makefile
--- plain2.org/Makefile 2008-01-09 21:35:05.000000000 +0900
+++ plain2/Makefile 2008-01-09 22:20:32.000000000 +0900
@@ -22,14 +22,14 @@
WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION:R}p${PORTVERSION:E}.orig
BUILD_WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION:R}p${PORTVERSION:E}.orig/src

-MAKE_ARGS= CC="${CC}" CFLAGS="${CFLAGS} -DBSD -DKANJI -DPICTURE -DHTML -fwritable-strings"
+MAKE_ARGS= CC="${CC}" CFLAGS="${CFLAGS} -DBSD -DKANJI -DPICTURE -DHTML"
ALL_TARGET= ${PORTNAME}

.include

-.if ${OSVERSION} >= 700042
-BROKEN= Broken with gcc 4.2
-.endif
+#.if ${OSVERSION} >= 700042
+#BROKEN= Broken with gcc 4.2
+#.endif

post-patch:
@${REINPLACE_CMD} -e \


結果。
http://www1.odn.ne.jp/taraijpn/plain2_errlog.txt

なにが恐ろしいってbinary出来てるんだよなあ……おそるおそる実行してみよう。
(やっぱりrootでやっちゃいけません。)




vmfbsd7# ./plain2 -tex ./plain2.h
Segmentation fault (core dumped)



そりゃそうだ。まあ plain2.h に手を入れて warningを消すことを考えよう。

http://www1.odn.ne.jp/taraijpn/patch-src::plain2.h




vmbsd7# make
(中略)
===> Building for ja-plain2-2.54.1_2
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c plain2.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c readfile.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c miscutil.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c section.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c example.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c list.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c plaintxt.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c spacing.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c headfoot.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c hint.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c justify.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c texout.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c output.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c renumout.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c macro.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c htmlout.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c roffout.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c analyze.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c table.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c title.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c picture.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -c ftitle.c
cc -O2 -fno-strict-aliasing -pipe -DBSD -DKANJI -DPICTURE -DHTML -o plain2 plain2.o readfile.o miscutil.o section.o example.o list.o plaintxt.o spacing.o headfoot.o hint.o justify.o texout.o output.o renumout.o macro.o htmlout.o roffout.o analyze.o table.o title.o picture.o ftitle.o
vmbsd7#



美しい :D

だがしかし。




vmfbsd7# ./plain2 -tex plain2.h
Segmentation fault (core dumped)


……あれー?

次回: -fwritable-strings に込められた意味とは!?
(過去どこかのblogでまったく同じハマり方をしている記事を見かけています。)

2008年1月9日水曜日

今年の目標。



この右下にずらーっと現れるJavaScript読み込みへの嫌悪感を無くすこと!

よく分かってない仕組みだから嫌なのであって、積極的に使えば嫌悪感も薄れることだろう。きっと。

Java開発者のためのAjax実践開発入門』も買ったし。
私はJava開発者じゃないけど、面白い本ですねこれ。
この本を読んでLaTeX入門の構成を見直そうかと思うくらい。