summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorTakuji Tanaka <ttk@t-lab.opal.ne.jp>2024-02-01 11:52:39 +0000
committerTakuji Tanaka <ttk@t-lab.opal.ne.jp>2024-02-01 11:52:39 +0000
commit78ed9b516abbe8ff912974668d86e51cc3504b7d (patch)
tree90d73dbbc7340e03adf109328e4b8e0d63986bc6 /Build
parentafee92f37ca304911160566b13d4536c0aff6de3 (diff)
ptexenc: Add a new simple encoding conversion utility "ptekf"
git-svn-id: svn://tug.org/texlive/trunk@69656 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/ptexenc/COPYRIGHT2
-rw-r--r--Build/source/texk/ptexenc/ChangeLog18
-rw-r--r--Build/source/texk/ptexenc/Makefile.am31
-rw-r--r--Build/source/texk/ptexenc/Makefile.in495
-rw-r--r--Build/source/texk/ptexenc/c-auto.in5
-rwxr-xr-xBuild/source/texk/ptexenc/configure31
-rw-r--r--Build/source/texk/ptexenc/configure.ac4
-rw-r--r--Build/source/texk/ptexenc/kanjicnv.c6
-rw-r--r--Build/source/texk/ptexenc/ptekf.c222
-rw-r--r--Build/source/texk/ptexenc/ptexenc.c104
-rw-r--r--Build/source/texk/ptexenc/ptexenc/kanjicnv.h2
-rw-r--r--Build/source/texk/ptexenc/ptexenc/ptexenc.h2
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb0.bib-eucbin0 -> 704 bytes
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb0.bib-euc-utf813
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb0.bib-jisbin0 -> 878 bytes
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb0.bib-sjisbin0 -> 704 bytes
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb0.bib-sjis-utf85
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb0.bib-utf813
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb1.bib-eucbin0 -> 174 bytes
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb1.bib-jisbin0 -> 222 bytes
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb1.bib-sjisbin0 -> 174 bytes
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb1.bib-sjis-utf85
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb1.bib-utf85
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb2.bib-euc-utf813
-rw-r--r--Build/source/texk/ptexenc/tests/enc-amb2.bib-sjis-utf813
-rw-r--r--Build/source/texk/ptexenc/tests/enc-euc.bib-utf85
-rw-r--r--Build/source/texk/ptexenc/tests/enc-jis.bib-utf85
-rw-r--r--Build/source/texk/ptexenc/tests/enc-sjis.bib-utf85
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8.bib-euc6
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8.bib-jis6
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8.bib-sjis6
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8.bib-utf86
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8a.bib-eucbin0 -> 198 bytes
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8a.bib-jisbin0 -> 246 bytes
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8a.bib-sjisbin0 -> 198 bytes
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8a.bib-utf86
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8b.bib-euc7
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8b.bib-jis7
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8b.bib-sjis7
-rw-r--r--Build/source/texk/ptexenc/tests/enc-utf8b.bib-utf87
-rwxr-xr-xBuild/source/texk/ptexenc/tests/ptekf-conv.test77
-rwxr-xr-xBuild/source/texk/ptexenc/tests/ptekf-guess.test20
-rwxr-xr-xBuild/source/texk/ptexenc/tests/ptekf-smoke.test14
-rw-r--r--Build/source/texk/ptexenc/version.ac4
-rw-r--r--Build/source/texk/web2c/ChangeLog6
-rw-r--r--Build/source/texk/web2c/tests/enc-ep.bbl1
-rw-r--r--Build/source/texk/web2c/tests/enc-eu.bbl1
-rw-r--r--Build/source/texk/web2c/tests/enc-p.bbl1
-rw-r--r--Build/source/texk/web2c/tests/enc-sp.bbl1
-rw-r--r--Build/source/texk/web2c/tests/enc-su.bblbin931 -> 950 bytes
-rw-r--r--Build/source/texk/web2c/tests/enc-u.bbl1
-rw-r--r--Build/source/texk/web2c/tests/enc-up.bbl1
-rw-r--r--Build/source/texk/web2c/tests/enc-utf8.bib1
-rw-r--r--Build/source/texk/web2c/tests/enc-uu.bbl1
54 files changed, 1123 insertions, 68 deletions
diff --git a/Build/source/texk/ptexenc/COPYRIGHT b/Build/source/texk/ptexenc/COPYRIGHT
index 09a4da02d59..0a3af255b1c 100644
--- a/Build/source/texk/ptexenc/COPYRIGHT
+++ b/Build/source/texk/ptexenc/COPYRIGHT
@@ -1,6 +1,6 @@
Copyright (C) 2009 ASCII MEDIA WORKS.
Copyright (C) 2006-2010 N. Tsuchimura
-Copyright (C) 2010-2023 Japanese TeX Development Community
+Copyright (C) 2010-2024 Japanese TeX Development Community
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/Build/source/texk/ptexenc/ChangeLog b/Build/source/texk/ptexenc/ChangeLog
index dce75d109d6..a58fb567a16 100644
--- a/Build/source/texk/ptexenc/ChangeLog
+++ b/Build/source/texk/ptexenc/ChangeLog
@@ -1,3 +1,21 @@
+2024-02-01 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
+
+ * ptexenc.c, ptexenc/ptexenc.h, kanjicnv.c, ptexenc/kanjicnv.h:
+ Add to support ISO-8859 in guessing input file encodings.
+ * ptekf.c: Add a new simple encoding conversion utility "ptekf"
+ to analyze file encoding conversion procedure.
+ * tests/ptekf-{smoke,guess,conv}.test,
+ tests/enc-amb0.bib-{euc,euc-utf8,jis,sjis,sjis-utf8,utf8},
+ tests/enc-amb1.bib-{euc,jis,sjis,sjis-utf8,utf8},
+ tests/enc-amb2,bib_{euc,sjis}-utf8,
+ tests/enc-{euc,jis,sjis}.bib-utf8,
+ tests/enc-utf8{,a,b}.bib-{euc,jis,sjis,utf8}:
+ New tests to guess/convert encoding.
+ https://github.com/texjporg/tex-jp-build/issues/142
+ * configure.ac, Makefile.am: Adjust.
+ * version.ac, COPYRIGHT: Update copyright year.
+ * version.ac: Bump to 1.4.5/dev.
+
2023-09-11 Hironobu Yamashita <h.y.acetaminophen@gmail.com>
* unicode.c (UPTEXtoUCS): if >=UCS_MAX not >UCS_MAX.
diff --git a/Build/source/texk/ptexenc/Makefile.am b/Build/source/texk/ptexenc/Makefile.am
index d7be34975cb..d7a305d8123 100644
--- a/Build/source/texk/ptexenc/Makefile.am
+++ b/Build/source/texk/ptexenc/Makefile.am
@@ -3,7 +3,7 @@
## Copyright (C) 2010-2014 Peter Breitenlohner <tex-live@tug.org>
## You may freely use, modify and/or distribute this file.
##
-AM_CPPFLAGS = $(KPATHSEA_INCLUDES)
+AM_CPPFLAGS = $(PTEXENC_INCLUDES) $(KPATHSEA_INCLUDES) -DKPATHSEA -DPTEXENC
AM_CFLAGS = $(WARNING_CFLAGS)
lib_LTLIBRARIES = libptexenc.la
@@ -40,6 +40,35 @@ pkgconfig_DATA = ptexenc.pc
EXTRA_DIST = COPYRIGHT ChangeLog.jp
+## The programs
+bin_PROGRAMS = ptekf
+ptekf_LDADD = libptexenc.la
+
+LDADD = $(KPATHSEA_LIBS)
+
+## Tests
+#
+TESTS = tests/ptekf-smoke.test tests/ptekf-guess.test tests/ptekf-conv.test
+#
+tests/ptekf-smoke.log tests/ptekf-guess.log tests/ptekf-conv.log \
+ : ptekf$(EXEEXT)
+#
+EXTRA_DIST += $(TESTS)
+#
+## ptekf-conv.test
+EXTRA_DIST += \
+ tests/enc-amb0.bib-euc tests/enc-amb0.bib-euc-utf8 tests/enc-amb0.bib-jis \
+ tests/enc-amb0.bib-sjis tests/enc-amb0.bib-sjis-utf8 tests/enc-amb0.bib-utf8 \
+ tests/enc-amb1.bib-euc tests/enc-amb1.bib-jis tests/enc-amb1.bib-sjis \
+ tests/enc-amb1.bib-sjis-utf8 tests/enc-amb1.bib-utf8 \
+ tests/enc-amb2.bib-euc-utf8 tests/enc-amb2.bib-sjis-utf8 \
+ tests/enc-euc.bib-utf8 tests/enc-jis.bib-utf8 tests/enc-sjis.bib-utf8 \
+ tests/enc-utf8.bib-euc tests/enc-utf8.bib-jis tests/enc-utf8.bib-sjis tests/enc-utf8.bib-utf8 \
+ tests/enc-utf8a.bib-euc tests/enc-utf8a.bib-jis tests/enc-utf8a.bib-sjis tests/enc-utf8a.bib-utf8 \
+ tests/enc-utf8b.bib-euc tests/enc-utf8b.bib-jis tests/enc-utf8b.bib-sjis tests/enc-utf8b.bib-utf8
+DISTCLEANFILES = enc-*.bib*
+
+
# Rebuild
rebuild_prereq =
rebuild_target = all
diff --git a/Build/source/texk/ptexenc/Makefile.in b/Build/source/texk/ptexenc/Makefile.in
index d390aea6c67..6361464e6ba 100644
--- a/Build/source/texk/ptexenc/Makefile.in
+++ b/Build/source/texk/ptexenc/Makefile.in
@@ -16,6 +16,7 @@
+
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
@@ -90,6 +91,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
+bin_PROGRAMS = ptekf$(EXEEXT)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-common.m4 \
@@ -101,7 +103,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-common.m4 \
$(top_srcdir)/../../m4/ltsugar.m4 \
$(top_srcdir)/../../m4/ltversion.m4 \
$(top_srcdir)/../../m4/lt~obsolete.m4 $(top_srcdir)/version.ac \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/../../version.ac $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
@@ -113,6 +115,9 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/ptexenc/c-auto.h
CONFIG_CLEAN_FILES = ptexenc.pc
CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \
+ "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"
+PROGRAMS = $(bin_PROGRAMS)
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -140,8 +145,6 @@ am__uninstall_files_from_dir = { \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
-am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \
- "$(DESTDIR)$(includedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libptexenc_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
@@ -156,6 +159,9 @@ am__v_lt_1 =
libptexenc_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libptexenc_la_LDFLAGS) $(LDFLAGS) -o $@
+ptekf_SOURCES = ptekf.c
+ptekf_OBJECTS = ptekf.$(OBJEXT)
+ptekf_DEPENDENCIES = libptexenc.la
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -174,7 +180,7 @@ am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/libptexenc_la-kanjicnv.Plo \
./$(DEPDIR)/libptexenc_la-ptexenc.Plo \
./$(DEPDIR)/libptexenc_la-unicode-jp.Plo \
- ./$(DEPDIR)/libptexenc_la-unicode.Plo
+ ./$(DEPDIR)/libptexenc_la-unicode.Plo ./$(DEPDIR)/ptekf.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -194,8 +200,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = $(libptexenc_la_SOURCES)
-DIST_SOURCES = $(libptexenc_la_SOURCES)
+SOURCES = $(libptexenc_la_SOURCES) ptekf.c
+DIST_SOURCES = $(libptexenc_la_SOURCES) ptekf.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -221,7 +227,182 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
-AM_RECURSIVE_TARGETS = cscope
+AM_RECURSIVE_TARGETS = cscope check recheck
+am__tty_colors_dummy = \
+ mgn= red= grn= lgn= blu= brg= std=; \
+ am__color_tests=no
+am__tty_colors = { \
+ $(am__tty_colors_dummy); \
+ if test "X$(AM_COLOR_TESTS)" = Xno; then \
+ am__color_tests=no; \
+ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
+ am__color_tests=yes; \
+ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
+ am__color_tests=yes; \
+ fi; \
+ if test $$am__color_tests = yes; then \
+ red=''; \
+ grn=''; \
+ lgn=''; \
+ blu=''; \
+ mgn=''; \
+ brg=''; \
+ std=''; \
+ fi; \
+}
+am__recheck_rx = ^[ ]*:recheck:[ ]*
+am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
+am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
+# A command that, given a newline-separated list of test names on the
+# standard input, print the name of the tests that are to be re-run
+# upon "make recheck".
+am__list_recheck_tests = $(AWK) '{ \
+ recheck = 1; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ { \
+ if ((getline line2 < ($$0 ".log")) < 0) \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
+ { \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
+ { \
+ break; \
+ } \
+ }; \
+ if (recheck) \
+ print $$0; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# A command that, given a newline-separated list of test names on the
+# standard input, create the global log from their .trs and .log files.
+am__create_global_log = $(AWK) ' \
+function fatal(msg) \
+{ \
+ print "fatal: making $@: " msg | "cat >&2"; \
+ exit 1; \
+} \
+function rst_section(header) \
+{ \
+ print header; \
+ len = length(header); \
+ for (i = 1; i <= len; i = i + 1) \
+ printf "="; \
+ printf "\n\n"; \
+} \
+{ \
+ copy_in_global_log = 1; \
+ global_test_result = "RUN"; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".trs"); \
+ if (line ~ /$(am__global_test_result_rx)/) \
+ { \
+ sub("$(am__global_test_result_rx)", "", line); \
+ sub("[ ]*$$", "", line); \
+ global_test_result = line; \
+ } \
+ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
+ copy_in_global_log = 0; \
+ }; \
+ if (copy_in_global_log) \
+ { \
+ rst_section(global_test_result ": " $$0); \
+ while ((rc = (getline line < ($$0 ".log"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".log"); \
+ print line; \
+ }; \
+ printf "\n"; \
+ }; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# Restructured Text title.
+am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
+# by disabling -e (using the XSI extension "set +e") if it's set.
+am__sh_e_setup = case $$- in *e*) set +e;; esac
+# Default flags passed to test drivers.
+am__common_driver_flags = \
+ --color-tests "$$am__color_tests" \
+ --enable-hard-errors "$$am__enable_hard_errors" \
+ --expect-failure "$$am__expect_failure"
+# To be inserted before the command running the test. Creates the
+# directory for the log if needed. Stores in $dir the directory
+# containing $f, in $tst the test, in $log the log. Executes the
+# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
+# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
+# will run the test scripts (or their associated LOG_COMPILER, if
+# thy have one).
+am__check_pre = \
+$(am__sh_e_setup); \
+$(am__vpath_adj_setup) $(am__vpath_adj) \
+$(am__tty_colors); \
+srcdir=$(srcdir); export srcdir; \
+case "$@" in \
+ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
+ *) am__odir=.;; \
+esac; \
+test "x$$am__odir" = x"." || test -d "$$am__odir" \
+ || $(MKDIR_P) "$$am__odir" || exit $$?; \
+if test -f "./$$f"; then dir=./; \
+elif test -f "$$f"; then dir=; \
+else dir="$(srcdir)/"; fi; \
+tst=$$dir$$f; log='$@'; \
+if test -n '$(DISABLE_HARD_ERRORS)'; then \
+ am__enable_hard_errors=no; \
+else \
+ am__enable_hard_errors=yes; \
+fi; \
+case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
+ am__expect_failure=yes;; \
+ *) \
+ am__expect_failure=no;; \
+esac; \
+$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
+# A shell command to get the names of the tests scripts with any registered
+# extension removed (i.e., equivalently, the names of the test logs, with
+# the '.log' extension removed). The result is saved in the shell variable
+# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
+# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
+# since that might cause problem with VPATH rewrites for suffix-less tests.
+# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
+am__set_TESTS_bases = \
+ bases='$(TEST_LOGS)'; \
+ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
+ bases=`echo $$bases`
+AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
+RECHECK_LOGS = $(TEST_LOGS)
+TEST_SUITE_LOG = test-suite.log
+TEST_EXTENSIONS = @EXEEXT@ .test
+am__test_logs1 = $(TESTS:=.log)
+am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
+TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/../../build-aux/test-driver
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+ $(TEST_LOG_FLAGS)
+am__set_b = \
+ case '$@' in \
+ */*) \
+ case '$*' in \
+ */*) b='$*';; \
+ *) b=`echo '$@' | sed 's/\.log$$//'`; \
+ esac;; \
+ *) \
+ b='$*';; \
+ esac
am__DIST_COMMON = $(srcdir)/../../am/rebuild.am $(srcdir)/Makefile.in \
$(srcdir)/c-auto.in $(srcdir)/ptexenc.pc.in \
$(top_srcdir)/../../build-aux/ar-lib \
@@ -231,12 +412,14 @@ am__DIST_COMMON = $(srcdir)/../../am/rebuild.am $(srcdir)/Makefile.in \
$(top_srcdir)/../../build-aux/depcomp \
$(top_srcdir)/../../build-aux/install-sh \
$(top_srcdir)/../../build-aux/ltmain.sh \
- $(top_srcdir)/../../build-aux/missing ../../build-aux/ar-lib \
- ../../build-aux/compile ../../build-aux/config.guess \
- ../../build-aux/config.sub ../../build-aux/depcomp \
- ../../build-aux/install-sh ../../build-aux/ltmain.sh \
- ../../build-aux/missing ../../build-aux/texinfo.tex \
- ../../build-aux/ylwrap ChangeLog README
+ $(top_srcdir)/../../build-aux/missing \
+ $(top_srcdir)/../../build-aux/test-driver \
+ ../../build-aux/ar-lib ../../build-aux/compile \
+ ../../build-aux/config.guess ../../build-aux/config.sub \
+ ../../build-aux/depcomp ../../build-aux/install-sh \
+ ../../build-aux/ltmain.sh ../../build-aux/missing \
+ ../../build-aux/texinfo.tex ../../build-aux/ylwrap ChangeLog \
+ README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@@ -384,7 +567,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-AM_CPPFLAGS = $(KPATHSEA_INCLUDES)
+AM_CPPFLAGS = $(PTEXENC_INCLUDES) $(KPATHSEA_INCLUDES) -DKPATHSEA -DPTEXENC
AM_CFLAGS = $(WARNING_CFLAGS)
lib_LTLIBRARIES = libptexenc.la
libptexenc_la_CPPFLAGS = $(AM_CPPFLAGS) -DMAKE_PTENC_DLL
@@ -408,7 +591,29 @@ nobase_include_HEADERS = \
pkgconfigdir = ${libdir}/pkgconfig
pkgconfig_DATA = ptexenc.pc
-EXTRA_DIST = COPYRIGHT ChangeLog.jp
+#
+#
+EXTRA_DIST = COPYRIGHT ChangeLog.jp $(TESTS) tests/enc-amb0.bib-euc \
+ tests/enc-amb0.bib-euc-utf8 tests/enc-amb0.bib-jis \
+ tests/enc-amb0.bib-sjis tests/enc-amb0.bib-sjis-utf8 \
+ tests/enc-amb0.bib-utf8 tests/enc-amb1.bib-euc \
+ tests/enc-amb1.bib-jis tests/enc-amb1.bib-sjis \
+ tests/enc-amb1.bib-sjis-utf8 tests/enc-amb1.bib-utf8 \
+ tests/enc-amb2.bib-euc-utf8 tests/enc-amb2.bib-sjis-utf8 \
+ tests/enc-euc.bib-utf8 tests/enc-jis.bib-utf8 \
+ tests/enc-sjis.bib-utf8 tests/enc-utf8.bib-euc \
+ tests/enc-utf8.bib-jis tests/enc-utf8.bib-sjis \
+ tests/enc-utf8.bib-utf8 tests/enc-utf8a.bib-euc \
+ tests/enc-utf8a.bib-jis tests/enc-utf8a.bib-sjis \
+ tests/enc-utf8a.bib-utf8 tests/enc-utf8b.bib-euc \
+ tests/enc-utf8b.bib-jis tests/enc-utf8b.bib-sjis \
+ tests/enc-utf8b.bib-utf8
+ptekf_LDADD = libptexenc.la
+LDADD = $(KPATHSEA_LIBS)
+
+#
+TESTS = tests/ptekf-smoke.test tests/ptekf-guess.test tests/ptekf-conv.test
+DISTCLEANFILES = enc-*.bib*
# Rebuild
rebuild_prereq =
@@ -417,7 +622,7 @@ CLEANFILES = rebuild.stamp
all: all-am
.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
+.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../am/rebuild.am $(am__configure_deps)
@@ -469,6 +674,55 @@ distclean-hdr:
-rm -f ptexenc/c-auto.h ptexenc/stamp-h1
ptexenc.pc: $(top_builddir)/config.status $(srcdir)/ptexenc.pc.in
cd $(top_builddir) && $(SHELL) ./config.status $@
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+ fi; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p \
+ || test -f $$p1 \
+ ; then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' \
+ -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' \
+ `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
@@ -508,6 +762,10 @@ clean-libLTLIBRARIES:
libptexenc.la: $(libptexenc_la_OBJECTS) $(libptexenc_la_DEPENDENCIES) $(EXTRA_libptexenc_la_DEPENDENCIES)
$(AM_V_CCLD)$(libptexenc_la_LINK) -rpath $(libdir) $(libptexenc_la_OBJECTS) $(libptexenc_la_LIBADD) $(LIBS)
+ptekf$(EXEEXT): $(ptekf_OBJECTS) $(ptekf_DEPENDENCIES) $(EXTRA_ptekf_DEPENDENCIES)
+ @rm -f ptekf$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(ptekf_OBJECTS) $(ptekf_LDADD) $(LIBS)
+
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -518,6 +776,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libptexenc_la-ptexenc.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libptexenc_la-unicode-jp.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libptexenc_la-unicode.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ptekf.Po@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@@ -689,6 +948,162 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
+
+# Recover from deleted '.trs' file; this should ensure that
+# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
+# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
+# to avoid problems with "make -n".
+.log.trs:
+ rm -f $< $@
+ $(MAKE) $(AM_MAKEFLAGS) $<
+
+# Leading 'am--fnord' is there to ensure the list of targets does not
+# expand to empty, as could happen e.g. with make check TESTS=''.
+am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
+am--force-recheck:
+ @:
+
+$(TEST_SUITE_LOG): $(TEST_LOGS)
+ @$(am__set_TESTS_bases); \
+ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
+ redo_bases=`for i in $$bases; do \
+ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
+ done`; \
+ if test -n "$$redo_bases"; then \
+ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
+ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
+ if $(am__make_dryrun); then :; else \
+ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
+ fi; \
+ fi; \
+ if test -n "$$am__remaking_logs"; then \
+ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+ "recursion detected" >&2; \
+ elif test -n "$$redo_logs"; then \
+ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+ fi; \
+ if $(am__make_dryrun); then :; else \
+ st=0; \
+ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
+ for i in $$redo_bases; do \
+ test -f $$i.trs && test -r $$i.trs \
+ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
+ test -f $$i.log && test -r $$i.log \
+ || { echo "$$errmsg $$i.log" >&2; st=1; }; \
+ done; \
+ test $$st -eq 0 || exit 1; \
+ fi
+ @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
+ ws='[ ]'; \
+ results=`for b in $$bases; do echo $$b.trs; done`; \
+ test -n "$$results" || results=/dev/null; \
+ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
+ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
+ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
+ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
+ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
+ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
+ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
+ if test `expr $$fail + $$xpass + $$error` -eq 0; then \
+ success=true; \
+ else \
+ success=false; \
+ fi; \
+ br='==================='; br=$$br$$br$$br$$br; \
+ result_count () \
+ { \
+ if test x"$$1" = x"--maybe-color"; then \
+ maybe_colorize=yes; \
+ elif test x"$$1" = x"--no-color"; then \
+ maybe_colorize=no; \
+ else \
+ echo "$@: invalid 'result_count' usage" >&2; exit 4; \
+ fi; \
+ shift; \
+ desc=$$1 count=$$2; \
+ if test $$maybe_colorize = yes && test $$count -gt 0; then \
+ color_start=$$3 color_end=$$std; \
+ else \
+ color_start= color_end=; \
+ fi; \
+ echo "$${color_start}# $$desc $$count$${color_end}"; \
+ }; \
+ create_testsuite_report () \
+ { \
+ result_count $$1 "TOTAL:" $$all "$$brg"; \
+ result_count $$1 "PASS: " $$pass "$$grn"; \
+ result_count $$1 "SKIP: " $$skip "$$blu"; \
+ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
+ result_count $$1 "FAIL: " $$fail "$$red"; \
+ result_count $$1 "XPASS:" $$xpass "$$red"; \
+ result_count $$1 "ERROR:" $$error "$$mgn"; \
+ }; \
+ { \
+ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
+ $(am__rst_title); \
+ create_testsuite_report --no-color; \
+ echo; \
+ echo ".. contents:: :depth: 2"; \
+ echo; \
+ for b in $$bases; do echo $$b; done \
+ | $(am__create_global_log); \
+ } >$(TEST_SUITE_LOG).tmp || exit 1; \
+ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
+ if $$success; then \
+ col="$$grn"; \
+ else \
+ col="$$red"; \
+ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
+ fi; \
+ echo "$${col}$$br$${std}"; \
+ echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \
+ echo "$${col}$$br$${std}"; \
+ create_testsuite_report --maybe-color; \
+ echo "$$col$$br$$std"; \
+ if $$success; then :; else \
+ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
+ if test -n "$(PACKAGE_BUGREPORT)"; then \
+ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
+ fi; \
+ echo "$$col$$br$$std"; \
+ fi; \
+ $$success || exit 1
+
+check-TESTS:
+ @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+ @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ trs_list=`for i in $$bases; do echo $$i.trs; done`; \
+ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
+ exit $$?;
+recheck: all
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ bases=`for i in $$bases; do echo $$i; done \
+ | $(am__list_recheck_tests)` || exit 1; \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ log_list=`echo $$log_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
+ am__force_recheck=am--force-recheck \
+ TEST_LOGS="$$log_list"; \
+ exit $$?
+.test.log:
+ @p='$<'; \
+ $(am__set_b); \
+ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+@am__EXEEXT_TRUE@.test$(EXEEXT).log:
+@am__EXEEXT_TRUE@ @p='$<'; \
+@am__EXEEXT_TRUE@ $(am__set_b); \
+@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
+@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
@@ -862,10 +1277,13 @@ distcleancheck: distclean
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
-all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
+all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(DATA) $(HEADERS)
+install-binPROGRAMS: install-libLTLIBRARIES
+
installdirs:
- for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@@ -888,6 +1306,9 @@ install-strip:
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
+ -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
+ -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
+ -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
@@ -895,14 +1316,15 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
- mostlyclean-am
+clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
+ clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
@@ -910,6 +1332,7 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/libptexenc_la-ptexenc.Plo
-rm -f ./$(DEPDIR)/libptexenc_la-unicode-jp.Plo
-rm -f ./$(DEPDIR)/libptexenc_la-unicode.Plo
+ -rm -f ./$(DEPDIR)/ptekf.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-libtool distclean-tags
@@ -932,7 +1355,7 @@ install-dvi: install-dvi-am
install-dvi-am:
-install-exec-am: install-libLTLIBRARIES
+install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
install-html: install-html-am
@@ -961,6 +1384,7 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/libptexenc_la-ptexenc.Plo
-rm -f ./$(DEPDIR)/libptexenc_la-unicode-jp.Plo
-rm -f ./$(DEPDIR)/libptexenc_la-unicode.Plo
+ -rm -f ./$(DEPDIR)/ptekf.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
@@ -977,20 +1401,21 @@ ps: ps-am
ps-am:
-uninstall-am: uninstall-libLTLIBRARIES uninstall-nobase_includeHEADERS \
- uninstall-pkgconfigDATA
+uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES \
+ uninstall-nobase_includeHEADERS uninstall-pkgconfigDATA
-.MAKE: install-am install-strip
+.MAKE: check-am install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles am--refresh check \
- check-am clean clean-cscope clean-generic clean-libLTLIBRARIES \
- clean-libtool cscope cscopelist-am ctags ctags-am dist \
- dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \
- dist-xz dist-zip dist-zstd distcheck distclean \
- distclean-compile distclean-generic distclean-hdr \
- distclean-libtool distclean-tags distcleancheck distdir \
- distuninstallcheck dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-dvi \
+ check-TESTS check-am clean clean-binPROGRAMS clean-cscope \
+ clean-generic clean-libLTLIBRARIES clean-libtool cscope \
+ cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
+ dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
+ dist-zstd distcheck distclean distclean-compile \
+ distclean-generic distclean-hdr distclean-libtool \
+ distclean-tags distcleancheck distdir distuninstallcheck dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-binPROGRAMS install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am \
install-libLTLIBRARIES install-man \
@@ -999,7 +1424,8 @@ uninstall-am: uninstall-libLTLIBRARIES uninstall-nobase_includeHEADERS \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
+ recheck tags tags-am uninstall uninstall-am \
+ uninstall-binPROGRAMS uninstall-libLTLIBRARIES \
uninstall-nobase_includeHEADERS uninstall-pkgconfigDATA
.PRECIOUS: Makefile
@@ -1008,6 +1434,9 @@ uninstall-am: uninstall-libLTLIBRARIES uninstall-nobase_includeHEADERS \
$(libptexenc_la_OBJECTS): $(KPATHSEA_DEPEND)
@KPATHSEA_RULE@
+#
+tests/ptekf-smoke.log tests/ptekf-guess.log tests/ptekf-conv.log \
+ : ptekf$(EXEEXT)
rebuild.stamp: $(rebuild_target)
echo timestamp >$@
diff --git a/Build/source/texk/ptexenc/c-auto.in b/Build/source/texk/ptexenc/c-auto.in
index 79dcb493708..2f7b6094a01 100644
--- a/Build/source/texk/ptexenc/c-auto.in
+++ b/Build/source/texk/ptexenc/c-auto.in
@@ -6,7 +6,7 @@
#define PTEXENC_C_AUTO_H
/* ptexenc: the version string. */
-#define PTEXENCVERSION "ptexenc version 1.4.4/dev"
+#define PTEXENCVERSION "ptexenc version 1.4.5/dev"
/* Define to 1 if the 'closedir' function returns void instead of int. */
#undef CLOSEDIR_VOID
@@ -155,6 +155,9 @@
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
+/* Define to the current TeX Live version string. */
+#undef TL_VERSION
+
/* Version number of package */
#undef VERSION
diff --git a/Build/source/texk/ptexenc/configure b/Build/source/texk/ptexenc/configure
index 30a4863e306..f632b6eaf45 100755
--- a/Build/source/texk/ptexenc/configure
+++ b/Build/source/texk/ptexenc/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.72 for ptexenc 1.4.4/dev.
+# Generated by GNU Autoconf 2.72 for ptexenc 1.4.5/dev.
#
# Report bugs to <tex-k@tug.org>.
#
@@ -614,8 +614,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='ptexenc'
PACKAGE_TARNAME='ptexenc'
-PACKAGE_VERSION='1.4.4/dev'
-PACKAGE_STRING='ptexenc 1.4.4/dev'
+PACKAGE_VERSION='1.4.5/dev'
+PACKAGE_STRING='ptexenc 1.4.5/dev'
PACKAGE_BUGREPORT='tex-k@tug.org'
PACKAGE_URL=''
@@ -1363,7 +1363,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-'configure' configures ptexenc 1.4.4/dev to adapt to many kinds of systems.
+'configure' configures ptexenc 1.4.5/dev to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1434,7 +1434,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of ptexenc 1.4.4/dev:";;
+ short | recursive ) echo "Configuration of ptexenc 1.4.5/dev:";;
esac
cat <<\_ACEOF
@@ -1555,7 +1555,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-ptexenc configure 1.4.4/dev
+ptexenc configure 1.4.5/dev
generated by GNU Autoconf 2.72
Copyright (C) 2023 Free Software Foundation, Inc.
@@ -2097,7 +2097,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by ptexenc $as_me 1.4.4/dev, which was
+It was created by ptexenc $as_me 1.4.5/dev, which was
generated by GNU Autoconf 2.72. Invocation command line was
$ $0$ac_configure_args_raw
@@ -2875,10 +2875,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
-PTEXENCVERSION=1.4.4/dev
+PTEXENCVERSION=1.4.5/dev
-PTEXENC_LT_VERSINFO=5:4:4
+PTEXENC_LT_VERSINFO=5:5:4
am__api_version='1.16'
@@ -8664,7 +8664,7 @@ fi
# Define the identity of the package.
PACKAGE='ptexenc'
- VERSION='1.4.4/dev'
+ VERSION='1.4.5/dev'
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -15005,7 +15005,7 @@ Usage: $0 [OPTIONS]
Report bugs to <bug-libtool@gnu.org>."
lt_cl_version="\
-ptexenc config.lt 1.4.4/dev
+ptexenc config.lt 1.4.5/dev
configured by $0, generated by GNU Autoconf 2.72.
Copyright (C) 2011 Free Software Foundation, Inc.
@@ -16233,6 +16233,11 @@ ac_config_headers="$ac_config_headers ptexenc/c-auto.h:c-auto.in"
+
+
+printf "%s\n" "#define TL_VERSION \"TeX Live 2024\"" >>confdefs.h
+
+
ac_config_files="$ac_config_files Makefile ptexenc.pc"
@@ -16772,7 +16777,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by ptexenc $as_me 1.4.4/dev, which was
+This file was extended by ptexenc $as_me 1.4.5/dev, which was
generated by GNU Autoconf 2.72. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -16840,7 +16845,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
-ptexenc config.status 1.4.4/dev
+ptexenc config.status 1.4.5/dev
configured by $0, generated by GNU Autoconf 2.72,
with options \\"\$ac_cs_config\\"
diff --git a/Build/source/texk/ptexenc/configure.ac b/Build/source/texk/ptexenc/configure.ac
index 406902e1047..433d2296b7a 100644
--- a/Build/source/texk/ptexenc/configure.ac
+++ b/Build/source/texk/ptexenc/configure.ac
@@ -50,6 +50,10 @@ AH_TOP([/* ptexenc/c-auto.h: defines for ptexenc, as determined by configure. */
#define PTEXENCVERSION "ptexenc version] ptexenc_version["])
AH_BOTTOM([#endif /* !PTEXENC_C_AUTO_H */])
+m4_include([../../version.ac])[] dnl define tex_live_version
+AC_DEFINE([TL_VERSION], ["TeX Live tex_live_version()"],
+ [Define to the current TeX Live version string.])
+
AC_CONFIG_FILES([Makefile ptexenc.pc])
AC_OUTPUT
diff --git a/Build/source/texk/ptexenc/kanjicnv.c b/Build/source/texk/ptexenc/kanjicnv.c
index c5de51ac2e2..327c3f30fa7 100644
--- a/Build/source/texk/ptexenc/kanjicnv.c
+++ b/Build/source/texk/ptexenc/kanjicnv.c
@@ -41,6 +41,12 @@ boolean isSJISkanji2(int c)
return (0x40 <= c && c <= 0xfc && c != 0x7f);
}
+boolean isISO8859(int c)
+{
+ c &= 0xff;
+ return (0xa0 <= c && c <= 0xff);
+}
+
/* EUC <=> JIS X 0208 code conversion */
int EUCtoJIS(int kcode)
{
diff --git a/Build/source/texk/ptexenc/ptekf.c b/Build/source/texk/ptexenc/ptekf.c
new file mode 100644
index 00000000000..50d495a71bb
--- /dev/null
+++ b/Build/source/texk/ptexenc/ptekf.c
@@ -0,0 +1,222 @@
+/*
+
+Copyright 2024 Japanese TeX Development Community <issue@texjp.org>
+Distributed under the 3-Clause BSD License.
+
+*/
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <kpathsea/getopt.h>
+#include <kpathsea/progname.h>
+#include <kpathsea/lib.h>
+
+#include <ptexenc/ptexenc.h>
+#include <c-auto.h>
+
+static char opt_input_enc[5];
+static char opt_output_enc[5];
+static int flg_guess_enc;
+static int flg_output_buffer;
+
+#define GUESS_ONLY -1
+#define GUESS_AND_OUTPUT +1
+
+#define BUFFERLEN 4096
+static char buff[BUFFERLEN];
+
+static const char *optstr = "hvgbjseuGJSEU";
+
+static struct option long_options[] = {
+ {"help", 0, 0, 'h'},
+ {"version", 0, 0, 'v'},
+ {"guess", 0, 0, 'g'},
+ {"buffer", 0, 0, 'b'},
+ {0, 0, 0, 0}
+};
+
+#define MY_VERSION "20240201"
+#define BUG_ADDRESS "issue@texjp.org"
+
+static void show_version(void)
+{
+ printf("ptekf ver." MY_VERSION " (%s) (%s, %s)\n", get_enc_string(), ptexenc_version_string, TL_VERSION);
+ printf(" Copyright (C) 2024 Japanese TeX Development Community\n");
+}
+
+static void show_usage(void)
+{
+ printf("Usage: ptekf -[OPTION] [--] in_file1 [in_file2 ..]\n");
+ printf(" j/s/e/u Specify output encoding ISO-2022-JP, Shift_JIS, EUC-JP, UTF8\n");
+ printf(" J/S/E/U Specify input encoding ISO-2022-JP, Shift_JIS, EUC-JP, UTF8\n");
+ printf(" G Guess the input encoding and output to stdout or files\n");
+ printf(" --guess -g Guess the input encoding (no conversion)\n");
+ printf(" --version -v Print version number\n");
+ printf(" --help -h Print this help\n");
+ printf(" --buffer -b Output internal buffer without code conversion\n");
+ printf("Default input/output encoding depends on kpathsearch parameters PTEX_KANJI_ENC, guess_input_kanji_encoding\n");
+ printf("\nEmail bug reports to %s.\n", BUG_ADDRESS);
+}
+
+const char *infname;
+char *outfname;
+FILE *infp, *outfp;
+
+#if defined(WIN32)
+#define R_MODE "rb"
+#define W_MODE "wb"
+#else
+#define R_MODE "r"
+#define W_MODE "w"
+#endif
+
+static char *mfgets(char *buff, int size, FILE *fp)
+{
+ int c, len;
+
+ if ((len = input_line2(fp, (unsigned char *)buff, NULL, 0, size, &c)) == 0
+ && c != '\r' && c != '\n') return NULL;
+ if (c == '\n' || c == '\r') {
+ if (len+1 < size) strcat(buff+len, "\n");
+ else ungetc(c, fp);
+ }
+ if (c == EOF) return NULL;
+ return buff;
+}
+
+
+int
+main (int argc, char **argv)
+{
+ int c;
+ int opt_ienc=0, opt_oenc=0;
+ int (*fputs__)(const char*, FILE*);
+
+ if (argc<=1) {
+ show_version();
+ show_usage();
+ return 0;
+ }
+ kpse_set_program_name(argv[0], "ptekf");
+#if defined(WIN32)
+ {
+ int ac;
+ char **av, *enc;
+ file_system_codepage = CP_UTF8;
+ is_cp932_system = 0;
+ if (get_command_line_args_utf8("utf-8", &ac, &av)) {
+ argv = av;
+ argc = ac;
+ }
+ }
+#endif
+ enable_UPTEX(true);
+
+ while ((c = getopt_long(argc, argv, optstr, long_options, NULL)) != -1) {
+ switch (c) {
+
+ case 'G': /* guess and output to stdout or files */
+ flg_guess_enc = GUESS_AND_OUTPUT;
+ opt_ienc++;
+ break;
+
+ case 'g': /* guess */
+ flg_guess_enc = GUESS_ONLY;
+ opt_ienc++;
+ break;
+
+ case 'b': /* output internal buffer */
+ flg_output_buffer = 1;
+ opt_oenc++;
+ break;
+
+ case 'h': /* help */
+ show_version();
+ show_usage();
+ return 0;
+
+ case 'v': /* version */
+ show_version();
+ return 0;
+
+ /* input encoding */
+ case 'J': strcpy(opt_input_enc, "jis") ; opt_ienc++; break;
+ case 'S': strcpy(opt_input_enc, "sjis") ; opt_ienc++; break;
+ case 'E': strcpy(opt_input_enc, "euc") ; opt_ienc++; break;
+ case 'U': strcpy(opt_input_enc, "utf8") ; opt_ienc++; break;
+
+ /* output encoding */
+ case 'j': strcpy(opt_output_enc, "jis") ; opt_oenc++; break;
+ case 's': strcpy(opt_output_enc, "sjis") ; opt_oenc++; break;
+ case 'e': strcpy(opt_output_enc, "euc") ; opt_oenc++; break;
+ case 'u': strcpy(opt_output_enc, "utf8") ; opt_oenc++; break;
+ }
+ }
+
+ if (opt_ienc>1) {
+ fprintf(stderr, "Option (--guess or -g), -G, -J, -S, -E and -U are mutually exclusive\n");
+ exit(16);
+ }
+ if (opt_oenc>1) {
+ fprintf(stderr, "Option (--buffer or -b), -j, -s, -e and -u are mutually exclusive\n");
+ exit(16);
+ }
+
+ fputs__ = flg_output_buffer ? fputs : fputs2; /* without/with code conversion */
+
+ while (optind < argc) {
+ char *genc, *ret;
+
+ infname = argv[optind++];
+ if ((infp = fopen(infname, R_MODE)) == 0) {
+ fprintf(stderr, "ERROR: fail to open input file [%s].", infname);
+ exit(32);
+ }
+ if (flg_guess_enc) {
+ genc = ptenc_guess_enc(infp, 1);
+ printf("%s: %s\n", infname, genc);
+ setinfileenc(infp, genc);
+ free(genc);
+ }
+
+ if ((opt_ienc && flg_guess_enc!=GUESS_ONLY) || opt_oenc) {
+ if (opt_oenc) {
+ outfname = xmalloc(strlen(infname)+5);
+ strcpy(outfname, infname);
+ strcat(outfname, ".out");
+
+ if ((outfp = fopen(outfname, W_MODE)) == 0) {
+ fprintf(stderr, "ERROR: fail to open output file [%s].", outfname);
+ exit(32);
+ }
+ }
+ else
+ outfp = stdout;
+
+ if (strlen(opt_input_enc)) {
+ setinfileenc(infp, opt_input_enc);
+ }
+ if (strlen(opt_output_enc)) {
+ setfileenc(opt_output_enc);
+ }
+ while ((ret = mfgets(buff, BUFFERLEN, infp)) != NULL) {
+ (*fputs__)(buff, outfp);
+ }
+ if (fclose(infp)) {
+ fprintf(stderr, "ERROR: fail to close input file [%s].", infname);
+ exit(32);
+ }
+ if (outfp != stdout && fclose(outfp)) {
+ fprintf(stderr, "ERROR: fail to close output file [%s].", outfname);
+ exit(32);
+ }
+ if (outfname)
+ free(outfname);
+ }
+ }
+
+ return 0;
+}
diff --git a/Build/source/texk/ptexenc/ptexenc.c b/Build/source/texk/ptexenc/ptexenc.c
index 4e81dbee7c8..adb853971a9 100644
--- a/Build/source/texk/ptexenc/ptexenc.c
+++ b/Build/source/texk/ptexenc/ptexenc.c
@@ -49,6 +49,7 @@ int infile_enc_auto = 2;
static int file_enc = ENC_UNKNOWN;
static int internal_enc = ENC_UNKNOWN;
static int terminal_enc = ENC_UNKNOWN;
+static int guess_enc = ENC_UNKNOWN;
const_string enc_to_string(int enc)
{
@@ -73,12 +74,13 @@ static int string_to_enc(const_string str)
if (UPTEX_enabled && strcasecmp(str, "uptex") == 0) return ENC_UPTEX;
if (strcasecmp(str, "ASCII")== 0) return file_enc;
- if (strncasecmp(str, "AMBIGUOUS", 9) == 0) return file_enc;
+ if (strncasecmp(str, "AMBIGUOUS", 9) == 0) return guess_enc;
if (strcasecmp(str, "BINARY") == 0) return ENC_JIS;
if (strcasecmp(str, "ISO-2022-JP") == 0) return ENC_JIS;
if (strcasecmp(str, "EUC-JP") == 0) return ENC_EUC;
if (strcasecmp(str, "Shift_JIS") == 0) return ENC_SJIS;
- if (strcasecmp(str, "UTF-8") == 0) return ENC_UTF8;
+ if (strncasecmp(str, "UTF-8", 5) == 0) return ENC_UTF8;
+ if (strcasecmp(str, "ISO-8859") == 0) return ENC_JIS;
return -1; /* error */
}
@@ -787,13 +789,14 @@ static boolean is_tail(long *c, FILE *fp)
}
#define MARK_LEN 4
+static int bom_u[MARK_LEN] = { 0xEF, 0xBB, 0xBF, 0x7E };
+static int bom_l[MARK_LEN] = { 0xEF, 0xBB, 0xBF, 0x01 };
+
/* if stream begins with BOM + 7bit char */
static boolean isUTF8Nstream(FILE *fp)
{
int i;
int c[MARK_LEN];
- int bom_u[MARK_LEN] = { 0xEF, 0xBB, 0xBF, 0x7E };
- int bom_l[MARK_LEN] = { 0xEF, 0xBB, 0xBF, 0x01 };
for (i=0; i<MARK_LEN; i++) {
c[i] = getc4(fp);
@@ -815,21 +818,28 @@ static int infile_enc[NOFILE]; /* ENC_UNKNOWN (=0): not determined
No halfwidth katakana in Shift_JIS
No SS2 nor SS3 in EUC-JP
JIS X 0208 only and no platform dependent characters in Shift_JIS, EUC-JP
+ ISO-8859 may have 0xA0..0xFF, may not have 0x80..0x9F
*/
-char *ptenc_guess_enc(FILE *fp)
+char *ptenc_guess_enc(FILE *fp, boolean chk_bom)
{
char *enc;
int k0, k1, k2, cdb[2], cu8[4], len_utf8;
int is_ascii=1, lbyte=0;
- int maybe_sjis=1, maybe_euc=1, maybe_utf8=1, pos_db=0, pos_utf8=0;
+ int maybe_sjis=1, maybe_euc=1, maybe_utf8=1, maybe_iso8859=1, pos_db=0, pos_utf8=0;
+ int ch_sjis=0, ch_euc=0, ch_utf8=0, ch_iso8859=0, bom=0;
#ifdef DEBUG
int i;
unsigned char str0[5];
#endif /* DEBUG */
- enc = xmalloc(sizeof(char)*18);
+ enc = xmalloc(sizeof(char)*20);
while ((k0 = fgetc(fp)) != EOF &&
- (maybe_sjis+maybe_euc+maybe_utf8>1 || pos_db || pos_utf8)) {
+ (maybe_sjis+maybe_euc+maybe_utf8+maybe_iso8859>1 || pos_db || pos_utf8 || lbyte<200)) {
+ if (maybe_iso8859 && maybe_sjis+maybe_euc+maybe_utf8==1 && !pos_db && !pos_utf8
+ && ch_iso8859>=2000) {
+ break;
+ }
+ if (chk_bom && lbyte<4 && bom_l[lbyte] <= k0 && k0 <= bom_u[lbyte]) bom++;
lbyte++;
if (k0==ESC) {
k0 = fgetc(fp);
@@ -871,8 +881,10 @@ char *ptenc_guess_enc(FILE *fp)
fprintf(stderr, " not sjis\n");
}
#endif /* DEBUG */
- if (k1)
+ if (k1) {
+ ch_sjis++;
continue;
+ }
}
maybe_sjis = 0;
}
@@ -883,6 +895,11 @@ char *ptenc_guess_enc(FILE *fp)
}
continue;
}
+
+ if (!isISO8859(k0))
+ maybe_iso8859 = 0;
+ else
+ ch_iso8859++;
is_ascii = 0;
if (pos_db==0) {
cdb[0] = k0;
@@ -896,10 +913,14 @@ char *ptenc_guess_enc(FILE *fp)
if (maybe_sjis) {
if (!k1)
maybe_sjis = 0;
+ else
+ ch_sjis++;
}
if (maybe_euc) {
if (!k2)
maybe_euc = 0;
+ else
+ ch_euc++;
}
pos_db = 0;
#ifdef DEBUG
@@ -941,7 +962,8 @@ char *ptenc_guess_enc(FILE *fp)
if (pos_utf8==1) {
if ((cu8[0]==0xE0 && cu8[1]<0xA0) ||
(cu8[0]==0xED && cu8[1]>0x9F) ||
- (cu8[0]==0xF0 && cu8[1]<0x90)) { /* illegal combination in UTF-8 */
+ (cu8[0]==0xF0 && cu8[1]<0x90) ||
+ (cu8[0]==0xF4 && cu8[1]>0x8F)) { /* illegal combination in UTF-8 */
maybe_utf8 = 0;
pos_utf8 = 0;
continue;
@@ -956,6 +978,7 @@ char *ptenc_guess_enc(FILE *fp)
for (i=0; i<len_utf8; i++) fprintf(stderr, "%02X", cu8[i]);
fprintf(stderr, " U+%06lX (%s)\n", UTF8StoUCS(str0), str0);
#endif /* DEBUG */
+ ch_utf8++;
len_utf8 = 0;
pos_utf8 = 0;
cu8[0]=cu8[1]=cu8[2]=cu8[3]=0;
@@ -967,24 +990,62 @@ char *ptenc_guess_enc(FILE *fp)
if (pos_db) maybe_sjis = maybe_euc = 0;
if (pos_utf8) maybe_utf8 = 0;
}
+#ifdef DEBUG
+ if (maybe_sjis+maybe_euc+maybe_utf8+maybe_iso8859>1) {
+ fprintf(stderr,
+ "Maybe(%d, %d, %d, %d), Multibyte characters(%d, %d, %d, %d), lbyte(%d)\n",
+ maybe_sjis, maybe_euc, maybe_utf8, maybe_iso8859, ch_sjis, ch_euc, ch_utf8, ch_iso8859, lbyte);
+ }
+#endif /* DEBUG */
+ if (maybe_iso8859) {
+ /* The threshold of ch_* to judge ISO-8859 or not is heuristic, not strict */
+ if ((maybe_sjis && ch_sjis>=16 && ch_sjis*1.3<=ch_iso8859) ||
+ (maybe_euc && ch_euc >=8 && ch_euc *2 ==ch_iso8859) ||
+ (maybe_utf8 && ch_utf8>=8 && ch_utf8*2 <=ch_iso8859) ||
+ bom==4)
+ maybe_iso8859 = 0;
+ }
if (is_ascii)
strcpy(enc,"ASCII");
- else if (maybe_sjis+maybe_euc+maybe_utf8>1) {
+ else if (maybe_sjis+maybe_euc+maybe_utf8+maybe_iso8859>1) {
+ guess_enc = ENC_UNKNOWN;
strcpy(enc,"AMBIGUOUS(");
- if (maybe_sjis)
+ if (maybe_sjis) {
enc = strcat(enc,"s");
- if (maybe_euc)
+ if (file_enc == ENC_SJIS) guess_enc = ENC_SJIS;
+ }
+ if (maybe_euc) {
enc = strcat(enc, maybe_sjis ? ",e" : "e");
- if (maybe_utf8)
- enc = strcat(enc, ",u");
+ if (file_enc == ENC_EUC) guess_enc = ENC_EUC;
+ }
+ if (maybe_utf8) {
+ enc = strcat(enc, maybe_sjis || maybe_euc ? ",u" : "u");
+ if (file_enc == ENC_UTF8) guess_enc = ENC_UTF8;
+ }
+ if (maybe_iso8859)
+ enc = strcat(enc, ",i");
enc = strcat(enc,")");
+ if (maybe_iso8859 && maybe_euc+maybe_sjis+maybe_utf8==1) {
+ if (maybe_sjis) guess_enc = ENC_SJIS;
+ if (maybe_euc) guess_enc = ENC_EUC;
+ if (maybe_utf8) guess_enc = ENC_UTF8;
+ }
+#ifdef WIN32
+ if (guess_enc == ENC_UNKNOWN) guess_enc = ENC_UTF8;
+#else
+ if (guess_enc == ENC_UNKNOWN) guess_enc = get_terminal_enc();
+#endif
}
else if (maybe_sjis)
strcpy(enc,"Shift_JIS");
else if (maybe_euc)
strcpy(enc,"EUC-JP");
- else if (maybe_utf8)
+ else if (maybe_utf8) {
strcpy(enc,"UTF-8");
+ if (bom>=3) strcat(enc," (BOM)");
+ }
+ else if (maybe_iso8859)
+ strcpy(enc,"ISO-8859");
else
strcpy(enc,"BINARY");
post_process:
@@ -1041,7 +1102,7 @@ long input_line2(FILE *fp, unsigned char *buff, unsigned char *buff2,
getc4(fp);
getc4(fp);
rewind(fp);
- enc = ptenc_guess_enc(fp);
+ enc = ptenc_guess_enc(fp, 0);
if (string_to_enc(enc) > 0) {
infile_enc[fd] = string_to_enc(enc);
fprintf(stderr, "(guessed encoding #%d: %s = %s)", fd, enc, enc_to_string(infile_enc[fd]));
@@ -1145,6 +1206,15 @@ boolean setstdinenc(const char *str)
return true;
}
+boolean setfileenc(const char *str)
+{
+ int enc;
+ enc = string_to_enc(str);
+ if (enc < 0) return false;
+ file_enc = enc;
+ return true;
+}
+
#ifdef WIN32
void clear_infile_enc(FILE *fp)
{
diff --git a/Build/source/texk/ptexenc/ptexenc/kanjicnv.h b/Build/source/texk/ptexenc/ptexenc/kanjicnv.h
index d4ddfb378e4..81dbe7e0e04 100644
--- a/Build/source/texk/ptexenc/ptexenc/kanjicnv.h
+++ b/Build/source/texk/ptexenc/ptexenc/kanjicnv.h
@@ -20,6 +20,8 @@ extern boolean isEUCkanji2(int c);
extern boolean isSJISkanji1(int c);
extern boolean isSJISkanji2(int c);
+extern boolean isISO8859(int c);
+
/* EUC <=> JIS X 0208 code conversion */
extern int EUCtoJIS(int c);
extern int JIStoEUC(int c);
diff --git a/Build/source/texk/ptexenc/ptexenc/ptexenc.h b/Build/source/texk/ptexenc/ptexenc/ptexenc.h
index 20fa2833dd6..35a4425a80e 100644
--- a/Build/source/texk/ptexenc/ptexenc/ptexenc.h
+++ b/Build/source/texk/ptexenc/ptexenc/ptexenc.h
@@ -100,6 +100,8 @@ extern PTENCDLL long input_line2(FILE *fp, unsigned char *buff, unsigned char *b
/* set current encoding */
extern PTENCDLL boolean setinfileenc(FILE *fp, const char *str);
extern PTENCDLL boolean setstdinenc(const char *str);
+extern PTENCDLL boolean setfileenc(const char *str);
+extern PTENCDLL char *ptenc_guess_enc(FILE *fp, boolean chk_bom);
#ifdef WIN32
extern PTENCDLL void clear_infile_enc(FILE *fp);
diff --git a/Build/source/texk/ptexenc/tests/enc-amb0.bib-euc b/Build/source/texk/ptexenc/tests/enc-amb0.bib-euc
new file mode 100644
index 00000000000..98ffd08cd50
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb0.bib-euc
Binary files differ
diff --git a/Build/source/texk/ptexenc/tests/enc-amb0.bib-euc-utf8 b/Build/source/texk/ptexenc/tests/enc-amb0.bib-euc-utf8
new file mode 100644
index 00000000000..1973dbdc90c
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb0.bib-euc-utf8
@@ -0,0 +1,13 @@
+% ambiguous: UTF-8 or EUC-JP
+@Type{ambiguos-a001, field = {C2Ax: 蔵贈促則即測}, }
+@Type{ambiguos-a002, field = {C2Bx: 属賊其歎}, }
+@Type{ambiguos-a005, field = {CEAx: 痢裡里離陸律率立}, }
+@Type{ambiguos-a006, field = {CEBx: 留硫粒隆竜龍侶慮旅虜了亮僚両凌}, }
+@Type{ambiguos-a007, field = {D0Ax: 弌丐丕个丱丶丼丿乂乖乘亂亅豫亊}, }
+@Type{ambiguos-a008, field = {D0Bx: 舒弍于亞亟亠亢亰亳亶从仍仄仆仂仗}, }
+@Type{ambiguos-a009, field = {篏割査 紊у0 篋≦け 絲鞘勝 綛弱コ 絽遺算 篆>三 篌岩抄 絮怨桶 綛岩晋 綛喝幻 綮銀叱 薹臥傾}, }
+@Type{ambiguos-a011, field = {F0A3B3BE: 陦馨}, }
+@Type{ambiguos-a012, field = {F0A5B6A1: 陬供}, }
+@Type{ambiguos-a013, field = {F0A1B6B7: 陝況}, }
+@Type{ambiguos-a020, field = {両立 離陸 速達 天丼 弌弍 略奪 尊属}, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-amb0.bib-jis b/Build/source/texk/ptexenc/tests/enc-amb0.bib-jis
new file mode 100644
index 00000000000..71848f055df
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb0.bib-jis
Binary files differ
diff --git a/Build/source/texk/ptexenc/tests/enc-amb0.bib-sjis b/Build/source/texk/ptexenc/tests/enc-amb0.bib-sjis
new file mode 100644
index 00000000000..02875e8dd1e
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb0.bib-sjis
Binary files differ
diff --git a/Build/source/texk/ptexenc/tests/enc-amb0.bib-sjis-utf8 b/Build/source/texk/ptexenc/tests/enc-amb0.bib-sjis-utf8
new file mode 100644
index 00000000000..c3ffe990a6f
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb0.bib-sjis-utf8
@@ -0,0 +1,5 @@
+% ambiguous: UTF-8 or Shift_JIS
+@Type{ambiguos-a050, field = {菫R菴土}, }
+@Type{ambiguos-a051, field = {隱樞蔵隱壺贈}, }
+@Type{ambiguos-a052, field = {諤晄Φ 謇鍋帥 譏取枚 蝙ら峩 諤懈ぉ}, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-amb0.bib-utf8 b/Build/source/texk/ptexenc/tests/enc-amb0.bib-utf8
new file mode 100644
index 00000000000..571d35b0ed3
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb0.bib-utf8
@@ -0,0 +1,13 @@
+% ambiguous: UTF-8 or EUC-JP
+@Type{ambiguos-a001, field = {C2Ax: ¢£¥§¨¬}, }
+@Type{ambiguos-a002, field = {C2Bx: °±¶÷}, }
+@Type{ambiguos-a005, field = {CEAx: ΡΣΤΥΦΧΨΩ}, }
+@Type{ambiguos-a006, field = {CEBx: αβγδεζηθικλμνξο}, }
+@Type{ambiguos-a007, field = {D0Ax: СТУФХЦЧШЩЪЫЬЭЮЯ}, }
+@Type{ambiguos-a008, field = {D0Bx: абвгдежзийклмноп}, }
+@Type{ambiguos-a009, field = {佳人 大声 亡失 対価 幼女 帰任 信仰 伴侶 山岳 年俸 平常 延伸 鷲鷹}, }
+@Type{ambiguos-a011, field = {F0A3B3BE: 𣳾}, }
+@Type{ambiguos-a012, field = {F0A5B6A1: 𥶡}, }
+@Type{ambiguos-a013, field = {F0A1B6B7: 𡶷}, }
+@Type{ambiguos-a020, field = {ξΩ ΥΦ ®ã ŷЧ Сб άå º°}, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-amb1.bib-euc b/Build/source/texk/ptexenc/tests/enc-amb1.bib-euc
new file mode 100644
index 00000000000..3bc8972903f
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb1.bib-euc
Binary files differ
diff --git a/Build/source/texk/ptexenc/tests/enc-amb1.bib-jis b/Build/source/texk/ptexenc/tests/enc-amb1.bib-jis
new file mode 100644
index 00000000000..05fbc572323
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb1.bib-jis
Binary files differ
diff --git a/Build/source/texk/ptexenc/tests/enc-amb1.bib-sjis b/Build/source/texk/ptexenc/tests/enc-amb1.bib-sjis
new file mode 100644
index 00000000000..3ce0c188f93
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb1.bib-sjis
Binary files differ
diff --git a/Build/source/texk/ptexenc/tests/enc-amb1.bib-sjis-utf8 b/Build/source/texk/ptexenc/tests/enc-amb1.bib-sjis-utf8
new file mode 100644
index 00000000000..c3ffe990a6f
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb1.bib-sjis-utf8
@@ -0,0 +1,5 @@
+% ambiguous: UTF-8 or Shift_JIS
+@Type{ambiguos-a050, field = {菫R菴土}, }
+@Type{ambiguos-a051, field = {隱樞蔵隱壺贈}, }
+@Type{ambiguos-a052, field = {諤晄Φ 謇鍋帥 譏取枚 蝙ら峩 諤懈ぉ}, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-amb1.bib-utf8 b/Build/source/texk/ptexenc/tests/enc-amb1.bib-utf8
new file mode 100644
index 00000000000..07f09b456f3
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb1.bib-utf8
@@ -0,0 +1,5 @@
+% ambiguous: UTF-8 or Shift_JIS
+@Type{ambiguos-a050, field = {係q体y}, }
+@Type{ambiguos-a051, field = {語①誚②}, }
+@Type{ambiguos-a052, field = {思想 打球 明文 垂直 怜悧}, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-amb2.bib-euc-utf8 b/Build/source/texk/ptexenc/tests/enc-amb2.bib-euc-utf8
new file mode 100644
index 00000000000..e7d4a278605
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb2.bib-euc-utf8
@@ -0,0 +1,13 @@
+% ambiguous: EUC-JP or Shift_JIS
+@Type{ambiguos-a100, field = {E0Ax: 燹燿爍爐爛爨爭爬爰爲爻爼爿牀牆}, }
+@Type{ambiguos-a101, field = {E2Ax: 癲癶癸發皀皃皈皋皎皖皓皙皚皰皴}, }
+@Type{ambiguos-a102, field = {E4Ax: 筺笄筍笋筌筅筵筥筴筧筰筱筬筮箝}, }
+@Type{ambiguos-a103, field = {E6Ax: 罅罌罍罎罐网罕罔罘罟罠罨罩罧罸}, }
+@Type{ambiguos-a104, field = {E8Ax: 茵茴茖茲茱荀茹荐荅茯茫茗茘莅莚}, }
+@Type{ambiguos-a105, field = {EAAx: 蝓蝣蝪蠅}, }
+@Type{ambiguos-a106, field = {coffee: 珈琲 獻琥}, }
+@Type{ambiguos-a107, field = {amber: 琥珀 琅珎}, }
+@Type{ambiguos-a108, field = {dotage: 耄碌 稾瘴}, }
+@Type{ambiguos-a109, field = {konjak: 蒟蒻 粤粫}, }
+@Type{ambiguos-a110, field = {rampant: 猖獗 猊獏}, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-amb2.bib-sjis-utf8 b/Build/source/texk/ptexenc/tests/enc-amb2.bib-sjis-utf8
new file mode 100644
index 00000000000..8d99e043d07
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-amb2.bib-sjis-utf8
@@ -0,0 +1,13 @@
+% ambiguous: EUC-JP or Shift_JIS
+@Type{ambiguos-a100, field = {E0Ax: 爍爐爛爨爭爬爰爲爻爼爿牀牆牋牘}, }
+@Type{ambiguos-a101, field = {E2Ax: 筍笋筌筅筵筥筴筧筰筱筬筮箝箘箟}, }
+@Type{ambiguos-a102, field = {E4Ax: 茖茲茱荀茹荐荅茯茫茗茘莅莚莪莟}, }
+@Type{ambiguos-a103, field = {E6Ax: 譯譴譽讀讌讎讒讓讖讙讚谺豁谿豈}, }
+@Type{ambiguos-a104, field = {E8Ax: 陦陲陬隍隘隕隗險隧隱隲隰隴隶隸}, }
+@Type{ambiguos-a105, field = {EAAx: 遙瑤凜熙}, }
+@Type{ambiguos-a106, field = {coffee: 珎瑕 珈琲}, }
+@Type{ambiguos-a107, field = {amber: 琲珮 琥珀}, }
+@Type{ambiguos-a108, field = {dotage: 賽糂 耄碌}, }
+@Type{ambiguos-a109, field = {konjak: 韈韭 蒟蒻}, }
+@Type{ambiguos-a110, field = {rampant: 猴獨 猖獗}, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-euc.bib-utf8 b/Build/source/texk/ptexenc/tests/enc-euc.bib-utf8
new file mode 100644
index 00000000000..5ecaea34bfa
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-euc.bib-utf8
@@ -0,0 +1,5 @@
+@Type{ascii-e001, field = {ABC xyz}, }
+@Type{greek-e001, field = {ΑΒΓ χψω}, }
+@Type{cyrillic-e001, field = {АБВ эюя}, }
+@Type{kana-e001, field = {あいうえお}, }
+@Type{hanzi-e001, field = {一二三四五}, }
diff --git a/Build/source/texk/ptexenc/tests/enc-jis.bib-utf8 b/Build/source/texk/ptexenc/tests/enc-jis.bib-utf8
new file mode 100644
index 00000000000..a53b81bebeb
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-jis.bib-utf8
@@ -0,0 +1,5 @@
+@Type{ascii-j001, field = {ABC xyz}, }
+@Type{greek-j001, field = {ΑΒΓ χψω}, }
+@Type{cyrillic-j001, field = {АБВ эюя}, }
+@Type{kana-j001, field = {あいうえお}, }
+@Type{hanzi-j001, field = {一二三四五}, }
diff --git a/Build/source/texk/ptexenc/tests/enc-sjis.bib-utf8 b/Build/source/texk/ptexenc/tests/enc-sjis.bib-utf8
new file mode 100644
index 00000000000..86068701e3e
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-sjis.bib-utf8
@@ -0,0 +1,5 @@
+@Type{ascii-s001, field = {ABC xyz}, }
+@Type{greek-s001, field = {ΑΒΓ χψω}, }
+@Type{cyrillic-s001, field = {АБВ эюя}, }
+@Type{kana-s001, field = {あいうえお}, }
+@Type{hanzi-s001, field = {一二三四五}, }
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8.bib-euc b/Build/source/texk/ptexenc/tests/enc-utf8.bib-euc
new file mode 100644
index 00000000000..70739acce90
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8.bib-euc
@@ -0,0 +1,6 @@
+@Type{ascii-u001, field = {ABC xyz}, }
+@Type{greek-u001, field = { ֦צ}, }
+@Type{cyrillic-u001, field = { }, }
+@Type{kana-u001, field = {}, }
+@Type{kana-u002, field = {ϥϥХХѥ}, }
+@Type{hanzi-u001, field = {󻰻͸}, }
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8.bib-jis b/Build/source/texk/ptexenc/tests/enc-utf8.bib-jis
new file mode 100644
index 00000000000..ccd52a19c12
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8.bib-jis
@@ -0,0 +1,6 @@
+@Type{ascii-u001, field = {ABC xyz}, }
+@Type{greek-u001, field = {$B&!&"&#(B $B&V&W&X(B}, }
+@Type{cyrillic-u001, field = {$B'!'"'#(B $B'o'p'q(B}, }
+@Type{kana-u001, field = {$B$"$$$&$($*(B}, }
+@Type{kana-u002, field = {$B%O%O%P%P%Q%Q(B}, }
+@Type{hanzi-u001, field = {$B0lFs;0;M8^(B}, }
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8.bib-sjis b/Build/source/texk/ptexenc/tests/enc-utf8.bib-sjis
new file mode 100644
index 00000000000..a601ce1a122
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8.bib-sjis
@@ -0,0 +1,6 @@
+@Type{ascii-u001, field = {ABC xyz}, }
+@Type{greek-u001, field = { ԃՃ}, }
+@Type{cyrillic-u001, field = {@AB }, }
+@Type{kana-u001, field = {}, }
+@Type{kana-u002, field = {nnoopp}, }
+@Type{hanzi-u001, field = {Ol}, }
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8.bib-utf8 b/Build/source/texk/ptexenc/tests/enc-utf8.bib-utf8
new file mode 100644
index 00000000000..4f29e2005ee
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8.bib-utf8
@@ -0,0 +1,6 @@
+@Type{ascii-u001, field = {ABC xyz}, }
+@Type{greek-u001, field = {ΑΒΓ χψω}, }
+@Type{cyrillic-u001, field = {АБВ эюя}, }
+@Type{kana-u001, field = {あいうえお}, }
+@Type{kana-u002, field = {ハハババパパ}, }
+@Type{hanzi-u001, field = {一二三四五}, }
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8a.bib-euc b/Build/source/texk/ptexenc/tests/enc-utf8a.bib-euc
new file mode 100644
index 00000000000..e0be682a04b
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8a.bib-euc
Binary files differ
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8a.bib-jis b/Build/source/texk/ptexenc/tests/enc-utf8a.bib-jis
new file mode 100644
index 00000000000..9567b5dc66b
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8a.bib-jis
Binary files differ
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8a.bib-sjis b/Build/source/texk/ptexenc/tests/enc-utf8a.bib-sjis
new file mode 100644
index 00000000000..d5e88e84c6d
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8a.bib-sjis
Binary files differ
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8a.bib-utf8 b/Build/source/texk/ptexenc/tests/enc-utf8a.bib-utf8
new file mode 100644
index 00000000000..45c98d1c9fd
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8a.bib-utf8
@@ -0,0 +1,6 @@
+% UTF-8 with BOM
+@Type{ascii-v001, field = {ABC xyz}, }
+@Type{ambiguos-v050, field = {係q体y}, }
+@Type{ambiguos-v051, field = {語①誚②}, }
+@Type{ambiguos-v052, field = {思想 打球 明文 垂直 怜悧}, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8b.bib-euc b/Build/source/texk/ptexenc/tests/enc-utf8b.bib-euc
new file mode 100644
index 00000000000..f6c63164ff1
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8b.bib-euc
@@ -0,0 +1,7 @@
+% UTF-8 with BOM
+@Type{ascii-v002, field = {ABC xyz}, }
+@Type{ambiguos-v003, field = {C2Ax: }, }
+@Type{ambiguos-v006, field = {CEBx: ¦æĦŦƦǦȦɦʦ˦̦ͦΦ}, }
+@Type{ambiguos-v008, field = {D0Bx: ѧҧӧԧէ֧ا٧ڧۧܧݧާߧ}, }
+@Type{ambiguos-v009, field = {¿ ˴ в Ľ Ǥ ȼη ǯ ʿ 俭 }, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8b.bib-jis b/Build/source/texk/ptexenc/tests/enc-utf8b.bib-jis
new file mode 100644
index 00000000000..81a4fef1394
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8b.bib-jis
@@ -0,0 +1,7 @@
+% UTF-8 with BOM
+@Type{ascii-v002, field = {ABC xyz}, }
+@Type{ambiguos-v003, field = {C2Ax: $B!q!r!o!x!/"L(B}, }
+@Type{ambiguos-v006, field = {CEBx: $B&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O(B}, }
+@Type{ambiguos-v008, field = {D0Bx: $B'Q'R'S'T'U'V'X'Y'Z'['\']'^'_'`'a(B}, }
+@Type{ambiguos-v009, field = {$B2B?M(B $BBg@<(B $BK4<:(B $BBP2A(B $BMD=w(B $B5"G$(B $B?.6D(B $BH<N7(B $B;33Y(B $BG/Jp(B $BJ?>o(B $B1d?-(B $BOIBk(B}, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8b.bib-sjis b/Build/source/texk/ptexenc/tests/enc-utf8b.bib-sjis
new file mode 100644
index 00000000000..10aa4baeb84
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8b.bib-sjis
@@ -0,0 +1,7 @@
+% UTF-8 with BOM
+@Type{ascii-v002, field = {ABC xyz}, }
+@Type{ambiguos-v003, field = {C2Ax: N}, }
+@Type{ambiguos-v006, field = {CEBx: ƒÃăŃƃǃȃɃʃ˃̃}, }
+@Type{ambiguos-v008, field = {D0Bx: pqrstuwxyz{|}~}, }
+@Type{ambiguos-v009, field = {l 吺 S Ή c AC M Rx N L h}, }
+
diff --git a/Build/source/texk/ptexenc/tests/enc-utf8b.bib-utf8 b/Build/source/texk/ptexenc/tests/enc-utf8b.bib-utf8
new file mode 100644
index 00000000000..1ff4d3f40dd
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/enc-utf8b.bib-utf8
@@ -0,0 +1,7 @@
+% UTF-8 with BOM
+@Type{ascii-v002, field = {ABC xyz}, }
+@Type{ambiguos-v003, field = {C2Ax: ¢£¥§¨¬}, }
+@Type{ambiguos-v006, field = {CEBx: αβγδεζηθικλμνξο}, }
+@Type{ambiguos-v008, field = {D0Bx: абвгдежзийклмноп}, }
+@Type{ambiguos-v009, field = {佳人 大声 亡失 対価 幼女 帰任 信仰 伴侶 山岳 年俸 平常 延伸 鷲鷹}, }
+
diff --git a/Build/source/texk/ptexenc/tests/ptekf-conv.test b/Build/source/texk/ptexenc/tests/ptekf-conv.test
new file mode 100755
index 00000000000..9c496796751
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/ptekf-conv.test
@@ -0,0 +1,77 @@
+#! /bin/sh -vx
+# $Id$
+# Copyright 2024 Japanese TeX Development Community <issue@texjp.org>
+# You may freely use, modify and/or distribute this file.
+
+# Not really a test, just making sure the program executes.
+
+BinDir=${BinDir:-.}
+ExeExt=${ExeExt:-}
+_ptekf=$BinDir/ptekf$ExeExt
+
+TEXMFCNF=$srcdir/../kpathsea
+web2cdir=$srcdir/../web2c
+
+export TEXMFCNF
+
+rm -f ./enc-*.bib.out*
+
+cp $web2cdir/tests/enc-*.bib .
+
+for sfx in amb0 amb1 euc jis sjis utf8 utf8a utf8b; do
+
+ $_ptekf --guess -u ./enc-$sfx.bib
+ diff enc-$sfx.bib.out $srcdir/tests/enc-$sfx.bib-utf8 || exit 1
+ $_ptekf --guess --buffer ./enc-$sfx.bib
+ diff enc-$sfx.bib.out $srcdir/tests/enc-$sfx.bib-utf8 || exit 2
+ if [ $sfx = euc ]; then
+ $_ptekf -E -u ./enc-$sfx.bib
+ diff enc-$sfx.bib.out $srcdir/tests/enc-$sfx.bib-utf8 || exit 3
+ fi
+ if [ $sfx = jis ]; then
+ $_ptekf -J -u ./enc-$sfx.bib
+ diff enc-$sfx.bib.out $srcdir/tests/enc-$sfx.bib-utf8 || exit 4
+ fi
+ if [ $sfx = sjis ]; then
+ $_ptekf -S -u ./enc-$sfx.bib
+ diff enc-$sfx.bib.out $srcdir/tests/enc-$sfx.bib-utf8 || exit 5
+ fi
+
+done
+
+for sfx in amb0 amb1 utf8 utf8a utf8b; do
+
+ $_ptekf -U -b ./enc-$sfx.bib
+ mv enc-$sfx.bib.out enc-$sfx.bib.out-buf
+ diff enc-$sfx.bib.out-buf $srcdir/tests/enc-$sfx.bib-utf8 || exit 11
+ $_ptekf -U -e ./enc-$sfx.bib
+ mv enc-$sfx.bib.out enc-$sfx.bib.out-euc
+ diff enc-$sfx.bib.out-euc $srcdir/tests/enc-$sfx.bib-euc || exit 12
+ $_ptekf -U -j ./enc-$sfx.bib
+ mv enc-$sfx.bib.out enc-$sfx.bib.out-jis
+ diff enc-$sfx.bib.out-jis $srcdir/tests/enc-$sfx.bib-jis || exit 13
+ $_ptekf -U -s ./enc-$sfx.bib
+ mv enc-$sfx.bib.out enc-$sfx.bib.out-sjis
+ diff enc-$sfx.bib.out-sjis $srcdir/tests/enc-$sfx.bib-sjis || exit 14
+
+done
+
+for sfx in amb0 amb2; do
+
+ $_ptekf -E -u ./enc-$sfx.bib
+ diff enc-$sfx.bib.out $srcdir/tests/enc-$sfx.bib-euc-utf8 || exit 21
+ $_ptekf -E --buffer ./enc-$sfx.bib
+ diff enc-$sfx.bib.out $srcdir/tests/enc-$sfx.bib-euc-utf8 || exit 22
+
+done
+
+for sfx in amb1 amb2; do
+
+ cp $web2cdir/tests/enc-$sfx.bib .
+
+ $_ptekf -S -u ./enc-$sfx.bib
+ diff enc-$sfx.bib.out $srcdir/tests/enc-$sfx.bib-sjis-utf8 || exit 23
+ $_ptekf -S --buffer ./enc-$sfx.bib
+ diff enc-$sfx.bib.out $srcdir/tests/enc-$sfx.bib-sjis-utf8 || exit 24
+
+done
diff --git a/Build/source/texk/ptexenc/tests/ptekf-guess.test b/Build/source/texk/ptexenc/tests/ptekf-guess.test
new file mode 100755
index 00000000000..8f3d216a007
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/ptekf-guess.test
@@ -0,0 +1,20 @@
+#! /bin/sh -v
+# $Id$
+# Copyright 2024 Japanese TeX Development Community <issue@texjp.org>
+# You may freely use, modify and/or distribute this file.
+
+# Not really a test, just making sure the program executes.
+
+BinDir=${BinDir:-.}
+ExeExt=${ExeExt:-}
+_ptekf=$BinDir/ptekf$ExeExt
+
+TEXMFCNF=$srcdir/../kpathsea
+web2cdir=$srcdir/../web2c
+bibtexxdir=$srcdir/../bibtex-x
+
+export TEXMFCNF
+
+
+$_ptekf --guess $web2cdir/tests/*.bib || exit 1
+$_ptekf --guess $bibtexxdir/tests/*.bib || exit 2
diff --git a/Build/source/texk/ptexenc/tests/ptekf-smoke.test b/Build/source/texk/ptexenc/tests/ptekf-smoke.test
new file mode 100755
index 00000000000..e33eaee11e0
--- /dev/null
+++ b/Build/source/texk/ptexenc/tests/ptekf-smoke.test
@@ -0,0 +1,14 @@
+#! /bin/sh
+# $Id$
+# Copyright 2024 Japanese TeX Development Community <issue@texjp.org>
+# You may freely use, modify and/or distribute this file.
+
+# Not really a test, just making sure the program executes.
+
+BinDir=${BinDir:-.}
+ExeExt=${ExeExt:-}
+_ptekf=$BinDir/ptekf$ExeExt
+
+$_ptekf --version || exit 1
+echo ''
+$_ptekf --help || exit 2
diff --git a/Build/source/texk/ptexenc/version.ac b/Build/source/texk/ptexenc/version.ac
index cde0d38387c..657885db531 100644
--- a/Build/source/texk/ptexenc/version.ac
+++ b/Build/source/texk/ptexenc/version.ac
@@ -1,5 +1,5 @@
dnl $Id$
-dnl Copyright 2022-2023 Japanese TeX Development Community <issue@texjp.org>
+dnl Copyright 2022-2024 Japanese TeX Development Community <issue@texjp.org>
dnl Copyright 2016-2022 Karl Berry <tex-live@tug.org>
dnl Copyright 2011-2015 Peter Breitenlohner <tex-live@tug.org>
dnl
@@ -11,4 +11,4 @@ dnl Keep package and shared library versions the same;
dnl see kpathsea/version.ac.
dnl
dnl This file is m4-included from configure.ac.
-m4_define([ptexenc_version], [1.4.4/dev])
+m4_define([ptexenc_version], [1.4.5/dev])
diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog
index 674181adcd2..5b4e15fa9e3 100644
--- a/Build/source/texk/web2c/ChangeLog
+++ b/Build/source/texk/web2c/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-01 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
+
+ * tests/enc-utf8.bib, tests/enc-{,e,s}[pu].bbl:
+ Add tests for guess encodings & upBibTeX &
+ Kana (semi)voiced sounds.
+
2023-12-24 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
* tests/fn-generate.perl:
diff --git a/Build/source/texk/web2c/tests/enc-ep.bbl b/Build/source/texk/web2c/tests/enc-ep.bbl
index f297f089e2b..ae8e545a63f 100644
--- a/Build/source/texk/web2c/tests/enc-ep.bbl
+++ b/Build/source/texk/web2c/tests/enc-ep.bbl
@@ -33,6 +33,7 @@
\item
\item
\item
+\item ϥϥХХѥ
\item ֦צ
\item ֦צ
\item ֦צ
diff --git a/Build/source/texk/web2c/tests/enc-eu.bbl b/Build/source/texk/web2c/tests/enc-eu.bbl
index 68a89dd8ff9..295874a613d 100644
--- a/Build/source/texk/web2c/tests/enc-eu.bbl
+++ b/Build/source/texk/web2c/tests/enc-eu.bbl
@@ -41,6 +41,7 @@
\item
\item
\item
+\item ϥϥХХѥ
\item 󻰻͸
\item 󻰻͸
\item 󻰻͸
diff --git a/Build/source/texk/web2c/tests/enc-p.bbl b/Build/source/texk/web2c/tests/enc-p.bbl
index d8cec92c192..499f11afd91 100644
--- a/Build/source/texk/web2c/tests/enc-p.bbl
+++ b/Build/source/texk/web2c/tests/enc-p.bbl
@@ -39,6 +39,7 @@
\item あいうえお
\item あいうえお
\item あいうえお
+\item ハハババパパ
\item ΑΒΓ χψω
\item ΑΒΓ χψω
\item ΑΒΓ χψω
diff --git a/Build/source/texk/web2c/tests/enc-sp.bbl b/Build/source/texk/web2c/tests/enc-sp.bbl
index 1512fe324a2..fb04c6d7bd8 100644
--- a/Build/source/texk/web2c/tests/enc-sp.bbl
+++ b/Build/source/texk/web2c/tests/enc-sp.bbl
@@ -21,6 +21,7 @@
\item
\item
\item
+\item nnoopp
\item ԃՃ
\item ԃՃ
\item ԃՃ
diff --git a/Build/source/texk/web2c/tests/enc-su.bbl b/Build/source/texk/web2c/tests/enc-su.bbl
index a3cfb67084d..77d51e38fc0 100644
--- a/Build/source/texk/web2c/tests/enc-su.bbl
+++ b/Build/source/texk/web2c/tests/enc-su.bbl
Binary files differ
diff --git a/Build/source/texk/web2c/tests/enc-u.bbl b/Build/source/texk/web2c/tests/enc-u.bbl
index 278cecf597d..c8aef409214 100644
--- a/Build/source/texk/web2c/tests/enc-u.bbl
+++ b/Build/source/texk/web2c/tests/enc-u.bbl
@@ -48,6 +48,7 @@
\item あいうえお
\item あいうえお
\item あいうえお
+\item ハハババパパ
\item 一二三四五
\item 一二三四五
\item 一二三四五
diff --git a/Build/source/texk/web2c/tests/enc-up.bbl b/Build/source/texk/web2c/tests/enc-up.bbl
index 7b943d21656..605beb80fae 100644
--- a/Build/source/texk/web2c/tests/enc-up.bbl
+++ b/Build/source/texk/web2c/tests/enc-up.bbl
@@ -19,6 +19,7 @@
\item F0A5B6A1: ^^f0^^a5^^b6^^a1
\item あいうえお
\item あいうえお
+\item ハハババパパ
\item ΑΒΓ χψω
\item ΑΒΓ χψω
\item ξΩ ΥΦ ^^c2^^ae^^c3^^a3 ^^c5^^b7Ч Сб ^^ce^^ac^^c3^^a5 ^^c2^^ba°
diff --git a/Build/source/texk/web2c/tests/enc-utf8.bib b/Build/source/texk/web2c/tests/enc-utf8.bib
index 483754464cb..013d9edecf6 100644
--- a/Build/source/texk/web2c/tests/enc-utf8.bib
+++ b/Build/source/texk/web2c/tests/enc-utf8.bib
@@ -2,4 +2,5 @@
@Type{greek-u001, field = {ΑΒΓ χψω}, }
@Type{cyrillic-u001, field = {АБВ эюя}, }
@Type{kana-u001, field = {あいうえお}, }
+@Type{kana-u002, field = {ハハババパパ}, }
@Type{hanzi-u001, field = {一二三四五}, }
diff --git a/Build/source/texk/web2c/tests/enc-uu.bbl b/Build/source/texk/web2c/tests/enc-uu.bbl
index 8cfb358ed2d..7df6264de50 100644
--- a/Build/source/texk/web2c/tests/enc-uu.bbl
+++ b/Build/source/texk/web2c/tests/enc-uu.bbl
@@ -24,6 +24,7 @@
\item АБВ эюя
\item あいうえお
\item あいうえお
+\item ハハババパパ
\item 一二三四五
\item 一二三四五
\item