summaryrefslogtreecommitdiff
path: root/macros/generic
diff options
context:
space:
mode:
Diffstat (limited to 'macros/generic')
-rw-r--r--macros/generic/ifptex/LICENSE2
-rw-r--r--macros/generic/ifptex/README-ja.md12
-rw-r--r--macros/generic/ifptex/README.md13
-rw-r--r--macros/generic/ifptex/ifptex.sty155
-rw-r--r--macros/generic/ifptex/ifuptex.sty4
5 files changed, 141 insertions, 45 deletions
diff --git a/macros/generic/ifptex/LICENSE b/macros/generic/ifptex/LICENSE
index ead3a3702e..df92641d58 100644
--- a/macros/generic/ifptex/LICENSE
+++ b/macros/generic/ifptex/LICENSE
@@ -1,6 +1,6 @@
The MIT License
-Copyright (c) 2008-2021 Takayuki YATO (aka. "ZR")
+Copyright (c) 2008-2022 Takayuki YATO (aka. "ZR")
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/macros/generic/ifptex/README-ja.md b/macros/generic/ifptex/README-ja.md
index 49fc486c06..591f746ea9 100644
--- a/macros/generic/ifptex/README-ja.md
+++ b/macros/generic/ifptex/README-ja.md
@@ -66,6 +66,15 @@ LaTeX の場合:
* `\RequirepTeXng`
`\ifpTeXng` 不成立の場合はエラーを出す。
※一応 `\RequireStrictpTeXng` もある。
+ * `\upTeXguessedversion` [mathchardef-トークン]
+ upTeX のバージョンの推測値(を百倍した整数値)。
+ ※1.23版以降では常に正確なバージョン値が得られる。
+ ※upTeX 以外のエンジンでは 0 になる。
+ * `\RequireupTeXAtLeast{<要求値>}`
+ `\upTeXguessedversion` の値が要求値より小さい場合はエラーを出す。
+ * `\RequireNativeupTeXAtLeast{<要求値>}`
+ `\upTeXguessedversion` の値が要求値より小さいまたは `\ifnativeupTeX`
+ が不成立の場合はエラーを出す。
ifuptex パッケージ ― ifptex の別名
@@ -88,6 +97,9 @@ LaTeX の場合:
更新履歴
--------
+ * Version 2.2 〈2022/04/03〉
+ - `\upTeXguessedversion` を正式にサポート。
+ - `\Require(Native)upTeXAtLeast` を追加。
* Version 2.1 〈2021/07/01〉
- 将来の版の pTeX に対応させる。
- とある非公開機能を削除。
diff --git a/macros/generic/ifptex/README.md b/macros/generic/ifptex/README.md
index 4b09b0baff..9f09ad8d85 100644
--- a/macros/generic/ifptex/README.md
+++ b/macros/generic/ifptex/README.md
@@ -68,6 +68,16 @@ NB: Here “e-TeX-ness” is not considered.
Issues an error if `\ifnativeupTeX` fails.
* `\RequirepTeXng`
Issues an error if `\ifpTeXng` fails.
+ * `\upTeXguessedversion` [mathchardef-token]
+ The guessed value of upTeX version; given as a 100-folded integer.
+ NB. On version 1.23 or later, the value is correct.
+ NB. On a non-upTeX engine, the value is zero.
+ * `\RequireupTeXAtLeast{<required>}`
+ Issues an error if `\upTeXguessedversion` is smaller than the given
+ required value.
+ * `\RequireNativeupTeXAtLeast{<required>}`
+ Issues an error either if `\upTeXguessedversion` is smaller than
+ the given required value or if `\ifnativeupTeX` fails.
ifuptex Package ― Alias of ifptex
@@ -94,6 +104,9 @@ Just the same as the ifptex package.
Revision History
----------------
+ * Version 2.2 〈2022/04/03〉
+ - Officialy support `\upTeXguessedversion`.
+ - Add `\Require(Native)upTeXAtLeast`.
* Version 2.1 〈2021/07/01〉
- Adjust for the future version of pTeX.
- Drop an undocumented feature.
diff --git a/macros/generic/ifptex/ifptex.sty b/macros/generic/ifptex/ifptex.sty
index a3e63d8d5d..604081118e 100644
--- a/macros/generic/ifptex/ifptex.sty
+++ b/macros/generic/ifptex/ifptex.sty
@@ -1,7 +1,7 @@
%%
%% This is file 'ifptex.sty'.
%%
-%% Copyright (c) 2008-2021 Takayuki YATO (aka. "ZR")
+%% Copyright (c) 2008-2022 Takayuki YATO (aka. "ZR")
%% GitHub: https://github.com/zr-tex8r
%% Twitter: @zr_tex8r
%%
@@ -70,7 +70,7 @@
%% package declaration
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{ifptex}[2021/07/01 v2.1 pTeX checker]
+\ProvidesPackage{ifptex}[2022/04/03 v2.2 pTeX checker]
\def\bxip@pkgname{ifptex}
%% packages
@@ -138,7 +138,7 @@
% do a hard stop
\batchmode\read-1to\bxip@tmpa
#3}
-\gdef\bxip@err@required#1{\bxip@Require\iftrue{#1}\fi}
+\gdef\bxip@err@required#1{\bxip@Require\iffalse{#1}\fi}
%% \bxip@protected
\let\bxip@protected\protected
@@ -149,17 +149,41 @@
%--------------------------------------- guess version
-%% \bxip@uptex@new@version
-\global\mathchardef\bxip@uptex@new@version=19
-
%%<+> \upTeXguessedversion
-% NB: The value of \upTeXguessedversion on pTeX is zero.
-\global\mathchardef\upTeXguessedversion=0
-\bxip@test@primitive\ptexversion\ifbxip@ok %<*version>
-% If \(u)ptexversion is supported...
-
- % get version from \uptexversion/revision
- \bxip@test@primitive\uptexversion\ifbxip@ok
+% A \mathchardef constant that represents the guessed version
+% of the upTeX engine. (123 means version 1.23.)
+% - The version 1.23 or later has primitive \uptexversion/revision,
+% from which the correct version value can be obtained.
+% - For the older versions, the version value is guessed from various
+% features of the engine, and the minimum possible values is stored
+% to \upTeXguessedversion. (For the versions earlier than v0.06,
+% however, \upTeXguessedversion is set to 1.)
+% - If the engine is not regarded as upTeX (or its derivative), then
+% \upTeXguessedversion is set to zero.
+
+% [Development history of upTeX until version 1.23]
+% Version 1.23 [2018-02-24] Introduce \uptexversion/revision
+% Version 1.22 [2017-01-15] Adopt blocks of Unicode v9.0.0
+% Version 1.21 [2016-02-20] Adopt blocks of Unicode v8.0.0
+% Version 1.20 [2014-12-29] Adopt blocks of Unicode v7.0.0
+% Version 1.11 [2012-09-21] (Fix bug on \meaning\kchardef)
+% Version 1.10 [2012-04-29] Adopt blocks of Unicode v6.1.0
+% Version 1.00 [2012-01-15] Adopt blocks of Unicode v6.0.0
+% Version 0.30 [2010-04-10] (No observable changes)
+% Version 0.29 [2010-01-31] Adopt blocks of Unicode v5.2.0
+% Version 0.28 [2009-08-23] (Fix bug on \if test)
+% Version 0.21 [2008-03-13] (Fix bug on \uppercase)
+% Version 0.19 [2007-12-26] Introduce \forcecjktoken
+% Version 0.12 [2007-08-25] Adjust newline after hangul
+% Version 0.11 [2007-08-07] (Fix bug on \jcharwidowpenalty)
+% Version 0.10 [2007-07-28] Introduce \kchar and \kchardef
+% Version 0.06 [2007-04-15] Introduce \enable/disablecjktoken
+% Version 0.00 [2007-01-27] Initial version
+
+\global\let\upTeXguessedversion\relax
+\bxip@test@primitive\uptexversion\ifbxip@ok
+ % If the engine has \uptexversion, it is upTeX of >= v1.23.
+ % The exact version can be known from \uptexversion/revision.
\bxip@test@primitive\uptexrevision\ifbxip@ok
\def\bxip@tmpa#1#2#3#4\relax{%
\chardef\bxip@tmpa=0\relax
@@ -171,29 +195,65 @@
\multiply\bxip@cnta100\relax
\advance\bxip@cnta\bxip@tmpa
\global\mathchardef\upTeXguessedversion=\bxip@cnta
- \fi\fi
-
-\else %<*!version>
-% If \(u)ptexversion is not supported...
-
-% if \ucs exists, then gv >= 1
-\bxip@test@primitive\ucs\ifbxip@ok
- \global\mathchardef\upTeXguessedversion=1
- % if \enablecjktoken exists, then gv >= 6
- \bxip@test@primitive\enablecjktoken\ifbxip@ok
- \global\mathchardef\upTeXguessedversion=6
- % if \kchar exists, then gv >= 10
- \bxip@test@primitive\kchar\ifbxip@ok
- \global\mathchardef\upTeXguessedversion=10
- % if \forcecjktoken exists, then gv >= 19
- \bxip@test@primitive\forcecjktoken\ifbxip@ok
- \global\mathchardef\upTeXguessedversion=19
- \fi
- \fi
+ \else % UNEXPECTED CASE
+ \global\mathchardef\upTeXguessedversion=0
\fi
\fi
-
-\fi %</version>
+\ifx\upTeXguessedversion\relax % still unknown
+ \bxip@test@primitive\ptexversion\ifbxip@ok
+ % If the engine has \ptexversion but not \uptexversion,
+ % it is a real pTeX.
+ \global\mathchardef\upTeXguessedversion=0
+ % Note: The recent version of pTeX has primitive \ucs.
+ \fi
+\fi
+\ifx\upTeXguessedversion\relax % still unknown
+ \bxip@test@primitive\ucs\ifbxip@ok\else
+ % If the engine does not have \ucs, it is pTeX.
+ \global\mathchardef\upTeXguessedversion=0
+ \fi
+\fi
+% Here if \upTeXguessedversion is not zero, it is upTeX definitely.
+\ifx\upTeXguessedversion\relax % still unknown
+ % If \uptexversion is missing, I guess the version according to
+ % the way the Unicode blocks are divided.
+ \def\bxip@tmpa#1#2{% check if #1 and #2 belong to different blocks
+ \bxip@true{ifbxip@ok}\begingroup
+ \kcatcode#1=16\kcatcode#2=17\relax
+ \ifnum\kcatcode#1=17 \aftergroup\bxip@tmpb \fi
+ \endgroup}
+ \def\bxip@tmpb{\bxip@false{ifbxip@ok}}
+ \bxip@tmpa{"1C50}{"1C80}\ifbxip@ok
+ \global\mathchardef\upTeXguessedversion=122
+ \else\bxip@tmpa{"AB30}{"AB70}\ifbxip@ok
+ \global\mathchardef\upTeXguessedversion=121
+ \else\bxip@tmpa{"1A20}{"1AB0}\ifbxip@ok
+ \global\mathchardef\upTeXguessedversion=120
+ \else\bxip@tmpa{"840}{"8A0}\ifbxip@ok
+ \global\mathchardef\upTeXguessedversion=110
+ \else\bxip@tmpa{"800}{"840}\ifbxip@ok
+ \global\mathchardef\upTeXguessedversion=100
+ \else\bxip@tmpa{"7C0}{"800}\ifbxip@ok
+ \global\mathchardef\upTeXguessedversion=29
+ \else
+ \global\mathchardef\upTeXguessedversion=1
+ \fi\fi\fi\fi\fi\fi
+\fi
+% I guess the more correct version according to the existence
+% and/or the behavior of the specific primitives.
+\ifnum\upTeXguessedversion=1 % v0.00-0.28
+ \bxip@test@primitive\forcecjktoken\ifbxip@ok
+ % \forcecjktoken exists
+ \global\mathchardef\upTeXguessedversion=19
+ \else\bxip@test@primitive\kchar\ifbxip@ok
+ % \kchar exists
+ \global\mathchardef\upTeXguessedversion=10
+ \else\bxip@test@primitive\enablecjktoken\ifbxip@ok
+ % \enablecjktoken exists
+ \global\mathchardef\upTeXguessedversion=6
+ % else \upTeXguessedversion=1 (v0.00-0.05)
+ \fi\fi\fi
+\fi
%--------------------------------------- public stuffs
% Note:
@@ -278,6 +338,20 @@
\bxip@protected\gdef\RequireStrictpTeXng{%
\bxip@Require\ifstrictpTeXng{pTeX-ng}\fi}
+%%<+> \RequireupTeXAtLeast{<min_version>}
+\bxip@protected\gdef\RequireupTeXAtLeast#1{%
+ \ifupTeX
+ \bxip@check@version\upTeXguessedversion{#1}{upTeX}%
+ \else \bxip@err@required{upTeX}%
+ \fi}
+
+%%<+> \RequireNativeupTeXAtLeast{<min_version>}
+\bxip@protected\gdef\RequireNativeupTeXAtLeast#1{%
+ \ifnativeupTeX
+ \bxip@check@version\upTeXguessedversion{#1}{upTeX in Unicode}%
+ \else \bxip@err@required{upTeX in Unicode}%
+ \fi}
+
%--------------------------------------- deprecated stuffs
%%<+>D \ifNativeupTeX == \ifnativeupTeX
@@ -285,6 +359,9 @@
%%<+>D \RequirenativeupTeX == \RequireNativeupTeX
\gdef\RequirenativeupTeX{\RequireNativeupTeX}
+%% \bxip@uptex@new@version
+\global\mathchardef\bxip@uptex@new@version=19
+
%%<+>D \ifnewupTeX
\global\bxip@false{ifnewupTeX}
\ifnum\upTeXguessedversion<\bxip@uptex@new@version\else
@@ -295,19 +372,13 @@
\gdef\RequireNewupTeX{%
\bxip@with@default\bxip@uptex@new@version\bxip@require@new@uptex@a}
\gdef\bxip@require@new@uptex@a[#1]{%
- \ifupTeX
- \bxip@check@version\upTeXguessedversion{#1}{upTeX}%
- \else \bxip@err@required{upTeX}%
- \fi}
+ \RequireupTeXAtLeast{#1}}
%%<+>D \RequireNativeNewupTeX
\gdef\RequireNativeNewupTeX{%
\bxip@with@default\bxip@uptex@new@version\bxip@require@new@uptex@b}
\gdef\bxip@require@new@uptex@b[#1]{%
- \ifnativeupTeX
- \bxip@check@version\upTeXguessedversion{#1}{upTeX in Unicode}%
- \else \bxip@err@required{upTeX in Unicode}%
- \fi}
+ \RequireNativeupTeXAtLeast{#1}}
%--------------------------------------- all done
\endgroup
diff --git a/macros/generic/ifptex/ifuptex.sty b/macros/generic/ifptex/ifuptex.sty
index 0489b25eb7..989c576782 100644
--- a/macros/generic/ifptex/ifuptex.sty
+++ b/macros/generic/ifptex/ifuptex.sty
@@ -1,7 +1,7 @@
%%
%% This is file 'ifuptex.sty'.
%%
-%% Copyright (c) 2008-2021 Takayuki YATO (aka. "ZR")
+%% Copyright (c) 2008-2022 Takayuki YATO (aka. "ZR")
%% GitHub: https://github.com/zr-tex8r
%% Twitter: @zr_tex8r
%%
@@ -52,7 +52,7 @@
%% package declaration
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{ifuptex}[2021/07/01 v2.1 pTeX checker]
+\ProvidesPackage{ifuptex}[2022/04/03 v2.2 pTeX checker]
%% load ifptex
\bxip@input