Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mendex] makeindex と挙動が異なる #173

Closed
h20y6m opened this issue Jan 29, 2025 · 5 comments
Closed

[mendex] makeindex と挙動が異なる #173

h20y6m opened this issue Jan 29, 2025 · 5 comments
Labels

Comments

@h20y6m
Copy link
Collaborator

h20y6m commented Jan 29, 2025

https://okumuralab.org/tex/mod/forum/discuss.php?d=3888 参照

とりあえず以下のような挙動の違いがあるようです。

heading_prefix 等のエスケープの挙動

  • makeindex では \t, \n 以外のエスケープは \ を取り除いて直後の文字をそのまま使う。

  • mendex では \\, \n, \t, \r, \" 以外のエスケープは「ゴミ」になる。
    「ゴミ」が NUL 文字だとそこで文字列が終端する。

以下のソースコードの部分で上記以外のエスケープが考慮されていないようです。

else if (buff1[i]=='\\') {
i++;
if (buff1[i]=='\\') buff2[j]='\\';
else if (buff1[i]=='n') buff2[j]='\n';
else if (buff1[i]=='t') buff2[j]='\t';
else if (buff1[i]=='r') buff2[j]='\r';
else if (buff1[i]=='\"') buff2[j]='\"';
}

これはバグとして扱ってよいと思います。

encap string の escape と quote の挙動

  • makeindex では | 以降の encap string でも escape と quote が有効。

  • mendex では encap string では escape や quote が考慮されない。

encap string を取得する getestr 関数で escape や quote が考慮されていないようです。

static int getestr(char *buff, char *estr)

これに関しては「修正」すると以前に動作していたものが動作しなくなる可能性はありそうです。

@h20y6m h20y6m added the bug label Jan 29, 2025
h20y6m added a commit to h20y6m/tex-jp-build that referenced this issue Jan 29, 2025
@t-tk
Copy link
Collaborator

t-tk commented Feb 2, 2025

b45b2d7 の hare はtypoかもしれません。
upmendex は mendex で修正頂いた方法をそのまま使わせてもらおうと思います。

h20y6m added a commit to h20y6m/tex-jp-build that referenced this issue Feb 3, 2025
h20y6m added a commit to h20y6m/tex-jp-build that referenced this issue Feb 4, 2025
h20y6m added a commit to h20y6m/tex-jp-build that referenced this issue Feb 4, 2025
@h20y6m
Copy link
Collaborator Author

h20y6m commented Feb 4, 2025

b45b2d7 の hare はtypoかもしれません。

typo ですね……

heading_prefix 等のエスケープの挙動

c20cad0 でうまく動いていると思います。

escape と quote の挙動

makeindex のエスケープの挙動が理解しきれていませが、
とりあえず 5bcb98f で元のForumの例やZRさんの記事にある例で makeindex と同じ出力が得られるようになった気がします。

@t-tk
Copy link
Collaborator

t-tk commented Feb 8, 2025

mendex.test にテストを追加してみました。 4b1050f
私は良いように思っていますが、意図通りの動作でしょうか。もしそうならTeX Live svnへコミットしてよいと思います。
makeindex でも同様の動作であることは確認しました。
makeindex の方も、TeX Live svn へ同様のテストをコミットしようと思っています。
upmendex もご提案のパッチを適用してみました。 18fdb36, bab4174

@h20y6m
Copy link
Collaborator Author

h20y6m commented Feb 9, 2025

ありがとうございます。意図通りの動作になっていると思います。

r73805 でコミットしました。


まだ makeindex と挙動が異なる部分がありますが、実用ではなさそうなパターンなのと、修正が大変そうなのでいったん保留にします。

挙動の異なる例: \index{right brace {@\string}}
makeindex: \item \string}, 1
(up)mendex: \item right brace {@\string}, 1

t-tk added a commit that referenced this issue Feb 9, 2025
t-tk added a commit that referenced this issue Feb 9, 2025
t-tk added a commit that referenced this issue Feb 9, 2025
@t-tk
Copy link
Collaborator

t-tk commented Feb 10, 2025

upmendex も同様の更新を入れて TeX Live svn にコミットしました。r73836

makeindex との挙動の差異が見つかるということはときどき気付きますがあまり追究していません。
upmendex は ASCII社さんのmendexがEUC-JPベースだったのに手を入れ、フォークしてUnicode化 & ICU導入で作った物であり、ソフトウェアの骨格や欧文の動作は ASCII社さんの時代から基本的に変わっていません。
ASCII社さんの mendex は makeindex と大体互換でありつつ日本語に特化した部分を追加した仕様を満たしつつスクラッチから作る、というような設計思想だったそうなので、makeindex と細部で違いが生じるのは織り込み済みだったと思います。
upmendex は非英語ラテン文字の人たちが少しずつ使い始めているようなので makeindex からの移行組が違和感ない程度には互換性は欲しいと思っていますが、どの程度なら大丈夫なのか正直分からないでいます。
なにかご提案があれば、そのときはよろしくお願いします。

ここは閉じます。

@t-tk t-tk closed this as completed Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants