texinfo-4.7-j.diff Texinfo 4.7 (正式版) の日本語化パッチです。texindex のパッチは 次のヘッダに示す,森下 お代官様 MaNMOS さんのパッチを 4.7 対応にしただけのものです。SJIS の場合のバグと思った部分は 訂正しました。 なお、オリジナルは ftp://ftp.gnu.org/gnu/texinfo/texinfo-4.7.tar.gz であり、 CTAN にもあるはずです。 | From manmos@knowledge.co.jp (HideoMorisita) Wed Jul 14 12:46:05 1993 | From: manmos@knowledge.co.jp (Hideo "Sir MaNMOS" Morisita) | Newsgroups: fj.sources | Subject: Japanese extention for texindex | Date: 13 Jul 93 02:35:02 GMT | Followup-To: fj.sources.d | Distribution: fj | Organization: Knowledge. Co., Osaka, Japan | | | 森下 お代官様 MaNMOS@ナレッジです。 | | 以前、texinfoの日本語拡張がfjに流れましたが、それ用のtexindexは流れな | かったようですので、作ってみました。 | | texindex.c 1.45の拡張として作ってあります。(texindex.c 1.45は | texinfo-2.15 から texinfo-3.0まで同じものです) makeinfo と texinfo.tex の日本語化は私が適当に試したものです。 texinfo.tex は TeX, pdfTeX (0.13d 以下及び 0.14a 以上), に対応して おり,日本語化によって ASCII-pTeX, NTT-jTeX に対応しています。 makeinfo によって Info file を作成する場合,元来 EUC なら日本語化しない でも通るのですが,改行位置がおかしくなったりする場合があります。 SJIS の場合は日本語化が必須です。またこのバージョンの makeinfo は --html オプションにより,HTML も出力できるのですが,HTML 出力の場合には EUC の 場合も日本語化が必要です。 makeinfo のエラーチェックは非常に厳しいのでご注意下さい。エラーや warning があっても --force オプションを付けることによって大部分問題 の無い Info や HTML が出力されます。 Texinfo では特に @xref に於いて、 閉じブレース } の後にアスキーのピリオド '.' あるいはアスキーの コンマ ',' を置くことが強制されています。これが無いと warning が 出ます。この場合も --force オプションを付けて対処して下さい。 コンパイルオプション -DSJIS=1 で Shift JIS となり, -DEUC=1 で EUC となります。なお,インストールされる txi-ja.tex (よいかげんな ものですが) は EUC になっていますので,SJIS を選択される場合には あとで SJIS に変換して下さい。texi2dvi に関してはデフォルト TeX コマンドは ptex としています。 TEX 環境変数で変更できます。 makeinfo に関して、新井康司さんの指摘によると、@anchor{} の参照位置が GNU Emacs 20.4 以降ではバイト数でなくて、文字数で計算されるので狂うと いうことです。このパッチでは新井さんの修正をそのまま採用したつもり です。 --em20 オプションによって、バイト数ではなくて、文字数で計算するように なると思われます。--em20 オプションが無いときはバイト数で計算します。 方法: texinfo-4.7.tar.gz と texinfo-4.7-j.diff を同じディレクトリに おいて tar zxvf texinfo-4.7.tar.gz patch -p0 さん によって EUC-JP で実現されたものがオリジナルに付属していますが、この 日本語化パッチによって使用できなくなる可能性があります。(未チェック)。 上の例で --disable-nls なる configure のオプションは、国際化メッセージ をあきらめ、英語メッセージを選択するためのものです。多分このオプションが 必要と思われます。 [変更履歴] [2004/04/18] 最初のバージョン。 [2004/05/01] texi2dvi を pTeX 用に書き換え。 ------------------------------------------------------------------- ( 2004/05/01 A. Kakuto ) diff -Nur texinfo-4.7-orig/doc/Makefile.am texinfo-4.7/doc/Makefile.am --- texinfo-4.7-orig/doc/Makefile.am Sat Dec 06 10:31:15 2003 +++ texinfo-4.7/doc/Makefile.am Sat May 01 11:50:19 2004 @@ -21,7 +21,7 @@ MAKEINFO = ../makeinfo/makeinfo INSTALL_INFO = ../util/install-info -TXI_XLATE = txi-cs.tex txi-de.tex txi-en.tex txi-es.tex txi-fr.tex \ +TXI_XLATE = txi-ja.tex txi-cs.tex txi-de.tex txi-en.tex txi-es.tex txi-fr.tex \ txi-it.tex txi-nl.tex txi-no.tex txi-pl.tex txi-pt.tex txi-tr.tex # Include our texinfo.tex, not Automake's. diff -Nur texinfo-4.7-orig/doc/Makefile.in texinfo-4.7/doc/Makefile.in --- texinfo-4.7-orig/doc/Makefile.in Sat Apr 10 06:25:01 2004 +++ texinfo-4.7/doc/Makefile.in Sat May 01 11:50:19 2004 @@ -214,7 +214,7 @@ info.5 texinfo.5 INSTALL_INFO = ../util/install-info -TXI_XLATE = txi-cs.tex txi-de.tex txi-en.tex txi-es.tex txi-fr.tex \ +TXI_XLATE = txi-ja.tex txi-cs.tex txi-de.tex txi-en.tex txi-es.tex txi-fr.tex \ txi-it.tex txi-nl.tex txi-no.tex txi-pl.tex txi-pt.tex txi-tr.tex diff -Nur texinfo-4.7-orig/doc/texinfo.tex texinfo-4.7/doc/texinfo.tex --- texinfo-4.7-orig/doc/texinfo.tex Thu Apr 08 00:18:16 2004 +++ texinfo-4.7/doc/texinfo.tex Sat May 01 11:50:19 2004 @@ -67,7 +67,28 @@ \everyjob{\message{[Texinfo version \texinfoversion]}% \catcode`+=\active \catcode`\_=\active} +% (Aug. 17, 1999 --ak) +% Japanese support. (pTeX is a free Japanese TeX by ASCII corp., Japan, +% and jTeX is a free Japanese TeX by NTT corp. and T. Sakurai) +\newif\ifjaTeX +\newif\ifpTeX +\newif\ifjTeX +\ifx\kanjiskip\undefined\else + \pTeXtrue + \jaTeXtrue +\fi +\ifx\jkern\undefined\else + \jTeXtrue + \jaTeXtrue +\fi + \message{Basics,} +\ifpTeX +\message{ASCII-pTeX,} +\fi +\ifjTeX +\message{NTT-jTeX,} +\fi \chardef\other=12 % We never want plain's \outer definition of \+ in Texinfo. @@ -1403,16 +1424,34 @@ % \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} -\def\rm{\fam=0 \setfontstyle{rm}} + \def\it{\fam=\itfam \setfontstyle{it}} \def\sl{\fam=\slfam \setfontstyle{sl}} -\def\bf{\fam=\bffam \setfontstyle{bf}} \def\tt{\fam=\ttfam \setfontstyle{tt}} +% Japanese fonts. (--ak) +\ifjaTeX +\csname newfam\endcsname\mcfam +\csname newfam\endcsname\gtfam +\catcode`\@ =11 +\def\mc{\fam\mcfam \setfontstyle{min}} +\def\gt{\fam\gtfam \setfontstyle{gt}} +\def\rm{\mc \fam\z@ \setfontstyle{rm}} +\def\bf{\gt \fam\bffam \setfontstyle{bf}} +\catcode`\@ =12 +\else +\def\rm{\fam=0 \setfontstyle{rm}} +\def\bf{\fam=\bffam \setfontstyle{bf}} +\fi + % Texinfo sort of supports the sans serif font style, which plain TeX does not. % So we set up a \sf. \newfam\sffam +\ifjaTeX +\def\sf{\gt \fam\sffam \setfontstyle{sf}} +\else \def\sf{\fam=\sffam \setfontstyle{sf}} +\fi \let\li = \sf % Sometimes we call it \li, not \sf. % We don't need math for this font style. @@ -1474,10 +1513,26 @@ \mainmagstep=\magstep1 \setfont\textrm\rmshape{12}{1000} \setfont\texttt\ttshape{12}{1000} + \ifpTeX + \font\textmc=min10 scaled 1200 + \font\textgt=goth10 scaled 1200 + \fi + \ifjTeX + \jfont\textmc=dm12 + \jfont\textgt=dg12 + \fi \else \mainmagstep=\magstephalf \setfont\textrm\rmshape{10}{\mainmagstep} \setfont\texttt\ttshape{10}{\mainmagstep} + \ifpTeX + \font\textmc=min10 scaled \magstephalf + \font\textgt=goth10 scaled \magstephalf + \fi + \ifjTeX + \jfont\textmc=dm10 scaled \magstephalf + \jfont\textgt=dg10 scaled \magstephalf + \fi \fi \setfont\textbf\bfshape{10}{\mainmagstep} \setfont\textit\itshape{10}{\mainmagstep} @@ -1489,10 +1544,28 @@ \font\textsy=cmsy10 scaled \mainmagstep % A few fonts for @defun names and args. +\ifpTeX +\setfont\defbf\bfshape{10}{\magstep1} +\setfont\deftt\ttshape{10}{\magstep1} +\font\defmc=min10 scaled \magstep1 +\font\defgt=goth10 scaled \magstep1 +\setfont\defttsl\ttslshape{10}{\magstep1} +\def\df{\let\tentt=\deftt \let\tenmin=\defmc +\let\tengt=\defgt \let\tenbf=\defbf \let\tenttsl=\defttsl \bf} +\else\ifjTeX \setfont\defbf\bfshape{10}{\magstep1} \setfont\deftt\ttshape{10}{\magstep1} +\jfont\defmc=dm10 scaled \magstep1 +\jfont\defgt=dg10 scaled \magstep1 \setfont\defttsl\ttslshape{10}{\magstep1} -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} +\def\df{\let\tentt=\deftt \let\tenmin=\defmc +\let\tengt=\defgt\let\tenbf=\defbf \let\tenttsl=\defttsl \bf} +\else +\setfont\defbf\bxshape{10}{\magstep1} %was 1314 +\setfont\deftt\ttshape{10}{\magstep1} +\setfont\defttsl\ttslshape{10}{\magstep1} +\def\df{\let\tentt=\deftt \let\tenbf=\defbf \let\tenttsl=\defttsl \bf} +\fi\fi % Fonts for indices, footnotes, small examples (9pt). \setfont\smallrm\rmshape{9}{1000} @@ -1505,6 +1578,14 @@ \setfont\smallttsl\ttslshape{10}{900} \font\smalli=cmmi9 \font\smallsy=cmsy9 +\ifpTeX +\font\smallmc=min9 +\font\smallgt=goth9 +\fi +\ifjTeX +\jfont\smallmc=dm9 +\jfont\smallgt=dg9 +\fi % Fonts for small examples (8pt). \setfont\smallerrm\rmshape{8}{1000} @@ -1517,6 +1598,14 @@ \setfont\smallerttsl\ttslshape{10}{800} \font\smalleri=cmmi8 \font\smallersy=cmsy8 +\ifpTeX +\font\smallermc=min8 +\font\smallergt=goth8 +\fi +\ifjTeX +\jfont\smallermc=dm8 +\jfont\smallergt=dg8 +\fi % Fonts for title page (20.4pt): \setfont\titlerm\rmbshape{12}{\magstep3} @@ -1525,11 +1614,22 @@ \setfont\titlett\ttbshape{12}{\magstep3} \setfont\titlettsl\ttslshape{10}{\magstep4} \setfont\titlesf\sfbshape{17}{\magstep1} +\ifpTeX +\font\titlemc=min10 scaled \magstep4 +\font\titlegt=goth10 scaled \magstep4 +\fi +\ifjTeX +\jfont\titlemc=dm10 scaled \magstep4 +\jfont\titlegt=dg10 scaled \magstep4 +\fi \let\titlebf=\titlerm \setfont\titlesc\scbshape{10}{\magstep4} \font\titlei=cmmi12 scaled \magstep3 \font\titlesy=cmsy10 scaled \magstep4 \def\authorrm{\secrm} +\ifjaTeX +\def\authormc{\secmc} +\fi \def\authortt{\sectt} % Chapter (and unnumbered) fonts (17.28pt). @@ -1539,6 +1639,14 @@ \setfont\chaptt\ttbshape{12}{\magstep2} \setfont\chapttsl\ttslshape{10}{\magstep3} \setfont\chapsf\sfbshape{17}{1000} +\ifpTeX +\font\chapmc=min10 scaled \magstep3 +\font\chapgt=goth10 scaled \magstep3 +\fi +\ifjTeX +\jfont\chapmc=dm10 scaled \magstep3 +\jfont\chapgt=dg10 scaled \magstep3 +\fi \let\chapbf=\chaprm \setfont\chapsc\scbshape{10}{\magstep3} \font\chapi=cmmi12 scaled \magstep2 @@ -1551,6 +1659,14 @@ \setfont\sectt\ttbshape{12}{\magstep1} \setfont\secttsl\ttslshape{10}{\magstep2} \setfont\secsf\sfbshape{12}{\magstep1} +\ifpTeX +\font\secmc=min10 scaled \magstep2 +\font\secgt=goth10 scaled \magstep2 +\fi +\ifjTeX +\jfont\secmc=dm10 scaled \magstep2 +\jfont\secgt=dg10 scaled \magstep2 +\fi \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep2} \font\seci=cmmi12 scaled \magstep1 @@ -1563,6 +1679,14 @@ \setfont\ssectt\ttbshape{12}{\magstephalf} \setfont\ssecttsl\ttslshape{10}{1315} \setfont\ssecsf\sfbshape{12}{\magstephalf} +\ifpTeX +\font\ssecmc=min10 scaled 1315 +\font\ssecgt=goth10 scaled 1315 +\fi +\ifjTeX +\jfont\ssecmc=dm10 scaled 1315 +\jfont\ssecgt=dg10 scaled 1315 +\fi \let\ssecbf\ssecrm \setfont\ssecsc\scbshape{10}{1315} \font\sseci=cmmi12 scaled \magstephalf @@ -1579,6 +1703,14 @@ \setfont\reducedttsl\ttslshape{10}{1000} \font\reducedi=cmmi10 \font\reducedsy=cmsy10 +\ifpTeX +\font\reducedmc=min10 +\font\reducedgt=goth10 +\fi +\ifjTeX +\jfont\reducedmc=dm10 +\jfont\reducedgt=dg10 +\fi % In order for the font changes to affect most math symbols and letters, % we have to define the \textfont of the standard families. Since @@ -1586,11 +1718,20 @@ % in the main text, we don't bother to reset \scriptfont and % \scriptscriptfont (which would also require loading a lot more fonts). % +\ifpTeX +\def\resetmathfonts{% + \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy + \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf + \textfont\ttfam=\tentt \textfont\sffam=\tensf + \textfont\mcfam = \tenmin \textfont\gtfam = \tengt +} +\else \def\resetmathfonts{% \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf \textfont\ttfam=\tentt \textfont\sffam=\tensf } +\fi % The font-changing commands redefine the meanings of \tenSTYLE, instead % of just \STYLE. We do this because \STYLE needs to also set the @@ -1603,13 +1744,35 @@ % % This all needs generalizing, badly. % +\ifjaTeX \def\textfonts{% \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl + \let\tenmin=\textmc \let\tengt=\textgt \def\lsize{reduced}\def\lllsize{smaller}% \resetmathfonts \setleading{\textleading}} +\else +\def\textfonts{% + \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl + \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc + \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy + \let\tenttsl=\textttsl + \def\lsize{reduced}\def\lllsize{smaller}% + \resetmathfonts \setleading{\textleading}} +\fi +\ifjaTeX +\def\titlefonts{% + \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl + \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc + \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy + \let\tenttsl=\titlettsl + \let\tenmin=\titlemc \let\tengt=\titlegt + \def\lsize{chap}\def\lllsize{subsec}% + \resetmathfonts \setleading{25pt}} +\def\titlefont#1{{\titlefonts\rm #1}} +\else \def\titlefonts{% \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc @@ -1618,26 +1781,71 @@ \def\lsize{chap}\def\lllsize{subsec}% \resetmathfonts \setleading{25pt}} \def\titlefont#1{{\titlefonts\rm #1}} +\fi +\ifjaTeX +\def\chapfonts{% + \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl + \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc + \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl + \let\tenmin=\chapmc \let\tengt=\chapgt + \def\lsize{sec}\def\lllsize{text}% + \resetmathfonts \setleading{19pt}} +\else \def\chapfonts{% \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl \def\lsize{sec}\def\lllsize{text}% \resetmathfonts \setleading{19pt}} +\fi +\ifjaTeX \def\secfonts{% \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl + \let\tenmin=\secmc \let\tengt=\secgt \def\lsize{subsec}\def\lllsize{reduced}% \resetmathfonts \setleading{16pt}} +\else +\def\secfonts{% + \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl + \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc + \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy + \let\tenttsl=\secttsl + \def\lsize{subsec}\def\lllsize{reduced}% + \resetmathfonts \setleading{16pt}} +\fi +\ifjaTeX \def\subsecfonts{% \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl + \let\tenmin=\ssecmc \let\tengt=\ssecgt \def\lsize{text}\def\lllsize{small}% \resetmathfonts \setleading{15pt}} +\else +\def\subsecfonts{% + \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl + \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc + \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy + \let\tenttsl=\ssecttsl + \def\lsize{text}\def\lllsize{small}% + \resetmathfonts \setleading{15pt}} +\fi +\ifjaTeX +\let\subsubsecfonts = \subsecfonts +\def\reducedfonts{% + \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl + \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc + \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy + \let\tenttsl=\reducedttsl + \let\tenmc=\reducedmc + \let\tengt=\reducedgt + \def\lsize{small}\def\lllsize{smaller}% + \resetmathfonts \setleading{10.5pt}} +\else \let\subsubsecfonts = \subsecfonts \def\reducedfonts{% \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl @@ -1646,6 +1854,17 @@ \let\tenttsl=\reducedttsl \def\lsize{small}\def\lllsize{smaller}% \resetmathfonts \setleading{10.5pt}} +\fi +\ifjaTeX +\def\smallfonts{% + \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl + \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc + \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy + \let\tenttsl=\smallttsl + \let\tenmin=\smallmc \let\tengt=\smallgt + \def\lsize{smaller}\def\lllsize{smaller}% + \resetmathfonts \setleading{10.5pt}} +\else \def\smallfonts{% \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc @@ -1653,13 +1872,25 @@ \let\tenttsl=\smallttsl \def\lsize{smaller}\def\lllsize{smaller}% \resetmathfonts \setleading{10.5pt}} +\fi +\ifjaTeX \def\smallerfonts{% \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy \let\tenttsl=\smallerttsl + \let\tenmin=\smallermc \let\tengt=\smallergt \def\lsize{smaller}\def\lllsize{smaller}% \resetmathfonts \setleading{9.5pt}} +\else +\def\smallerfonts{% + \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl + \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc + \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy + \let\tenttsl=\smallerttsl + \def\lsize{smaller}\def\lllsize{smaller}% + \resetmathfonts \setleading{9.5pt}} +\fi % Set the fonts to use with the @small... environments. \let\smallexamplefonts = \smallfonts @@ -1695,6 +1926,14 @@ \setfont\shortcontbf\bfshape{10}{\magstep1} % no cmb12 \setfont\shortcontsl\slshape{12}{1000} \setfont\shortconttt\ttshape{12}{1000} +\ifpTeX +\font\shortcontmc=min10 scaled \magstep1 +\font\shortcontgt=goth10 scaled \magstep1 +\fi +\ifjTeX +\jfont\shortcontmc=dm10 scaled \magstep1 +\jfont\shortcontgt=dg10 scaled \magstep1 +\fi %% Add scribe-like font environments, plus @l for inline lisp (usually sans %% serif) and @ii for TeX italic @@ -1946,13 +2185,11 @@ % be smaller yet, but lllsize is the best we can do for now. % Adapted from the plain.tex definition of \copyright. % +\font\onlytodefineregisteredsymbol=psyr at 7pt \def\registeredsymbol{% - $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% - \hfil\crcr\Orb}}% - }$% +$^{\hbox{\onlytodefineregisteredsymbol\char210\relax}}$% } - \message{page headings,} \newskip\titlepagetopglue \titlepagetopglue = 1.5in @@ -3492,7 +3729,11 @@ \def\initial#1{{% % Some minor font changes for the special characters. +\ifjaTeX + \let\tentt=\sectt \let\tt=\sectt \let\sf=\gt\sectt +\else \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt +\fi % % Remove any glue we may have, we'll be inserting our own. \removelastskip @@ -3789,7 +4030,7 @@ % We do the following ugly conditional instead of the above simple % construct for the sake of pdftex, which needs the actual % letter in the expansion, not just typeset. -% +% \def\appendixletter{% \ifnum\appendixno=`A A% \else\ifnum\appendixno=`B B% diff -Nur texinfo-4.7-orig/doc/txi-ja.tex texinfo-4.7/doc/txi-ja.tex --- texinfo-4.7-orig/doc/txi-ja.tex Thu Jan 01 09:00:00 1970 +++ texinfo-4.7/doc/txi-ja.tex Sat May 01 11:50:19 2004 @@ -0,0 +1,70 @@ +% txi-ja.tex -- adaptation to Japanese for texinfo.tex. +% This is read when a source document says @documentlanguage ja +% (which might happen after another @documentlanguage). +% $Id: txi-ja.tex,v 1.1 2003/05/14 $ +% +% Copyright (C) 1999 Free Software Foundation, Inc. +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2, or (at your option) +% any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +% +\gdef\putwordAppendix{付記} +\gdef\putwordChapter{Chapter} +\gdef\putwordfile{ファイル} +\gdef\putwordin{in} +\gdef\putwordIndexIsEmpty{(インデックスは空です)} +\gdef\putwordIndexNonexistent{(インデックスはありません)} +\gdef\putwordInfo{Info} +\gdef\putwordInstanceVariableof{Instance Variable of} +\gdef\putwordMethodon{Method on} +\gdef\putwordNoTitle{無題} +\gdef\putwordof{of} +\gdef\putwordon{on} +\gdef\putwordpage{頁} +\gdef\putwordsection{section} +\gdef\putwordSection{Section} +\gdef\putwordsee{see} +\gdef\putwordSee{See} +\gdef\putwordShortTOC{簡要} +\gdef\putwordTOC{目次} +% +\gdef\putwordMJan{1月} +\gdef\putwordMFeb{2月} +\gdef\putwordMMar{3月} +\gdef\putwordMApr{4月} +\gdef\putwordMMai{5月} +\gdef\putwordMJun{6月} +\gdef\putwordMJul{7月} +\gdef\putwordMAug{8月} +\gdef\putwordMSep{9月} +\gdef\putwordMOct{10月} +\gdef\putwordMNov{11月} +\gdef\putwordMDec{12月} +% +\gdef\putwordDefmac{マクロ} +\gdef\putwordDefspec{特殊フォーム} +\gdef\putwordDefvar{変数} +\gdef\putwordDefopt{ユーザオプション} +\gdef\putwordDeffunc{関数} +% +\hyphenation{mini-buf-fer mini-buf-fers eshell white-space} +% +\gdef\today{% + \number\year 年\space + \ifcase\month + \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr + \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug + \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec + \fi + \number\day 日} diff -Nur texinfo-4.7-orig/makeinfo/Makefile.am texinfo-4.7/makeinfo/Makefile.am --- texinfo-4.7-orig/makeinfo/Makefile.am Tue Mar 09 07:45:54 2004 +++ texinfo-4.7/makeinfo/Makefile.am Sat May 01 11:50:19 2004 @@ -21,7 +21,8 @@ files.c files.h float.c float.h footnote.c footnote.h \ html.c html.h index.c index.h insertion.c insertion.h lang.c lang.h \ macro.c macro.h makeinfo.c makeinfo.h multi.c multi.h node.c node.h \ - sectioning.c sectioning.h toc.c toc.h xml.c xml.h xref.c xref.h + sectioning.c sectioning.h toc.c toc.h xml.c xml.h xref.c xref.h \ + kanji.c kanji.h EXTRA_DIST = README diff -Nur texinfo-4.7-orig/makeinfo/Makefile.in texinfo-4.7/makeinfo/Makefile.in --- texinfo-4.7-orig/makeinfo/Makefile.in Sat Apr 10 06:25:02 2004 +++ texinfo-4.7/makeinfo/Makefile.in Sat May 01 11:50:19 2004 @@ -82,7 +82,7 @@ index.$(OBJEXT) insertion.$(OBJEXT) lang.$(OBJEXT) \ macro.$(OBJEXT) makeinfo.$(OBJEXT) multi.$(OBJEXT) \ node.$(OBJEXT) sectioning.$(OBJEXT) toc.$(OBJEXT) \ - xml.$(OBJEXT) xref.$(OBJEXT) + xml.$(OBJEXT) xref.$(OBJEXT) kanji.$(OBJEXT) makeinfo_OBJECTS = $(am_makeinfo_OBJECTS) makeinfo_LDADD = $(LDADD) am__DEPENDENCIES_1 = @@ -98,7 +98,7 @@ @AMDEP_TRUE@ ./$(DEPDIR)/makeinfo.Po ./$(DEPDIR)/multi.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/node.Po ./$(DEPDIR)/sectioning.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/toc.Po ./$(DEPDIR)/xml.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/xref.Po +@AMDEP_TRUE@ ./$(DEPDIR)/xref.Po ./$(DEPDIR)/kanji.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) @@ -234,7 +234,8 @@ files.c files.h float.c float.h footnote.c footnote.h \ html.c html.h index.c index.h insertion.c insertion.h lang.c lang.h \ macro.c macro.h makeinfo.c makeinfo.h multi.c multi.h node.c node.h \ - sectioning.c sectioning.h toc.c toc.h xml.c xml.h xref.c xref.h + sectioning.c sectioning.h toc.c toc.h xml.c xml.h xref.c xref.h \ + kanji.c kanji.h EXTRA_DIST = README SUBDIRS = tests @@ -321,6 +322,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/toc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xml.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xref.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kanji.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ diff -Nur texinfo-4.7-orig/makeinfo/cmds.c texinfo-4.7/makeinfo/cmds.c --- texinfo-4.7-orig/makeinfo/cmds.c Thu Apr 08 05:17:38 2004 +++ texinfo-4.7/makeinfo/cmds.c Sat May 01 11:50:19 2004 @@ -33,6 +33,18 @@ #include "toc.h" #include "xml.h" +#ifdef SJIS +#include "kanji.h" +#endif + +#ifdef EUC +#include "kanji.h" +#endif + +#ifdef WIN32 +#define index strchr +#endif + #ifdef TM_IN_SYS_TIME #include #else @@ -900,7 +912,17 @@ while (start_pos < end_pos) { unsigned char c = output_paragraph[start_pos]; +#ifdef KANJI + if(iskanji(c)) { + start_pos += 2; + continue; + } +#endif +#ifdef SJIS + if (strchr ("[](),", c) && !iskanji(output_paragraph[start_pos-1])) +#else if (strchr ("[](),", c)) +#endif warning (_("unlikely character %c in @var"), c); output_paragraph[start_pos] = coerce_to_upper (c); start_pos++; @@ -937,6 +959,12 @@ while (start_pos < end_pos) { unsigned char c = output_paragraph[start_pos]; +#ifdef KANJI + if(iskanji(c)) { + start_pos += 2; + continue; + } +#endif if (!isupper (c)) all_upper = 0; if (!html) diff -Nur texinfo-4.7-orig/makeinfo/defun.c texinfo-4.7/makeinfo/defun.c --- texinfo-4.7-orig/makeinfo/defun.c Tue Mar 02 17:17:44 2004 +++ texinfo-4.7/makeinfo/defun.c Sat May 01 11:50:19 2004 @@ -26,6 +26,13 @@ #include "cmds.h" #include "html.h" +#ifdef SJIS +#include "kanji.h" +#endif + +#ifdef WIN32 +#define const +#endif #define DEFUN_SELF_DELIMITING(c) \ ((c) == '(' || (c) == ')' || (c) == '[' || (c) == ']') @@ -86,6 +93,12 @@ *string_pointer = scan_string - 1; return 0; } +#ifdef SJIS + if(iskanji(c)) { + scan_string++; + c = (*scan_string++); + } +#endif if (c == '{' && !started_command) level++; @@ -134,6 +147,12 @@ while (1) { c = *scan_string++; +#ifdef SJIS + if(iskanji(c)) { + scan_string++; + c = *scan_string++; + } +#endif if ((c == 0) || (c == '{') || (whitespace (c))) { @@ -195,6 +214,12 @@ /* Do not back up if we're looking at a }; since the only valid }'s are those matched with {'s, we want to give an error. If we back up, we go into an infinite loop. */ +#ifdef SJIS + if(iskanji(c)) { + scan_string++; + c = *scan_string++; + } +#endif if (!c || whitespace (c) || DEFUN_SELF_DELIMITING (c) || c == '{') { diff -Nur texinfo-4.7-orig/makeinfo/files.c texinfo-4.7/makeinfo/files.c --- texinfo-4.7-orig/makeinfo/files.c Sun Feb 29 17:16:42 2004 +++ texinfo-4.7/makeinfo/files.c Sat May 01 11:50:19 2004 @@ -26,6 +26,10 @@ #include "makeinfo.h" #include "node.h" +#if defined (SJIS) || defined (EUC) +#include "kanji.h" +#endif + FSTACK *filestack = NULL; static int node_filename_stack_index = 0; @@ -56,7 +60,15 @@ i++; start = i; +#ifdef KANJI + while (string[i] && string[i] != path_sep_char) { + if(iskanji(string[i])) + i++; + i++; + } +#else while (string[i] && string[i] != path_sep_char) i++; +#endif *index = i; if (i == start) @@ -79,6 +91,11 @@ } } +#ifdef WIN32 +#undef IS_ABSOLUTE +# define IS_ABSOLUTE(n) (((n)[0]=='/') || ((n)[0]=='\\') ||((n)[0] && (n)[1] == ':')) +#endif + /* Return the full pathname for FILENAME by searching along PATH. When found, return the stat () info for FILENAME in FINFO. If PATH is NULL, only the current directory is searched. @@ -203,7 +220,11 @@ filename = fullpath; file_size = (long) fileinfo.st_size; +#ifdef WIN32 + file = open (filename, _O_RDONLY); +#else file = open (filename, O_RDONLY); +#endif if (file < 0) goto error_exit; @@ -366,7 +387,18 @@ char * filename_part (char *filename) { +#ifdef WIN32 + char *pp, *basename; + for(pp = filename; *pp; pp++) { + if(iskanji(*pp)) { + pp++; continue; + } + if(*pp == '\\') *pp = '/'; + } + basename = filename_non_directory (filename); +#else char *basename = filename_non_directory (filename); +#endif #ifdef REMOVE_OUTPUT_EXTENSIONS /* See if there is an extension to remove. If so, remove it. */ @@ -405,11 +437,22 @@ { int initial_character; char *result; +#ifdef WIN32 + char *akp; +#endif /* No filename given? */ if (!filename || !*filename) return xstrdup (""); +#ifdef WIN32 + for(akp = filename; *akp; akp++) { + if(iskanji(*akp)) { + akp++; continue; + } + if(*akp == '\\') *akp = '/'; + } +#endif /* Already absolute? */ if (IS_ABSOLUTE (filename) || (*filename == '.' && @@ -434,6 +477,14 @@ strcat (localdir, "/"); strcat (localdir, filename); +#ifdef WIN32 + for(akp=localdir; *akp; akp++) { + if(iskanji(*akp)) { + akp++; continue; + } + if(*akp == '\\') *akp='/'; + } +#endif result = xstrdup (localdir); free (localdir); } @@ -695,8 +746,11 @@ fs_error (temp->filename); return; } - +#ifdef WIN32 + output_stream = fopen (temp->filename, "wb"); +#else output_stream = fopen (temp->filename, "w"); +#endif if (!output_stream) { fs_error (temp->filename); diff -Nur texinfo-4.7-orig/makeinfo/footnote.c texinfo-4.7/makeinfo/footnote.c --- texinfo-4.7-orig/makeinfo/footnote.c Wed Apr 07 07:37:44 2004 +++ texinfo-4.7/makeinfo/footnote.c Sat May 01 11:50:19 2004 @@ -25,6 +25,10 @@ #include "xml.h" #include "xref.h" +#if defined (SJIS) || defined (EUC) +#include "kanji.h" +#endif + /* Nonzero means that the footnote style for this document was set on the command line, which overrides any other settings. */ int footnote_style_preset = 0; @@ -166,6 +170,12 @@ return; } +#ifdef KANJI + if(iskanji(input_text[loc])) { + loc +=2; + continue; + } +#endif if (input_text[loc] == '{') braces++; else if (input_text[loc] == '}') diff -Nur texinfo-4.7-orig/makeinfo/html.c texinfo-4.7/makeinfo/html.c --- texinfo-4.7-orig/makeinfo/html.c Sun Mar 21 07:17:10 2004 +++ texinfo-4.7/makeinfo/html.c Sat May 01 11:50:19 2004 @@ -27,6 +27,13 @@ #include "node.h" #include "sectioning.h" +#ifdef WIN32 +#define const +#endif + +#if defined (SJIS) || defined (EUC) +#include "kanji.h" +#endif /* Append CHAR to BUFFER, (re)allocating as necessary. We don't handle null characters. */ @@ -342,6 +349,13 @@ do { +#ifdef SJIS + if(iskanji(string[i])) { + newlen+=2; + i++; + goto labela; + } +#endif /* Find how much to allocate. */ switch (string[i]) { @@ -358,6 +372,9 @@ default: newlen++; } +#ifdef SJIS + labela: ; +#endif } while (string[i++]); @@ -367,6 +384,13 @@ i = 0; do { +#ifdef SJIS + if(iskanji(string[i])) { + *newstring++ = string[i++]; + *newstring++ = string[i]; + goto labelb; + } +#endif switch (string[i]) { case '"': @@ -389,6 +413,9 @@ newstring[0] = string[i]; newstring++; } +#ifdef SJIS + labelb: ; +#endif } while (string[i++]); free (string); @@ -595,6 +622,13 @@ for (; *name; name++) { +#ifdef KANJI + if(iskanji(*name)) { + add_char (*name++); + add_char (*name); + continue; + } +#endif if (cr_or_whitespace (*name)) add_char ('-'); else if (! URL_SAFE_CHAR (*name)) @@ -654,6 +688,15 @@ for (i = 0; i < len; i++) { +#ifdef KANJI + if(iskanji(oldname[i])) { + filename[i] = oldname[i]; + i++; + filename[i] = oldname[i]; + filename[i+1] = '\0'; + continue; + } +#endif if (cr_or_whitespace (oldname[i])) strcat (filename, "-"); else if (URL_SAFE_CHAR (oldname[i])) diff -Nur texinfo-4.7-orig/makeinfo/index.c texinfo-4.7/makeinfo/index.c --- texinfo-4.7-orig/makeinfo/index.c Thu Mar 25 09:24:07 2004 +++ texinfo-4.7/makeinfo/index.c Sat May 01 11:50:19 2004 @@ -564,6 +564,9 @@ } +#ifdef WIN32 +#include "mkind.h" +#endif /* Sort the index passed in INDEX, returning an array of pointers to elements. The array is terminated with a NULL pointer. */ diff -Nur texinfo-4.7-orig/makeinfo/insertion.c texinfo-4.7/makeinfo/insertion.c --- texinfo-4.7-orig/makeinfo/insertion.c Sat Apr 10 06:08:11 2004 +++ texinfo-4.7/makeinfo/insertion.c Sat May 01 11:50:19 2004 @@ -29,6 +29,14 @@ #include "multi.h" #include "xml.h" +#if defined (SJIS) +#include "kanji.h" +#endif + +#ifdef WIN32 +#define const +#endif + /* Must match list in insertion.h. */ static char *insertion_type_names[] = { @@ -2093,6 +2101,9 @@ cm_item (void) { char *rest_of_line, *item_func; +#ifdef SJIS + int alen; +#endif /* Can only hack "@item" while inside of an insertion. */ if (insertion_level) @@ -2194,9 +2205,17 @@ themselves, and we know it needs them. */ if (item_func && *item_func) { +#ifdef SJIS + alen = strlen(item_func); + if ((*item_func == COMMAND_PREFIX + && item_func[strlen (item_func) - 1] != '}' + && command_needs_braces (item_func + 1)) + || (alen>1 && iskanji(item_func[alen-2]))) +#else if (*item_func == COMMAND_PREFIX && item_func[strlen (item_func) - 1] != '}' && command_needs_braces (item_func + 1)) +#endif execute_string ("%s{}", item_func); else execute_string ("%s", item_func); diff -Nur texinfo-4.7-orig/makeinfo/kanji.c texinfo-4.7/makeinfo/kanji.c --- texinfo-4.7-orig/makeinfo/kanji.c Thu Jan 01 09:00:00 1970 +++ texinfo-4.7/makeinfo/kanji.c Sat May 01 11:50:19 2004 @@ -0,0 +1,82 @@ +/* Japanese support (A. Kakuto 1998/11/12) */ +#if defined (SJIS) || defined (EUC) +#ifndef KANJI +#define KANJI 1 +#endif +#endif + +#ifdef KANJI +/* First byte of SJIS or EUC character */ +int iskanji(int c) +{ + c &= 0xff; +#ifdef SJIS + return((c>=0x81 && c<=0x9f) || (c>=0xe0 && c<=0xfc)); +#else + return(c>=0xa1 && c<=0xfe); +#endif +} +int this_is_kanji = 0; +int kanji_space = 0; +#endif + +#ifdef KANJI +int iskanji2(int c) +{ + c &= 0xff; +#ifdef SJIS + return(c>=0x40 && c<=0xfc && c!=0x7f); +#else + return(c>=0xa1 && c<=0xfe); +#endif +} +#endif + +#ifdef KANJI +int gyoto(int a, int b) +{ + a &= 0xff; + b &= 0xff; +#ifdef SJIS + return (a == 0x81 && ((b >= 0x41 && b <= 0x49) || + (b == 0x4c) || + (b >= 0x52 && b <= 0x56) || + (b == 0x5e) || + (b == 0x5f) || + (b == 0x66) || + (b == 0x68) || + (b == 0x6a) || + (b == 0x6c) || + (b == 0x6e) || + (b == 0x70) || + (b == 0x72) || + (b == 0x74) || + (b == 0x76) || + (b == 0x78) || + (b == 0x7a) || + (b == 0x8c) || + (b == 0x8d)) + ); +#else + return (a == 0xa1 && ((b >= 0xa2 && b <= 0xaa) || + (b == 0xad) || + (b >= 0xb3 && b <= 0xb7) || + (b == 0xbf) || + (b == 0xc0) || + (b == 0xc7) || + (b == 0xc9) || + (b == 0xcb) || + (b == 0xcd) || + (b == 0xcf) || + (b == 0xd1) || + (b == 0xd3) || + (b == 0xd5) || + (b == 0xd7) || + (b == 0xd9) || + (b == 0xdb) || + (b == 0xec) || + (b == 0xed)) + ); +#endif +} +#endif diff -Nur texinfo-4.7-orig/makeinfo/kanji.h texinfo-4.7/makeinfo/kanji.h --- texinfo-4.7-orig/makeinfo/kanji.h Thu Jan 01 09:00:00 1970 +++ texinfo-4.7/makeinfo/kanji.h Sat May 01 11:50:19 2004 @@ -0,0 +1,11 @@ +#ifndef KANJI_H +#define KANJI_H +#ifndef KANJI +#define KANJI 1 +#endif +extern int iskanji(int c); +extern int iskanji2(int c); +extern int gyoto(int a, int b); +extern int this_is_kanji; +extern int kanji_space; +#endif diff -Nur texinfo-4.7-orig/makeinfo/macro.c texinfo-4.7/makeinfo/macro.c --- texinfo-4.7-orig/makeinfo/macro.c Sat Feb 14 17:12:52 2004 +++ texinfo-4.7/makeinfo/macro.c Sat May 01 11:50:19 2004 @@ -24,6 +24,10 @@ #include "makeinfo.h" #include "insertion.h" +#if defined (SJIS) +#include "kanji.h" +#endif + /* If non-NULL, this is an output stream to write the full macro expansion of the input text to. The result is another texinfo file, but missing @include, @infoinclude, @macro, and macro invocations. Instead, @@ -177,7 +181,14 @@ while ((character = curchar ())) { +#ifdef SJIS + if (iskanji(character)) { + input_text_offset +=2; + } + else if (character == '\\') +#else if (character == '\\') +#endif { input_text_offset += 2; escape_seen = 1; @@ -203,7 +214,14 @@ { int i; for (i = 0; word[i]; i++) +#ifdef SJIS + if ((word[i] == '\\') + && (i < 1 || (!iskanji(word[i-1]) || + (i > 1 && iskanji(word[i-2]) && + iskanji2(word[i-1]))))) +#else if (word[i] == '\\') +#endif memmove (word + i, word + i + 1, 1 + strlen (word + i + 1)); } @@ -308,7 +326,12 @@ while (body[i]) { /* Anything but a \ is easy. */ +#ifdef SJIS + if ((body[i] != '\\') || + (i>0 && iskanji(body[i-1]))) +#else if (body[i] != '\\') +#endif new_body[new_body_index++] = body[i++]; else { /* Snarf parameter name, check against named parameters. */ @@ -316,7 +339,12 @@ int param_start, len; param_start = ++i; +#ifdef SJIS + while ((body[i]) && ((body[i] != '\\') || + (i>0 && iskanji(body[i-1])))) +#else while (body[i] && body[i] != '\\') +#endif i++; len = i - param_start; @@ -477,8 +505,15 @@ for (i = start; i < input_text_length && input_text[i] != '{' && !cr_or_whitespace (input_text[i]); - i++) ; - + i++) +#ifdef SJIS + { + if(iskanji(input_text[i])) + i++; + } +#else + ; +#endif len = i - start; name = xmalloc (1 + len); memcpy (name, input_text + start, len); @@ -512,6 +547,12 @@ (character = input_text[i]); i++) { +#ifdef SJIS + if(iskanji(character)) { + i++; + continue; + } +#endif switch (character) { case '\n': @@ -533,6 +574,10 @@ && character != ',' && character != '}') { +#ifdef SJIS + if(iskanji(character)) + input_text_offset++; +#endif input_text_offset++; if (character == '\n') line_number++; @@ -857,8 +902,13 @@ { int i; +#ifdef SJIS + for (i = input_text_offset; i && (input_text[i] != COMMAND_PREFIX + || (i>0 && iskanji(input_text[i-1]))); i--); +#else for (i = input_text_offset; i && (input_text[i] != COMMAND_PREFIX); i--) ; +#endif maybe_write_itext (input_text, i); } diff -Nur texinfo-4.7-orig/makeinfo/makeinfo.c texinfo-4.7/makeinfo/makeinfo.c --- texinfo-4.7-orig/makeinfo/makeinfo.c Sat Apr 10 06:17:17 2004 +++ texinfo-4.7/makeinfo/makeinfo.c Sat May 01 11:50:19 2004 @@ -21,8 +21,21 @@ Original author of makeinfo: Brian Fox (bfox@ai.mit.edu). */ #include "system.h" +#ifdef WIN32 +#include +#include +#include +#include +#ifndef R_OK +#define R_OK 4 +#endif +#endif #include "getopt.h" +#if defined (SJIS) || defined (EUC) +#include "kanji.h" +#endif + #define COMPILING_MAKEINFO #include "makeinfo.h" #include "cmds.h" @@ -39,6 +52,10 @@ #include "toc.h" #include "xml.h" +#ifdef WIN32 +#define const +#endif + /* You can change some of the behavior of Makeinfo by changing the following defines: */ @@ -354,6 +371,7 @@ --no-validate suppress node cross-reference validation.\n\ --no-warn suppress warnings (but not errors).\n\ --reference-limit=NUM warn about at most NUM references (default %d).\n\ + --em20 make char ptr compatible with Emacs20 or later.\n\ -v, --verbose explain what is being done.\n\ --version display version information and exit.\n"), max_error_level, reference_warning_limit); @@ -457,6 +475,7 @@ makeinfo --html --no-headers foo.texi write html without node lines, menus\n\ makeinfo --number-sections foo.texi write Info with numbered sections\n\ makeinfo --no-split foo.texi write one Info file however big\n\ + makeinfo --em20 foo.texi write Info compatible with Emacs20\n\ "), stdout); puts (_("\n\ @@ -469,6 +488,9 @@ xexit (exit_value); } +#ifdef KANJI +int emacs20 = 0; +#endif struct option long_options[] = { { "commands-in-node-names", 0, &expensive_validation, 1 }, @@ -476,6 +498,9 @@ { "docbook", 0, 0, 'd' }, { "enable-encoding", 0, &enable_encoding, 1 }, { "error-limit", 1, 0, 'e' }, +#ifdef KANJI + { "em20", 0, &emacs20, 1 }, +#endif { "fill-column", 1, 0, 'f' }, { "footnote-style", 1, 0, 's' }, { "force", 0, &force, 1 }, @@ -523,6 +548,10 @@ int c, ind; int reading_from_stdin = 0; +#ifdef WIN32 + strcpy(argv[0], "makeinfo"); + setmode(fileno(stdout), _O_BINARY); +#endif #ifdef HAVE_SETLOCALE /* Do not use LC_ALL, because LC_NUMERIC screws up the scanf parsing of the argument to @multicolumn. */ @@ -628,7 +657,11 @@ { macro_expansion_filename = optarg; macro_expansion_output_stream +#ifdef WIN32 + = strcmp (optarg, "-") == 0 ? stdout : fopen (optarg, "wb"); +#else = strcmp (optarg, "-") == 0 ? stdout : fopen (optarg, "w"); +#endif if (!macro_expansion_output_stream) error (_("%s: could not open macro expansion output `%s'"), progname, optarg); @@ -868,7 +901,17 @@ for (i = 0; ((input_text_offset != input_text_length) && (character = curchar ()) && COMMAND_CHAR (character)); - i++, input_text_offset++); + i++, input_text_offset++) +#ifdef SJIS + { + if(iskanji(character)) { + i++; + input_text_offset++; + } + } +#else + ; +#endif result = xmalloc (i + 1); memcpy (result, &input_text[input_text_offset - i], i); result[i] = 0; @@ -896,14 +939,22 @@ do { +#ifdef KANJI + if (!cr_or_whitespace (*p) || iskanji(*p)) +#else if (!cr_or_whitespace (*p)) +#endif break; ++p; } while (*p); len = strlen (p); +#ifdef KANJI + while (len && cr_or_whitespace (p[len-1]) && !iskanji2(p[len-1])) +#else while (len && cr_or_whitespace (p[len-1])) +#endif --len; if (p != string) @@ -926,6 +977,16 @@ while (string[string_index]) { c = temp[temp_index++] = string[string_index++]; +#ifdef KANJI + if ((c == '\n' || c == ' ' || c == '\t') && + (string_index >2 && iskanji(string[string_index-3]) && + iskanji2(string[string_index-2])) && + (iskanji(string[string_index])) && + !gyoto(string[string_index-3], string[string_index-2])) { + temp_index--; + continue; + } +#endif if (c == ' ' || c == '\n' || c == '\t') { @@ -1180,6 +1241,12 @@ for (i = input_text_offset; i < input_text_length; i++) { +#ifdef SJIS + if(iskanji(input_text[i])) { + i++; + continue; + } +#endif if (i < input_text_length - 1 && input_text[i] == '@') { i++; /* skip commands like @, and @{ */ @@ -1242,6 +1309,9 @@ use there loses with the `init_paragraph' calls done by the multitable code; the tag indices get reset to zero. */ output_position = 0; +#ifdef KANJI + output_char_offset = 0; +#endif } /* Reverse the chain of structures in LIST. Output the new head @@ -1517,6 +1587,11 @@ for (i = 0; i < end_of_first_line; i++) { if ((input_text[i] == '\\') && +#ifdef SJIS + ((i == 0 || !iskanji(input_text[i-1])) || + (i>1 && iskanji(input_text[i-2]) && + iskanji2(input_text[i-1]))) && +#endif (strncmp (input_text + i + 1, "input", 5) == 0)) { input_text_offset = i; @@ -1600,8 +1675,12 @@ real_output_filename = expand_filename (output_filename, name); else real_output_filename = xstrdup (real_output_filename); +#ifdef WIN32 + output_stream = fopen (real_output_filename, "wb"); +#else output_stream = fopen (real_output_filename, "w"); +#endif } set_current_output_filename (real_output_filename); @@ -2057,6 +2136,18 @@ break; character = curchar (); +#ifdef KANJI + if(iskanji(character)){ + if(emacs20) jchar_num++; + add_char (character); + input_text_offset++; + character = curchar(); + this_is_kanji = 1; + add_char(character); + input_text_offset++; + continue; + } +#endif /* If only_macro_expansion, only handle macros and leave everything else intact. */ @@ -2501,6 +2592,9 @@ void add_char (int character) { +#ifdef KANJI + int ktmp, kk, temp; +#endif if (xml) { xml_add_char (character); @@ -2595,6 +2689,20 @@ { int len = get_char_len (character); int suppress_insert = 0; +#ifdef KANJI + if(!html && iskanji(character) && !kanji_space) { + if(output_paragraph_offset > 2 && + iskanji(output_paragraph[output_paragraph_offset-3]) && + iskanji2(output_paragraph[output_paragraph_offset-2]) && + output_paragraph[output_paragraph_offset-1] == ' ' && + !gyoto(output_paragraph[output_paragraph_offset-3], + output_paragraph[output_paragraph_offset-2])) { + output_paragraph_offset--; + /* output_column--; */ + } + } + kanji_space = 0; +#endif if ((character == ' ') && (last_char_was_newline)) { @@ -2639,13 +2747,85 @@ adjust_braces_following (0, 3); /* adjust for

*/ } } +#ifdef KANJI + output_column += len; + if(this_is_kanji) ktmp = output_column + 1; + else ktmp = output_column; + if (ktmp > fill_column) +#else output_column += len; if (output_column > fill_column) +#endif { +#ifdef KANJI + if(this_is_kanji) { + this_is_kanji = 0; + if (!html && filling_enabled) { + if(!gyoto(output_paragraph[output_paragraph_offset-1], + character)) { + kanji_space = 1; + kk = output_paragraph[output_paragraph_offset-1]; + insert(kk); + /* output_column++; */ + output_paragraph[output_paragraph_offset-2] = ' '; + } + } + } +#endif if (filling_enabled && !html) { +#ifdef KANJI + if(!html && !kanji_space) { + for(ktmp = output_paragraph_offset - 1; + ktmp > 0 && output_paragraph[ktmp] != '\n'; + ktmp--) { + if(!iskanji(output_paragraph[ktmp]) && + !(iskanji(output_paragraph[ktmp-1]) && + iskanji2(output_paragraph[ktmp])) && + COMMAND_CHAR(output_paragraph[ktmp]) && + output_paragraph[ktmp] != '\"' && + output_paragraph[ktmp] != '\'') { + if(ktmp > 1 && iskanji2(output_paragraph[ktmp-1]) && + iskanji(output_paragraph[ktmp-2])&& + output_paragraph[ktmp] != ')' && + output_paragraph[ktmp] != '.' && + output_paragraph[ktmp] != ',' && + output_paragraph[ktmp] != ']' && + output_paragraph[ktmp] != '!') { + kk=output_paragraph[output_paragraph_offset - 1]; + insert(kk); + /* output_column++; */ + for(kk=output_paragraph_offset - 3; + kk >= ktmp; kk--) + output_paragraph[kk+1] = output_paragraph[kk]; + output_paragraph[ktmp] = ' '; + break; + } + else if(ktmp < output_paragraph_offset - 1 && + iskanji(output_paragraph[ktmp+1]) && + output_paragraph[ktmp] != '(' && + output_paragraph[ktmp] != '[' && + output_paragraph[ktmp] != '`' && + (ktmp > output_paragraph_offset-3 || + !gyoto(output_paragraph[ktmp+1], + output_paragraph[ktmp+2]))) { + kk = output_paragraph[output_paragraph_offset - 1]; + insert(kk); + /* output_column++; */ + for(kk=output_paragraph_offset - 3; + kk > ktmp; kk--) + output_paragraph[kk+1] = output_paragraph[kk]; + output_paragraph[ktmp+1] = ' '; + break; + } + } + } + } + temp = output_paragraph_offset; +#else int temp = output_paragraph_offset; +#endif while (--temp > 0 && output_paragraph[temp] != '\n') { /* If we have found a space, we have the place to break @@ -2741,6 +2921,10 @@ if (!suppress_insert) { +#ifdef KANJI + if(this_is_kanji) + this_is_kanji = 0; +#endif insert (character); last_inserted_character = character; } @@ -2748,6 +2932,17 @@ line_already_broken = 0; } } +#ifdef KANJI + kk = output_paragraph_offset; + if(kk > 2 && iskanji(output_paragraph[kk-2]) && + iskanji2(output_paragraph[kk-1]) && + gyoto(output_paragraph[kk-2], output_paragraph[kk-1]) && + output_paragraph[kk-3] == '\n') { + output_paragraph[kk-3] = output_paragraph[kk-2]; + output_paragraph[kk-2] = output_paragraph[kk-1]; + output_paragraph[kk-1] = '\n'; + } +#endif } /* Add a character and store its position in meta_char_pos. */ @@ -2885,7 +3080,12 @@ if (!html && (output_paragraph[i] & meta_character_bit)) { int temp = UNMETA (output_paragraph[i]); +#ifdef SJIS + if ((temp == ' ') && + (i<1 || !iskanji(output_paragraph[i-1]))) +#else if (temp == ' ') +#endif output_paragraph[i] &= 0x7f; } } @@ -2893,6 +3093,12 @@ fwrite (output_paragraph, 1, output_paragraph_offset, output_stream); output_position += output_paragraph_offset; +#ifdef KANJI + if(emacs20) { + output_char_offset += output_paragraph_offset - jchar_num; + jchar_num = 0; + } +#endif output_paragraph_offset = 0; meta_char_pos = 0; } diff -Nur texinfo-4.7-orig/makeinfo/makeinfo.h texinfo-4.7/makeinfo/makeinfo.h --- texinfo-4.7-orig/makeinfo/makeinfo.h Thu Mar 11 17:15:17 2004 +++ texinfo-4.7/makeinfo/makeinfo.h Sat May 01 11:50:19 2004 @@ -63,6 +63,21 @@ DECLARE (int, output_line_number, 1); DECLARE (int, node_line_number, 0); +#ifdef SJIS +#ifndef KANJI +#define KANJI 1 +#endif +#endif +#ifdef EUC +#ifndef KANJI +#define KANJI 1 +#endif +#endif +#ifdef KANJI +DECLARE (int, output_char_offset, 0); +DECLARE (int, jchar_num, 0); +#endif + /* The offset into OUTPUT_PARAGRAPH where we have a meta character produced by a markup such as @code or @dfn. */ DECLARE (int, meta_char_pos, -1); diff -Nur texinfo-4.7-orig/makeinfo/multi.c texinfo-4.7/makeinfo/multi.c --- texinfo-4.7-orig/makeinfo/multi.c Mon Mar 01 17:20:30 2004 +++ texinfo-4.7/makeinfo/multi.c Sat May 01 11:50:19 2004 @@ -27,6 +27,10 @@ #include "multi.h" #include "xml.h" +#if defined (SJIS) +#include "kanji.h" +#endif + #define MAXCOLS 100 /* remove this limit later @@ */ @@ -107,6 +111,9 @@ do { +#ifdef SJIS + if(iskanji(**params)) (*params) += 2; +#endif if (**params == '{' && (*params == start || (*params)[-1] != '@')) brace_level++; else if (**params == '}' && (*params)[-1] != '@') @@ -205,6 +212,10 @@ while (*params) { while (whitespace (*params)) params++; +#ifdef SJIS + if(iskanji(*params)) + params += 2; +#endif if (*params == '@') { sscanf (params, "%200s", command); diff -Nur texinfo-4.7-orig/makeinfo/node.c texinfo-4.7/makeinfo/node.c --- texinfo-4.7-orig/makeinfo/node.c Mon Mar 01 17:20:30 2004 +++ texinfo-4.7/makeinfo/node.c Sat May 01 11:50:19 2004 @@ -39,6 +39,24 @@ int node_order = 0; int current_section = 0; int outstanding_node = 0; +#ifdef SJIS +#ifndef KANJI +#define KANJI 1 +#endif +#endif +#ifdef EUC +#ifndef KANJI +#define KANJI 1 +#endif +#endif +#ifdef KANJI +extern int emacs20; +#endif + +#ifdef WIN32 +#define const +#endif + /* Adding nodes, and making tags. */ @@ -99,7 +117,14 @@ { /* This reference is to a node. */ execute_string ("Node: %s", node->node); } +#ifdef KANJI + if(emacs20) + add_word_args ("\177%d\n", node->char_offset); + else + add_word_args ("\177%d\n", node->position); +#else add_word_args ("\177%d\n", node->position); +#endif } add_word ("\037\nEnd Tag Table\n"); @@ -114,7 +139,11 @@ void write_tag_table (char *filename) { +#ifdef WIN32 + output_stream = fopen (filename, "ab"); +#else output_stream = fopen (filename, "a"); +#endif if (!output_stream) { fs_error (filename); @@ -268,8 +297,13 @@ /* Remember NODE and associates. */ static void +#ifdef KANJI +remember_node (char *node, char *prev, char *next, char *up, + int position, int char_offset, int line_no, char *fname, int flags) +#else remember_node (char *node, char *prev, char *next, char *up, int position, int line_no, char *fname, int flags) +#endif { /* Check for existence of this tag already. */ if (validating) @@ -299,6 +333,9 @@ new->next = next; new->up = up; new->position = position; +#ifdef KANJI + new->char_offset = char_offset; +#endif new->line_no = line_no; new->filename = node_filename; new->touched = 0; @@ -842,8 +879,14 @@ if (!*next) { free (next); next = NULL; } if (!*prev) { free (prev); prev = NULL; } if (!*up) { free (up); up = NULL; } +#ifdef KANJI + remember_node (node, prev, next, up, new_node_pos, + output_char_offset, line_number, + fname_for_this_node, no_warn); +#else remember_node (node, prev, next, up, new_node_pos, line_number, fname_for_this_node, no_warn); +#endif outstanding_node = 1; } @@ -864,7 +907,11 @@ anchor, we complain and nuke that anchor's file. */ if (!tag) { +#ifdef WIN32 + output_stream = fopen (filename, "wb"); +#else output_stream = fopen (filename, "w"); +#endif html_output_head_p = 0; /* so that we generate HTML preamble */ html_output_head (); } @@ -882,7 +929,11 @@ anchor anymore. */ free (tag->html_fname); tag->html_fname = NULL; +#ifdef WIN32 + output_stream = fopen (filename, "wb"); +#else output_stream = fopen (filename, "w"); +#endif html_output_head_p = 0; /* so that we generate HTML preamble */ html_output_head (); } @@ -946,7 +997,7 @@ tem = expansion (next, 0); add_word ((char *) _("Next:")); add_word (" "); - + add_word ("position; +#ifdef KANJI + file_top_offset = tags->char_offset; +#endif limit = file_top + size; /* If the rest of this file is only one node, then @@ -1828,7 +1896,12 @@ root_filename, which_file); char *split_basename = filename_part (split_filename); +#ifdef WIN32 + fd = open (split_filename, + _O_BINARY|_O_WRONLY|_O_TRUNC|_O_CREAT, 0666); +#else fd = open (split_filename, O_WRONLY|O_TRUNC|O_CREAT, 0666); +#endif if (fd < 0 || write (fd, the_header, header_size) != header_size || write (fd, the_file + file_top, file_bot - file_top) @@ -1849,9 +1922,18 @@ sprintf (indirect_info, "\037\nIndirect:\n"); indirect_info += strlen (indirect_info); } +#ifdef KANJI + if(emacs20) + sprintf (indirect_info, "%s: %d\n", + split_basename, file_top_offset); + else + sprintf (indirect_info, "%s: %d\n", + split_basename, file_top); +#else sprintf (indirect_info, "%s: %d\n", split_basename, file_top); +#endif free (split_basename); free (split_filename); @@ -1866,7 +1948,11 @@ /* We have sucessfully created the subfiles. Now write out the original again. We must use `output_stream', or write_tag_table_indirect () won't know where to place the output. */ +#ifdef WIN32 + output_stream = fopen (filename, "wb"); +#else output_stream = fopen (filename, "w"); +#endif if (!output_stream) { perror (filename); diff -Nur texinfo-4.7-orig/makeinfo/node.h texinfo-4.7/makeinfo/node.h --- texinfo-4.7-orig/makeinfo/node.h Sun Feb 29 17:16:42 2004 +++ texinfo-4.7/makeinfo/node.h Sat May 01 11:50:19 2004 @@ -24,6 +24,16 @@ #include "xref.h" +#ifdef SJIS +#ifndef KANJI +#define KANJI 1 +#endif +#endif +#ifdef EUC +#ifndef KANJI +#define KANJI 1 +#endif +#endif /* The various references that we know about. */ /* What we remember for each node. */ typedef struct tentry @@ -34,6 +44,9 @@ char *next; /* Name of "Next:" for this node. */ char *up; /* Name of "Up:" for this node. */ int position; /* Output file position of this node. */ +#ifdef KANJI + int char_offset; +#endif int line_no; /* Defining line in source file. */ char *filename; /* The file that this node was found in. */ int touched; /* Nonzero means this node has been referenced. */ diff -Nur texinfo-4.7-orig/makeinfo/toc.c texinfo-4.7/makeinfo/toc.c --- texinfo-4.7-orig/makeinfo/toc.c Thu Mar 11 17:15:17 2004 +++ texinfo-4.7/makeinfo/toc.c Sat May 01 11:50:19 2004 @@ -32,6 +32,10 @@ #include "toc.h" #include "xml.h" +#if defined (SJIS) || defined (EUC) +#include "kanji.h" +#endif + /* array of toc entries */ static TOC_ENTRY_ELT **toc_entry_alist = NULL; @@ -91,6 +95,13 @@ { for (; *s; s++) { +#ifdef KANJI + if(iskanji(*s)) { + *d++ = *s++; + *d++ = *s; + continue; + } +#endif if (cr_or_whitespace (*s)) *d++ = '-'; else if (! URL_SAFE_CHAR (*s)) diff -Nur texinfo-4.7-orig/makeinfo/xml.c texinfo-4.7/makeinfo/xml.c --- texinfo-4.7-orig/makeinfo/xml.c Tue Mar 02 17:17:44 2004 +++ texinfo-4.7/makeinfo/xml.c Sat May 01 11:50:19 2004 @@ -30,6 +30,10 @@ #include "xml.h" +#if defined (SJIS) || defined (EUC) +#include "kanji.h" +#endif + /* Options */ int xml_index_divisions = 1; @@ -556,6 +560,12 @@ { /* Check if a character is allowed in ID attributes. This list differs slightly from XML specs that it doesn't contain underscores. See http://xml.coverpages.org/sgmlsyn/sgmlsyn.htm, ``9.3 Name'' */ +#ifdef KANJI + if(iskanji(*p) && iskanji2(*(p+1))) { + p++; p++; + continue; + } +#endif if (!strchr ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.", *p)) *p = '-'; p++; @@ -690,9 +700,8 @@ insert ('\n'); for (i = 0; i < element_stack_index * xml_indentation_increment; i++) insert (' '); - } + } } - void xml_start_para (void) { @@ -924,7 +933,11 @@ if (format) { +#ifdef KANJI + char temp_string[8192]; +#else char temp_string[2000]; /* xx no fixed limits */ +#endif #ifdef VA_SPRINTF va_list ap; #endif @@ -1228,6 +1241,18 @@ && cr_or_whitespace(xml_last_character)) return; +#ifdef SJIS + if(iskanji(xml_last_character)) { + insert(character); + xml_last_character = character; + return; + } + if(iskanji(character)) { + insert(character); + xml_last_character = character; + return; + } +#endif if (character == '\n' && !xml_in_para && !inhibit_paragraph_indentation) return; diff -Nur texinfo-4.7-orig/util/install-info.c texinfo-4.7/util/install-info.c --- texinfo-4.7-orig/util/install-info.c Mon Mar 29 21:44:23 2004 +++ texinfo-4.7/util/install-info.c Sat May 01 11:50:19 2004 @@ -21,6 +21,18 @@ #include "system.h" #include +#ifdef WIN32 +#include +#include +#define const +int +iskanji(int c) +{ + c &= 0xff; + return((c>=0x81 && c<=0x9f) || (c>=0xe0 && c<=0xfc)); +} +#endif + static char *progname = "install-info"; struct spec_entry; @@ -392,7 +404,7 @@ item_basename++; /* have /, move past it */ /* First, ITEM must actually match NAME (usually it won't). */ - ret = strncasecmp (item_basename, name, name_len) == 0; + ret = strncasecmp (item, name, name_len) == 0; if (ret) { /* Then, `foobar' doesn't match `foo', so be sure we've got all of @@ -482,7 +494,11 @@ FILE *f; char *readerr = strerror (errno); close (desc); +#ifdef WIN32 + f = fopen (dirfile, "wb"); +#else f = fopen (dirfile, "w"); +#endif if (f) { fprintf (f, _("This is the file .../info/dir, which contains the\n\ @@ -632,7 +648,11 @@ char *command = concat (*compression_program," -cd <", *opened_filename); if (fclose (f) < 0) pfatal_with_name (*opened_filename); +#ifdef WIN32 + f = _popen (command, "r"); +#else f = popen (command, "r"); +#endif if (f) *is_pipe = 1; else @@ -701,7 +721,11 @@ by popen is simulated by a temporary file which only gets removed inside pclose. */ if (pipe_p) +#ifdef WIN32 + _pclose (f); +#else pclose (f); +#endif else fclose (f); @@ -714,6 +738,10 @@ null, pipe to it to create DIRFILE. Thus if we read dir.gz on input, we'll write dir.gz on output. */ +#ifdef WIN32 +#include "mkind.h" +#endif + static void output_dirfile (char *dirfile, int dir_nlines, struct line_data *dir_lines, int n_entries_to_add, struct spec_entry *entries_to_add, @@ -725,10 +753,18 @@ if (compression_program) { char *command = concat (compression_program, ">", dirfile); +#ifdef WIN32 + output = _popen (command, "wb"); +#else output = popen (command, "w"); +#endif } else +#ifdef WIN32 + output = fopen (dirfile, "wb"); +#else output = fopen (dirfile, "w"); +#endif if (!output) { @@ -838,7 +874,11 @@ On those systems, the compressor actually gets run inside pclose, so we must call pclose. */ if (compression_program) +#ifdef WIN32 + _pclose (output); +#else pclose (output); +#endif else fclose (output); } @@ -1159,6 +1199,11 @@ int i; +#ifdef WIN32 + strcpy(argv[0], "install-info"); + setmode(fileno(stdout), _O_BINARY); +#endif + #ifdef HAVE_SETLOCALE /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); @@ -1504,6 +1549,7 @@ *nlinesp = filled; return lines; } + /* This is the comparison function for qsort for a vector of pointers to struct spec_section. (Have to use const void * as the parameter type diff -Nur texinfo-4.7-orig/util/texi2dvi texinfo-4.7/util/texi2dvi --- texinfo-4.7-orig/util/texi2dvi Sat Apr 10 06:22:49 2004 +++ texinfo-4.7/util/texi2dvi Sat May 01 11:59:23 2004 @@ -230,8 +230,8 @@ # We can't do much without tex. # -if findprog ${TEX:-tex}; then :; else cat < +#ifdef WIN32 +#include +#include +#define const +#endif + static char *program_name = "texindex"; #if defined (emacs) @@ -37,7 +43,9 @@ #define memset(ptr, ignore, count) bzero (ptr, count) #endif +#ifndef WIN32 char *mktemp (char *); +#endif #if !defined (SEEK_SET) # define SEEK_SET 0 @@ -154,6 +162,10 @@ { int i; +#ifdef WIN32 + strcpy(argv[0], "texindex"); + setmode(fileno(stdout), _O_BINARY); +#endif tempcount = 0; last_deleted_tempcount = 0; @@ -307,6 +319,9 @@ int arg_index = 1; char **ip; char **op; +#ifdef WIN32 + char *pp; +#endif /* Store default values into parameter variables. */ @@ -319,6 +334,14 @@ tempdir = DEFAULT_TMPDIR; else tempdir = concat (tempdir, "/"); +#ifdef WIN32 + for(pp=tempdir; *pp; pp++) { + if(iskanji(*pp)) { + pp++; continue; + } + if(*pp=='\\') *pp='/'; + } +#endif keep_tempfiles = 0; @@ -637,6 +660,12 @@ while (bracelevel) { c = *p++; +#ifdef SJIS + if ( iskanji(c)) { + p++; + continue; + } +#endif if (c == '{') bracelevel++; if (c == '}') @@ -679,6 +708,12 @@ while (bracelevel) { c = *p++; +#ifdef SJIS + if ( iskanji(c)) { + p++; + continue; + } +#endif if (c == '{') bracelevel++; if (c == '}') @@ -705,8 +740,388 @@ /* Vector used to translate characters for comparison. This is how we make all alphanumerics follow all else, and ignore case in the first sorting. */ +/* int char_order[256]; +*/ +int char_order[0x10000]; /* japanese */ + +#ifdef EUC +#define KANJI +#endif + +#ifdef SJIS +#define KANJI +#endif + +#ifdef KANJI + +#ifndef EUC +# ifndef SJIS +# define EUC +# endif +#else +# ifdef SJIS +# error +# endif +#endif + +#ifdef EUC +#define JIS_NUM_0 0xa3b0 +#define JIS_NUM_9 (JIS_NUM_0 + '9'- '0') +#define JIS_ALPH_A 0xa3c1 +#define JIS_ALPH_Z (JIS_ALPH_A + 'Z'-'A') +#define JIS_ALPH_a 0xa3e1 +#define JIS_HIRA_SMALL_A 0xa4a1 +#define JIS_HIRA_NN 0xa4f3 +#define JIS_KATA_SMALL_A 0xa5a1 +#define JIS_KATA_SMALL_KE 0xa5f6 +#define JIS_HIRA_U 0xa4a6 +#define JIS_KATA_U 0xa5a6 +#define JIS_KATA_VU 0xa5f4 + +#define JIS_KATA_UPPER 0xa5 +#define JIS_HIRA_UPPER 0xa4 + +#define JIS_HIRA_A 0xa4a2 +#define JIS_KATA_A 0xa5a2 + +#define JIS_DAKUTEN 0xa1ab +#define JIS_HANDAKUTEN 0xa1ac +#define JIS_CHOUON 0xa2ac + +int kana[] = { +/* . [ ] , . wo a */ + 0xa1a1, 0xa1a3, 0xa1d6, 0xa1d7, 0xa1a2, 0xa1a6, 0xa5f2, 0xa5a1, +/* i u e o ya yu yo tsu */ + 0xa5a3, 0xa5a5, 0xa5a7, 0xa5a9, 0xa5e3, 0xa5e5, 0xa5e7, 0xa5c3, +/* - a i u e o ka ki */ + 0xa1bc, 0xa5a2, 0xa5a4, 0xa5a6, 0xa5a8, 0xa5aa, 0xa5ab, 0xa5ad, +/* ku ke ko sa si su se so */ + 0xa5af, 0xa5b1, 0xa5b3, 0xa5b5, 0xa5b7, 0xa5b9, 0xa5bb, 0xa5bd, +/* ta ti tu te to na ni nu */ + 0xa5bf, 0xa5c1, 0xa5c4, 0xa5c6, 0xa5c8, 0xa5ca, 0xa5cb, 0xa5cc, +/* ne no ha hi hu he ho ma */ + 0xa5cd, 0xa5ce, 0xa5cf, 0xa5d2, 0xa5d5, 0xa5d8, 0xa5db, 0xa5de, +/* mi mu me mo ya yu yo ra */ + 0xa5df, 0xa5e0, 0xa5e1, 0xa5e2, 0xa5e4, 0xa5e6, 0xa5e8, 0xa5e9, +/* ri ru re ro wa nn "" maru */ + 0xa5ea, 0xa5eb, 0xa5ec, 0xa5ed, 0xa5ef, 0xa5f3, JIS_DAKUTEN,JIS_HANDAKUTEN +}; + +int daku[] = {0xa5ac, 0xa5ae, 0xa5b0, 0xa5b2, 0xa5b4, + 0xa5b6, 0xa5b8, 0xa5ba, 0xa5bc, 0xa5be, + 0xa5c0, 0xa5c2, 0xa5c5, 0xa5c7, 0xa5c9, + 0xa5d0, 0xa5d3, 0xa5d6, 0xa5d9, 0xa5dc}; +int handaku[] = {0xa5d1, 0xa5d4, 0xa5d7, 0xa5da, 0xa5dd}; +int dakuall[] = {0xa4ac, 0xa4ae, 0xa4b0, 0xa4b2, 0xa4b4, + 0xa4b6, 0xa4b8, 0xa4ba, 0xa4bc, 0xa4be, + 0xa4c0, 0xa4c2, 0xa4c5, 0xa4c7, 0xa4c9, + 0xa4d0, 0xa4d3, 0xa4d6, 0xa4d9, 0xa4dc, + 0xa5ac, 0xa5ae, 0xa5b0, 0xa5b2, 0xa5b4, + 0xa5b6, 0xa5b8, 0xa5ba, 0xa5bc, 0xa5be, + 0xa5c0, 0xa5c2, 0xa5c5, 0xa5c7, 0xa5c9, + 0xa5d0, 0xa5d3, 0xa5d6, 0xa5d9, 0xa5dc}; +int handakuall[] = {0xa4d1, 0xa4d4, 0xa4d7, 0xa4da, 0xa4dd, + 0xa5d1, 0xa5d4, 0xa5d7, 0xa5da, 0xa5dd}; +int +iskanji(int c) /* japanses extention */ +{ + if ( !(c & 0x80 )) return 0; + if ( c == 0x8e ) return 0; + return 1; +} + +int +is201kana(int c) /* japanses extention */ +{ + if ( c == 0x8e ) return 1; + else return 0; +} +#else /* SJIS */ +#define JIS_NUM_0 0x824f +#define JIS_NUM_9 (JIS_NUM_0 + '9'- '0') +#define JIS_ALPH_A 0x8260 +#define JIS_ALPH_Z (JIS_ALPH_A + 'Z'-'A') +#define JIS_ALPH_a 0x8281 +#define JIS_HIRA_SMALL_A 0x829f +#define JIS_HIRA_NN 0x82f1 +#define JIS_KATA_SMALL_A 0x8340 +#define JIS_KATA_SMALL_KE 0x8396 +#define JIS_HIRA_U 0x82a4 +#define JIS_KATA_U 0x8345 /* org 0x83a5 A.K. 1999 */ +#define JIS_KATA_VU 0x8394 + +#define JIS_KATA_UPPER 0x83 +#define JIS_HIRA_UPPER 0x82 + +#define JIS_HIRA_A 0x82a0 +#define JIS_KATA_A 0x8341 + +#define JIS_DAKUTEN 0x814a +#define JIS_HANDAKUTEN 0x814b +#define JIS_CHOUON 0x815b + +int kana[] = { +/* . [ ] , . wo a */ + 0x813f, 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x8392, 0x8340, +/* i u e o ya yu yo tsu */ + 0x8342, 0x8344, 0x8346, 0x8348, 0x8383, 0x8385, 0x8387, 0x8362, +/* - a i u e o ka ki */ + 0x815b, 0x8341, 0x8343, 0x8345, 0x8347, 0x8349, 0x834a, 0x834c, +/* ku ke ko sa si su se so */ + 0x834e, 0x8350, 0x8352, 0x8354, 0x8356, 0x8358, 0x835a, 0x835c, +/* ta ti tu te to na ni nu */ + 0x835e, 0x8360, 0x8363, 0x8365, 0x8367, 0x8369, 0x836a, 0x836b, +/* ne no ha hi hu he ho ma */ + 0x836c, 0x836d, 0x836e, 0x8371, 0x8374, 0x8377, 0x837a, 0x837d, +/* mi mu me mo ya yu yo ra */ + 0x837e, 0x8380, 0x8381, 0x8382, 0x8384, 0x8386, 0x8388, 0x8389, +/* ri ru re ro wa nn "" maru */ + 0x838a, 0x838b, 0x838c, 0x838d, 0x838f, 0x8393, JIS_DAKUTEN,JIS_HANDAKUTEN +}; + +int daku[] = {0x834b, 0x834d, 0x834f, 0x8351, 0x8353, + 0x8355, 0x8357, 0x8359, 0x835b, 0x835d, + 0x835f, 0x8361, 0x8364, 0x8366, 0x8367, + 0x836f, 0x8372, 0x8375, 0x8378, 0x837b}; + +int handaku[] = {0x8370, 0x8373, 0x8376, 0x8379, 0x837c}; + +int dakuall[] = {0x82aa, 0xa2ac, 0x82a3, 0x82b0, 0x82b2, + 0x82b4, 0x82b6, 0x82b8, 0x82ba, 0x82bc, + 0x82be, 0x82c0, 0x82c3, 0x82c5, 0x82c7, + 0x82ce, 0x82d1, 0x82d4, 0x82d7, 0x82da, + 0x834b, 0x834d, 0x834f, 0x8351, 0x8353, + 0x8355, 0x8357, 0x8359, 0x835b, 0x835d, + 0x835f, 0x8361, 0x8364, 0x8366, 0x8367, + 0x836f, 0x8372, 0x8375, 0x8378, 0x837b}; + +int handakuall[] = {0x82cf, 0x82d2, 0x82d5, 0x82d8, 0x82db, + 0x8370, 0x8373, 0x8376, 0x8379, 0x837c}; + +int +iskanji(int c) /* japanses extention */ +{ + c &= 0xff; + if (( c >= 0x81 && c <= 0x9f ) || + ( c >= 0xe0 && c <= 0xea )) return 1; + return 0; +} + +int +is201kana(int c) /* japanses extention */ +{ + if ( c >= 0xa0 && c <= 0xdf ) return 1; + else return 0; +} +#endif + +void +kana_char_order(void) /* japanese */ +{ + unsigned int c, i, j, cc; + + for ( c = 0x8000 ; c < 0x10000 ; c++ ) + char_order[c] = c; + + /* NUMERIC */ + for ( c = JIS_NUM_0 , i = '0' + 512; c <= JIS_NUM_9 ; i++,c++) + char_order[c] = i; + + /* ALPHABET */ + for ( c = JIS_ALPH_A , i = 'a' + 512; c <= JIS_ALPH_Z ; i++,c++) { + char_order[c] = i; + char_order[c+JIS_ALPH_a - JIS_ALPH_A] = i; + } + + /* KANA */ + for ( c = JIS_HIRA_SMALL_A ; c <= JIS_HIRA_NN ; c++ ) { + char_order[c] = c+512; + cc = c+JIS_KATA_SMALL_A-JIS_HIRA_SMALL_A; +#ifdef SJIS + if ( cc > 0x837e ) cc++; +#endif + char_order[cc] = c+512; + if (isdaku(c) ) { + char_order[c] = c+512-1; + char_order[cc] = c+512-1; + } else if (ishandaku(c) ) { + char_order[c] = c+512-2; + char_order[cc] = c+512-2; + } + } + for ( c = JIS_KATA_VU ; c <= JIS_KATA_SMALL_KE ; c++ ) { + char_order[c] = c+512; + if (c == JIS_KATA_VU ) { + char_order[c] = JIS_KATA_U + 512; + } + } +} + + +#ifdef EUC +#define KANA_BYTES 2 +#else +#define KANA_BYTES 2 +#endif + +static int +convert_htoz(unsigned char *str, int *ret) +{ + int c, c2; + int num = KANA_BYTES; + +#ifdef EUC + str++; +#endif + c = *str++; + if (!is201kana(*str)) { + if (c >= 0xa0 && c <= 0xdf) + *ret = kana[c - 0xa0]; + else *ret = 0x8e00 + c; + return num; + } +#ifdef EUC + str++; +#endif + num += KANA_BYTES; + + if ( (c2 = *str++) == 0xde) { + if (c >= 0xb6 && c <= 0xba) /* line-ga */ + c = daku[c - 0xb6]; + else if (c >= 0xbb && c <= 0xbf) /* line-za */ + c = daku[c - 0xbb+5]; + else if (c >= 0xc0 && c <= 0xc4) /* line-da */ + c = daku[c - 0xc0+10]; + else if (c >= 0xca && c <= 0xce) /* line-ba */ + c = daku[c - 0xca+15]; + else if ( c == 0xb3 ) /* vu */ + c = JIS_KATA_VU; + } else if (c2 == 0xdf) { + if (c >= 0xca && c <= 0xce) /* line-pa */ + c = handaku[c - 0xca]; + } else if ( c2 == 0xb1 ) { + if (c >= 0xa0 && c <= 0xdd) + *ret = kana[c - 0xa0]; + else *ret = 0x8e00 + c; + } + if ( c < 0x100 ) c += 0x8e00; + return num; +} + +int +isadddaku(int c) +{ + int i; + for ( i = 0 ; i < sizeof(dakuall) / sizeof(dakuall[1]) ; i++ ) + if ( dakuall[i]-1 == c ) return 1; + return 0; +} + +int +isaddhandaku(int c) +{ + int i; + for ( i = 0 ; i < sizeof(handakuall) / sizeof(handakuall[1]) ; i++ ) + if ( handakuall[i]-2 == c ) return 1; + return 0; +} + +int +isdaku(int c) +{ + int i; + for ( i = 0 ; i < sizeof(dakuall) / sizeof(dakuall[1]) ; i++ ) + if ( dakuall[i] == c ) return 1; + return 0; +} + +int +ishandaku(int c) +{ + int i; + for ( i = 0 ; i < sizeof(handakuall) / sizeof(handakuall[1]) ; i++ ) + if ( handakuall[i] == c ) return 1; + return 0; +} + +int mbchar(unsigned char *str, int *ret) +{ + int c = *str++; + int cc, ccc; + if ( !iskanji(c) && !is201kana(c)) { + *ret = c & 0xff; + return 1; + } + if ( iskanji (c) ) { + cc = ((c & 0xff) << 8) | ((*str++) & 0xff); + ccc = (((*str++ ) & 0xff) << 8 ) | ((*str++) & 0xff); + + if ( ccc == JIS_DAKUTEN ) { + if ( isadddaku(cc)) cc++; + else if ( cc == JIS_KATA_U || cc == JIS_HIRA_U ) + cc = JIS_KATA_VU; + *ret = cc; + return 4; + } else if ( ccc == JIS_HANDAKUTEN ) { + if ( isaddhandaku(cc)) cc+=2; + *ret = cc; + return 4; + } else if ( ccc == JIS_CHOUON ) { + *ret = cc; + return 4; + } else { + *ret = cc; + return 2; + } + } else if ( is201kana(c)) { + /* EUC */ + return convert_htoz(str-1,ret); + } +} + +void +xinitial(unsigned char *str, int c) +{ + int up; + if (isdaku(c)) c--; + else if (ishandaku(c)) c -= 2; + else if ( c == JIS_KATA_VU ) c = JIS_KATA_U; +#ifdef SJIS /* A.K. 1999 */ + if (((up= (c & 0xff00) >>8) == JIS_KATA_UPPER) && + (c & 0xff) < 0x97) +#else + if ((up= (c & 0xff00) >>8) == JIS_KATA_UPPER) +#endif + { /* katakana */ + c += JIS_HIRA_SMALL_A - JIS_KATA_SMALL_A; +#ifdef SJIS + if ( (c & 0xff) > 0xdd ) c--; /* A.K. 1999 */ +#endif + } + *str++ = (c >> 8 ) & 0xfff; + *str++ = c & 0xff; + *str= 0; +} + +int +make_initial(unsigned char *src, unsigned char *dst) +{ + int len; + int c; + + len = mbchar(src,&c); + if ( len == 1 ) { + dst[0] =toupper(c); + dst[1] = 0; + } else { + xinitial(dst,c); + len = 2; + } + return len; +} +#endif void init_char_order (void) { @@ -722,6 +1137,9 @@ char_order[i] = 512 + i; char_order[i + 'A' - 'a'] = 512 + i; } +#ifdef KANJI + kana_char_order(); /* japanese */ +#endif } /* Compare two fields (each specified as a start pointer and a character count) @@ -762,11 +1180,19 @@ if (p1 == e1) c1 = 0; else +#ifdef KANJI + p1 += mbchar(p1,&c1); /* japanese */ +#else c1 = *p1++; +#endif if (p2 == e2) c2 = 0; else +#ifdef KANJI + p2 += mbchar(p2,&c2); /* japanese */ +#else c2 = *p2++; +#endif if (char_order[c1] != char_order[c2]) return char_order[c1] - char_order[c2]; @@ -784,15 +1210,33 @@ if (p1 == e1) c1 = 0; else +#ifdef KANJI + p1 += mbchar(p1,&c1); /* japanese */ +#else c1 = *p1++; +#endif if (p2 == e2) c2 = 0; else - c2 = *p2++; - - if (c1 != c2) - /* Reverse sign here so upper case comes out last. */ - return c2 - c1; +#ifdef KANJI + p2 += mbchar(p2,&c2); /* japanese */ +#else + c2 = *p2++; +#endif +#ifdef KANJI + if ( iskanji(c1) || is201kana(c1)) { + if (c1 != c2) + /* Reverse sign here so upper case comes out last. */ + return c2 - c1; + } else { + if (c1 != c2) + return c1 - c2; + } +#else + if (c1 != c2) + /* Reverse sign here so upper case comes out last. */ + return c2 - c1; +#endif if (!c1) break; } @@ -883,7 +1327,11 @@ for (i = 0; i < ntemps; i++) { char *outname = maketempname (++tempcount); +#ifdef WIN32 + FILE *ostream = fopen (outname, "wb"); +#else FILE *ostream = fopen (outname, "w"); +#endif long tempsize = 0; if (!ostream) @@ -949,6 +1397,9 @@ assuming that is small enough to be done in-core, then indexify it and send the output to OUTFILE (or to stdout). */ +#ifdef WIN32 +#include "mkind.h" +#endif void sort_in_core (char *infile, int total, char *outfile) { @@ -1018,7 +1469,7 @@ Make a `struct lineinfo' for each line, which records the keyfield as well as the line, and sort them. */ - lineinfo = malloc ((nextline - linearray) * sizeof (struct lineinfo)); + lineinfo = (struct lineinfo *) malloc ((nextline - linearray) * sizeof (struct lineinfo)); if (lineinfo) { @@ -1048,7 +1499,11 @@ if (outfile) { +#ifdef WIN32 + ostream = fopen (outfile, "wb"); +#else ostream = fopen (outfile, "w"); +#endif if (!ostream) pfatal_with_name (outfile); } @@ -1109,7 +1564,7 @@ if (line == linearray + nlines) { char **old = linearray; - linearray = xrealloc (linearray, sizeof (char *) * (nlines *= 4)); + linearray = (char **) xrealloc (linearray, sizeof (char *) * (nlines *= 4)); line += linearray - old; } } @@ -1160,7 +1615,10 @@ /* When we need a string of length 1 for the value of lastinitial, store it here. */ +/* char lastinitial1[2]; +*/ +char lastinitial1[3]; /* japanese */ /* Initialize static storage for writing an index. */ @@ -1171,6 +1629,9 @@ lastinitial = lastinitial1; lastinitial1[0] = 0; lastinitial1[1] = 0; +#ifdef KANJI /* 2003 --ak */ + lastinitial1[2] = 0; +#endif lastinitiallength = 0; lastprimarylength = 100; lastprimary = (char *) xmalloc (lastprimarylength + 1); @@ -1191,7 +1652,10 @@ int nosecondary; int initiallength; char *initial; +/* char initial1[2]; +*/ + char initial1[3]; /* japanese */ register char *p; /* First, analyze the parts of the entry fed to us this time. */ @@ -1207,9 +1671,13 @@ else { initial = initial1; +#ifdef KANJI + initiallength = make_initial(p,initial1); /* japanese */ +#else initial1[0] = toupper (*p); initial1[1] = 0; initiallength = 1; +#endif } pagenumber = find_braced_pos (line, 1, 0, 0); @@ -1248,6 +1716,9 @@ { lastinitial = lastinitial1; *lastinitial1 = *initial1; +#ifdef KANJI /* 2003 --ak */ + *(lastinitial1+1) = *(initial1+1); +#endif } else { @@ -1441,7 +1912,11 @@ if (outfile) { +#ifdef WIN32 + ostream = fopen (outfile, "wb"); +#else ostream = fopen (outfile, "w"); +#endif } if (!ostream) pfatal_with_name (outfile);