summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/ptexdir
diff options
context:
space:
mode:
authorTakuji Tanaka <ttk@t-lab.opal.ne.jp>2022-06-12 08:18:23 +0000
committerTakuji Tanaka <ttk@t-lab.opal.ne.jp>2022-06-12 08:18:23 +0000
commitc6f5af13c21701cf913804b954c734f20b2748ce (patch)
tree0c86b4de09354f4ef0cdc1a5f28150328dbf8790 /Build/source/texk/web2c/ptexdir
parentab299733b38a3196a337723507b86a22a19589f3 (diff)
(e)(u)pTeX, (u)pBibTeX: support guessing input file encodings
git-svn-id: svn://tug.org/texlive/trunk@63557 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/ptexdir')
-rw-r--r--Build/source/texk/web2c/ptexdir/ChangeLog8
-rw-r--r--Build/source/texk/web2c/ptexdir/am/ptex.am8
-rw-r--r--Build/source/texk/web2c/ptexdir/kanji.c2
-rw-r--r--Build/source/texk/web2c/ptexdir/kanji.h3
-rw-r--r--Build/source/texk/web2c/ptexdir/pbibtex.ch18
-rwxr-xr-xBuild/source/texk/web2c/ptexdir/pbibtex.test37
6 files changed, 66 insertions, 10 deletions
diff --git a/Build/source/texk/web2c/ptexdir/ChangeLog b/Build/source/texk/web2c/ptexdir/ChangeLog
index 8d32404f757..0d94e1eb225 100644
--- a/Build/source/texk/web2c/ptexdir/ChangeLog
+++ b/Build/source/texk/web2c/ptexdir/ChangeLog
@@ -1,3 +1,11 @@
+2022-06-12 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
+
+ * kanji.[ch], pbibtex.ch:
+ Support guessing input file encodings.
+ https://github.com/texjporg/tex-jp-build/issues/142
+ * tests/pbibtex.test, am/ptex.am:
+ Add tests for guess encodings & pBibTeX.
+
2022-05-15 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
* pbibtex.ch, ptex.defines:
diff --git a/Build/source/texk/web2c/ptexdir/am/ptex.am b/Build/source/texk/web2c/ptexdir/am/ptex.am
index 4ab8c3bb486..a96e3dfa971 100644
--- a/Build/source/texk/web2c/ptexdir/am/ptex.am
+++ b/Build/source/texk/web2c/ptexdir/am/ptex.am
@@ -211,7 +211,13 @@ endif PWEB
EXTRA_DIST += ptexdir/tests/nissya_bib.aux ptexdir/tests/nissya.bst ptexdir/tests/sample.bib
DISTCLEANFILES += ptests/nissya_bib.*
## ptexdir/pbibtex.test
-DISTCLEANFILES += ptests/xexampl.aux ptests/xexampl.bbl ptests/xexampl.blg
+EXTRA_DIST += tests/testfield.bst tests/enc-asc.bib tests/enc-jis.bib tests/enc-sjis.bib \
+ tests/enc-euc.bib tests/enc-utf8.bib tests/enc-utf8a.bib tests/enc-utf8b.bib \
+ tests/enc-amb0.bib tests/enc-amb1.bib tests/enc-amb2.bib \
+ tests/enc.aux tests/enc-e.aux tests/enc-s.aux \
+ tests/enc-p.bbl tests/enc-ep.bbl tests/enc-sp.bbl
+DISTCLEANFILES += ptests/xexampl.aux ptests/xexampl.bbl ptests/xexampl.blg \
+ ptests/xenc*.*
## ptexdir/pbibtex-mem.test
EXTRA_DIST += tests/memdata1.bst tests/memdata2.bst tests/memdata3.bst
DISTCLEANFILES += ptests/memtest.bib ptests/memtest?.*
diff --git a/Build/source/texk/web2c/ptexdir/kanji.c b/Build/source/texk/web2c/ptexdir/kanji.c
index a3f56607612..0926f7b37ca 100644
--- a/Build/source/texk/web2c/ptexdir/kanji.c
+++ b/Build/source/texk/web2c/ptexdir/kanji.c
@@ -96,12 +96,10 @@ void init_default_kanji (const_string file_str, const_string internal_str)
fprintf (stderr, "Ignoring bad kanji encoding \"%s\".\n", p);
}
-#ifdef WIN32
p = kpse_var_value ("guess_input_kanji_encoding");
if (p) {
if (*p == '1' || *p == 'y' || *p == 't')
infile_enc_auto = 1;
free(p);
}
-#endif
}
diff --git a/Build/source/texk/web2c/ptexdir/kanji.h b/Build/source/texk/web2c/ptexdir/kanji.h
index e0edeb2ed70..91038154fd8 100644
--- a/Build/source/texk/web2c/ptexdir/kanji.h
+++ b/Build/source/texk/web2c/ptexdir/kanji.h
@@ -53,6 +53,9 @@ extern void init_default_kanji (const_string file_str, const_string internal_str
#endif
/* for pDVItype */
#define setpriorfileenc() set_prior_file_enc()
+/* for pBibTeX */
+#define enableguessfileenc() set_guess_file_enc(1)
+#define disableguessfileenc() set_guess_file_enc(0)
#ifndef PRESERVE_PUTC
#undef putc
diff --git a/Build/source/texk/web2c/ptexdir/pbibtex.ch b/Build/source/texk/web2c/ptexdir/pbibtex.ch
index 8b5f2077698..d1aa891a90a 100644
--- a/Build/source/texk/web2c/ptexdir/pbibtex.ch
+++ b/Build/source/texk/web2c/ptexdir/pbibtex.ch
@@ -625,7 +625,7 @@ while (sp_ptr < sp_end) do {shift the substring}
@x
const n_options = 4; {Pascal won't count array lengths for us.}
@y
-const n_options = 6; {Pascal won't count array lengths for us.}
+const n_options = 8; {Pascal won't count array lengths for us.}
@z
@x
@@ -641,6 +641,12 @@ const n_options = 6; {Pascal won't count array lengths for us.}
if (not set_enc_string(optarg, nil)) then
write_ln('Bad kanji encoding "', stringcast(optarg), '".');
+ end else if argument_is ('guess-input-enc') then begin
+ enable_guess_file_enc;
+
+ end else if argument_is ('no-guess-input-enc') then begin
+ disable_guess_file_enc;
+
end; {Else it was a flag; |getopt| has already done the assignment.}
@z
@@ -666,6 +672,16 @@ long_options[current_option].has_arg := 1;
long_options[current_option].flag := 0;
long_options[current_option].val := 0;
incr(current_option);
+long_options[current_option].name := 'guess-input-enc';
+long_options[current_option].has_arg := 0;
+long_options[current_option].flag := 0;
+long_options[current_option].val := 0;
+incr(current_option);
+long_options[current_option].name := 'no-guess-input-enc';
+long_options[current_option].has_arg := 0;
+long_options[current_option].flag := 0;
+long_options[current_option].val := 0;
+incr(current_option);
@z
@x
diff --git a/Build/source/texk/web2c/ptexdir/pbibtex.test b/Build/source/texk/web2c/ptexdir/pbibtex.test
index eaeff03454c..f7cb02845bb 100755
--- a/Build/source/texk/web2c/ptexdir/pbibtex.test
+++ b/Build/source/texk/web2c/ptexdir/pbibtex.test
@@ -5,13 +5,38 @@
# You may freely use, modify and/or distribute this file.
test -d ptests || mkdir -p ptests
-rm -f ptests/xexampl.*
+rm -f ptests/xexampl.* ptests/xenc*.*
+
+rc=0
+
+TEXMFCNF=$srcdir/../kpathsea
+BSTINPUTS=$srcdir/tests
+BIBINPUTS=$srcdir/tests
+export TEXMFCNF BSTINPUTS BIBINPUTS
cp $srcdir/tests/exampl.aux ptests/xexampl.aux
-TEXMFCNF=$srcdir/../kpathsea \
- BSTINPUTS=$srcdir/tests \
- BIBINPUTS=$srcdir/tests \
- ./pbibtex ptests/xexampl || exit 1
-diff $srcdir/tests/exampl.bbl ptests/xexampl.bbl || exit 2
+./pbibtex ptests/xexampl || rc=1
+diff $srcdir/tests/exampl.bbl ptests/xexampl.bbl || rc=2
+
+
+cp $srcdir/tests/enc.aux ptests/xenc.aux
+
+guess_input_kanji_encoding=1 ./pbibtex ptests/xenc || rc=3
+diff $srcdir/tests/enc-p.bbl ptests/xenc.bbl || rc=4
+
+
+cp $srcdir/tests/enc-e.aux ptests/xenc-e.aux
+
+guess_input_kanji_encoding=1 ./pbibtex -kanji=euc ptests/xenc-e || rc=5
+diff $srcdir/tests/enc-ep.bbl ptests/xenc-e.bbl || rc=6
+
+
+cp $srcdir/tests/enc-s.aux ptests/xenc-s.aux
+
+./pbibtex -guess-input-enc -kanji=sjis ptests/xenc-s || rc=7
+diff $srcdir/tests/enc-sp.bbl ptests/xenc-s.bbl || rc=8
+
+
+exit $rc