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 だった、というわけですね。

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

0 件のコメント: