diff options
author | Karl Berry <karl@freefriends.org> | 2017-05-04 22:14:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-05-04 22:14:01 +0000 |
commit | 673a8d0f7aca9c451d1a2e325e8479824b1a0df2 (patch) | |
tree | c7c963103e3a24f5b336a5cea25b9e80ea436ebb /Master/texmf-dist/tex/generic/ifptex/ifptex.sty | |
parent | 7026f62c118b13c173024f7a2748d1088fd48779 (diff) |
ifptex (4may17)
git-svn-id: svn://tug.org/texlive/trunk@44194 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/ifptex/ifptex.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/ifptex/ifptex.sty | 224 |
1 files changed, 224 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/ifptex/ifptex.sty b/Master/texmf-dist/tex/generic/ifptex/ifptex.sty new file mode 100644 index 00000000000..75273980832 --- /dev/null +++ b/Master/texmf-dist/tex/generic/ifptex/ifptex.sty @@ -0,0 +1,224 @@ +%% +%% This is file 'ifptex.sty'. +%% +%% Copyright (c) 2017 Takayuki YATO (aka. "ZR") +%% GitHub: https://github.com/zr-tex8r +%% Twitter: @zr_tex8r +%% +%% This package is distributed under the MIT License. +%% +% +%% avoid multiple loading +\csname\if11bxipIfptexLoaded\fi\endcsname +%% code guards +\edef\x{% +\catcode32=\the\catcode32% +\catcode33=\the\catcode33% +\catcode35=\the\catcode35% +\catcode42=\the\catcode42% +\catcode60=\the\catcode60% +\catcode62=\the\catcode62% +\catcode64=\the\catcode64% +\catcode91=\the\catcode91% +\catcode93=\the\catcode93% +\relax} +\catcode32=10\relax +\catcode33=11 %<"> +\catcode35=6 %<#> +\catcode42=12 %<*> +\catcode60=12 %<<> +\catcode62=12 %<>> +\catcode64=11 %<@> +\catcode91=12 %<[> +\catcode93=12 %<]> +\edef\bxip@restore@codes{\x + \noexpand\let\noexpand\bxip@restore@codes\relax} +\def\bxipIfptexLoaded{\endinput} + +%% check for LaTeX +\ifx\RequirePackage\@undefined %<*!LaTeX> + \let\bxip@latex=f + \long\def\x#1\ProvidesPackage#2[#3]{% + \immediate\write-1{Package: #2 #3}} + \expandafter\x +\else %<*LaTeX> + \let\bxip@latex=t \let\x\relax +\fi %</LaTeX> + +%% package declaration +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{ifptex}[2017/05/04 v1.1-pre pTeX checker] + +%% enter the big group +\begingroup + +%--------------------------------------- helpers + +%% \bxip@csletcs{<csnameA>}{<csnameB>} +\def\bxip@csletcs#1#2{% + \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname} +%% \bxip@true{<csname>} +\def\bxip@true#1{% + \expandafter\let\csname#1\endcsname\iftrue} +%% \bxip@false{<csname>} +\def\bxip@false#1{% + \expandafter\let\csname#1\endcsname\iffalse} + +%% switches +\bxip@false{ifbxip@ok} + +%% \bxip@test@primitive\CS +\def\bxip@test@primitive#1{% + \edef\bxip@tmpa{\string#1}\edef\bxip@tmpb{\meaning#1}% + \ifx\bxip@tmpa\bxip@tmpb \bxip@true{ifbxip@ok}% + \else \bxip@false{ifbxip@ok}% + \fi} + +%% \bxip@with@default{<arg>}\CS +\gdef\bxip@with@default#1#2{% + \def\bxip@tmpa{#2}\def\bxip@tmpb{#2[#1]}% + \futurelet\bxip@tok\bxip@with@default@a} +\gdef\bxip@with@default@a{% + \ifx[\bxip@tok\expandafter\bxip@tmpa%] + \else \expandafter\bxip@tmpb + \fi} + +%% \bxip@check@version{<current>}{<required>}{<label>} +\global\countdef\bxip@cnta=255 +\gdef\bxip@check@version#1#2#3{% + \ifnum#1<#2\relax + \begingroup + \bxip@cnta=#2\relax \advance\bxip@cnta100000\relax + \expandafter\bxip@check@version@a\the\bxip@cnta\relax{#3}% + \endgroup + \fi} +\gdef\bxip@check@version@a#1#2#3#4#5#6\relax#7{% + \bxip@err@required{#7 v.>=\number#2#3#4.#5#6}} + +%% \bxip@err@required{<string>} +% NB: Now the same style as in ifxetex is used. +\gdef\bxip@err@required#1{% + \begingroup + \errorcontextlines=-1\relax + \newlinechar=10\relax + \errmessage{^^J + ********************************************^^J + * #1 is required to compile this document.^^J + * Sorry!^^J + ********************************************}% + \endgroup} + +%--------------------------------------- guess version + +%% \bxip@uptex@new@version +\global\mathchardef\bxip@uptex@new@version=19 + +%%<+> \upTeXguessedversion +\global\mathchardef\upTeXguessedversion=0 +% 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 + \fi +\fi + +%--------------------------------------- public stuffs + +%%<+> \ifpTeX +\global\bxip@false{ifpTeX} +\bxip@test@primitive\kanjiskip\ifbxip@ok + \global\bxip@true{ifpTeX} +\fi +%%<+> \ifptex == \ifpTeX +\global\bxip@csletcs{ifptex}{ifpTeX} + +%%<+> \ifupTeX +\global\bxip@false{ifupTeX} +%%<+> \ifnativeupTeX +\global\bxip@false{ifnativeupTeX} +\ifnum\upTeXguessedversion>0 + \global\bxip@true{ifupTeX} + % native-ness check + \ifnum\ucs"3000="3000 \global\bxip@true{ifnativeupTeX}\fi +\fi +%%<+> \ifuptex == \ifupTeX +\global\bxip@csletcs{ifuptex}{ifupTeX} + +%%<+> \ifpTeXng +\global\bxip@false{ifpTeXng} +\bxip@test@primitive\ngbanner\ifbxip@ok + \global\bxip@true{ifpTeXng} +\fi +%%<+> \ifptexng == \ifpTeXng +\global\bxip@csletcs{ifptexng}{ifpTeXng} + +%%<+> \ifstrictpTeX +\global\bxip@false{ifstrictpTeX} +\ifpTeX \ifupTeX\else + \global\bxip@true{ifstrictpTeX} +\fi\fi +%%<+> \ifstrictptex == \ifstrictpTeX +\global\bxip@csletcs{ifstrictptex}{ifstrictpTeX} + +%%<+> \RequirepTeX +\gdef\RequirepTeX{% + \ifpTeX\else \bxip@err@required{(u)pTeX}\fi} +%%<+> \RequireStrictpTeX +\gdef\RequireStrictpTeX{% + \ifstrictpTeX\else \bxip@err@required{pTeX (not upTeX)}\fi} +%%<+> \RequireupTeX +\gdef\RequireupTeX{% + \ifupTeX\else \bxip@err@required{upTeX}\fi} +%%<+> \RequireNativeupTeX +\gdef\RequireNativeupTeX{% + \ifnativeupTeX\else \bxip@err@required{upTeX in Unicode}\fi} +%%<+> \RequirepTeXng +\gdef\RequirepTeXng{% + \ifpTeXng\else \bxip@err@required{pTeX-ng}\fi} + +%--------------------------------------- deprecated stuffs + +%%<+>D \ifNativeupTeX == \ifnativeupTeX +\global\bxip@csletcs{ifNativeupTeX}{ifnativeupTeX} +%%<+>D \RequirenativeupTeX == \RequireNativeupTeX +\gdef\RequirenativeupTeX{\RequireNativeupTeX} + +%%<+>D \ifnewupTeX +\global\bxip@false{ifnewupTeX} +\ifnum\upTeXguessedversion<\bxip@uptex@new@version\else + \global\bxip@true{ifnewupTeX} +\fi + +%%<+>D \RequireNewupTeX +\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} + +%%<+>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} + +%--------------------------------------- all done +\endgroup +\bxip@restore@codes +\endinput +%% EOF |