[latex3-commits] [git/LaTeX3-latex3-iftex] master: use \begingroup \expandafter construct instead of \ifnum to avoid = catcode issues (f8412a3)

David Carlisle d.p.carlisle at gmail.com
Fri Nov 8 01:20:22 CET 2019


Repository : https://github.com/latex3/iftex
On branch  : master
Link       : https://github.com/latex3/iftex/commit/f8412a38cf16ea30d248a27935eda67cd4f9b142

>---------------------------------------------------------------

commit f8412a38cf16ea30d248a27935eda67cd4f9b142
Author: David Carlisle <d.p.carlisle at gmail.com>
Date:   Fri Nov 8 00:20:22 2019 +0000

    use \begingroup \expandafter construct instead of \ifnum to avoid = catcode issues


>---------------------------------------------------------------

f8412a38cf16ea30d248a27935eda67cd4f9b142
 iftex.sty | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/iftex.sty b/iftex.sty
index 19df1d3..8ee4a0f 100644
--- a/iftex.sty
+++ b/iftex.sty
@@ -54,7 +54,8 @@
 
 
 % eTeX \protected if available.
-\ifnum\ifx\protected\@undefined 1 \else\ifx\protected\relax 1 \else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname protected\endcsname\relax
   \let\IFTEX at protected\relax
 \else
   \let\IFTEX at protected\protected
@@ -68,7 +69,7 @@
   \catcode41 12 % )
   \catcode44 12 % ,
   \catcode46 12 % .
-  \ifnum\ifx\directlua\@undefined 1\else\ifx\directlua\relax 1\else 0\fi\fi=1 \else
+  \expandafter\ifx\csname directlua\endcsname\relax\else
     \directlua{tex.enableprimitives("IFTEX@", {"detokenize","protected"})}
   \fi
   }
@@ -99,7 +100,8 @@
   \csname if#2\endcsname}
 
 % etex (should always be true in latex based formats)
-\ifnum\ifx\numexpr\@undefined 1\else\ifx\numexpr\relax 1\else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname numexpr\endcsname\relax
   \IFTEX at let{etex}{false}
 \else
   \IFTEX at let{etex}{true}
@@ -108,7 +110,8 @@
 
 % pdftex (including in dvi mode)
 \IFTEX at let{IFTEX at savedpdftex}{pdftex}
-\ifnum\ifx\pdftexversion\@undefined 1\else\ifx\pdftexversion\relax 1\else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname pdftexversion\endcsname\relax
   \IFTEX at let{pdftex}{false}
 \else
   \IFTEX at let{pdftex}{true}
@@ -116,7 +119,8 @@
 \IFTEX at let{PDFTeX}{pdftex}
 
 % xetex
-\ifnum\ifx\XeTeXrevision\@undefined 1\else\ifx\XeTeXrevision\relax 1\else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname XeTeXrevision\endcsname\relax
   \IFTEX at let{xetex}{false}
 \else
   \IFTEX at let{xetex}{true}
@@ -125,7 +129,8 @@
 
 
 % luatex (including luahbtex)
-\ifnum\ifx\directlua\@undefined 1\else\ifx\directlua\relax 1\else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname directlua\endcsname\relax
   \IFTEX at let{luatex}{false}
 \else
   \IFTEX at let{luatex}{true}
@@ -137,7 +142,8 @@
 % Use luaharfbuzz test rather than status.luatex_engine=="luahbtex"
 % for issue #2.
 \IFTEX at let{luahbtex}{false}
-\ifnum\ifx\directlua\@undefined 1\else\ifx\directlua\relax 1\else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname directlua\endcsname\relax
 \else
   \directlua{\IFTEX at detokenize{
    if(pcall(require, 'luaharfbuzz')) then
@@ -150,7 +156,8 @@
 
 
 % ptex (including all variants)
-\ifnum\ifx\kanjiskip\@undefined 1\else\ifx\kanjiskip\relax 1\else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname kanjiskip\endcsname\relax
   \IFTEX at let{ptex}{false}
 \else
   \IFTEX at let{ptex}{true}
@@ -166,7 +173,8 @@
 \IFTEX at let{upTeX}{uptex}
 
 % ptex-ng
-\ifnum\ifx\ngbanner\@undefined 1\else\ifx\ngbanner\relax 1\else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname ngbanner\endcsname\relax
   \IFTEX at let{ptexng}{false}
 \else
   \IFTEX at let{ptexng}{true}
@@ -175,7 +183,8 @@
 
 % vtex
 \IFTEX at let{IFTEX at savedVTeX}{VTeX}
-\ifnum\ifx\VTeXversion\@undefined 1\else\ifx\VTeXversion\relax 1\else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname VTeXversion\endcsname\relax
   \IFTEX at let{vtex}{false}
 \else
   \IFTEX at let{vtex}{true}
@@ -185,7 +194,8 @@
 % aleph
 \IFTEX at let{alephtex}{false}
 \ifptex\else
-\ifnum\ifx\omathchardef\@undefined 1\else\ifx\omathchardef\relax 1\else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname omathchardef\endcsname\relax
 \else
   \IFTEX at let{alephtex}{true}
 \fi
@@ -194,14 +204,14 @@
 
 
 % tutex (LuaTeX or XeTeX)
-\ifnum\ifx\Umathchardef\@undefined 1\else\ifx\Umathchardef\relax 1\else 0\fi\fi=1 %
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname Umathchardef\endcsname\relax
   \IFTEX at let{tutex}{false}
 \else
   \IFTEX at let{tutex}{true}
 \fi
 \IFTEX at let{TUTeX}{tutex}
 
-
 % Output mode 
 % declare with as if with \newif
 \def\pdftrue{\let\ifpdf\iftrue}





More information about the latex3-commits mailing list