eplain[56] U trunk/xeplain.tex: iftex.sty has replaced ifpdf.sty

commits+karl at tug.org commits+karl at tug.org
Mon Oct 3 03:21:28 CEST 2022


Revision: 56
          http://tug.org/svn/eplain?view=revision&revision=56
Author:   karl
Date:     2022-10-03 03:21:28 +0200 (Mon, 03 Oct 2022)
Log Message:
-----------
iftex.sty has replaced ifpdf.sty upstream, so follow suit

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/Makefile
    trunk/demo/lscommnt.pdf
    trunk/demo/xhyper.pdf
    trunk/doc/userdef.texi
    trunk/util/mkdist-merge
    trunk/xeplain.tex

Added Paths:
-----------
    trunk/iftex.sty

Removed Paths:
-------------
    trunk/ifpdf.sty

Property Changed:
----------------
    trunk/util/mkdist-merge
    trunk/xeplain.tex

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2022-10-03 00:49:11 UTC (rev 55)
+++ trunk/ChangeLog	2022-10-03 01:21:28 UTC (rev 56)
@@ -1,5 +1,15 @@
 2022-10-02  Karl Berry  <karl at freefriends.org>
 
+	* iftex.sty: new file.
+	* ifpdf.sty: remove.
+	* util/mkdist-merge: ifpdf.sty -> iftex.sty.
+	* xeplain.tex: ifpdf.sty -> iftex.sty.
+	* doc/userdef.texi (Checking for PDF output): now using iftex.sty;
+	update description.
+	* Makefile (sources): now iftex.sty.
+
+2022-10-02  Karl Berry  <karl at freefriends.org>
+
 	* README: update urls, mention miniltx and optex.
 	* doc/userdef.texi (Loading LaTeX packages): mention that
 	miniltx.tex can usually be used on its own, without Eplain.

Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2022-10-03 00:49:11 UTC (rev 55)
+++ trunk/Makefile	2022-10-03 01:21:28 UTC (rev 56)
@@ -5,9 +5,9 @@
 dist_name   = eplain-$(version)
 
 # Categories of the files in the source tree.
-sources     = arrow.tex btxmac.tex ifpdf.sty path.sty texnames.sty xeplain.tex
+sources     = arrow.tex btxmac.tex iftex.sty path.sty texnames.sty xeplain.tex
 support     = Makefile PROJECTS util/mkdist-*
-manuals     = $(patsubst %,doc/%,Makefile *.texi texinfo.tex)
+manuals     = $(patsubst %,doc/%,Makefile *.texi)
 tests       = $(patsubst %,test/%,*.tex *.bib *.map *.mst *.eps)
 utils       = util/idxuniq util/trimsee
 demos       = demo/Makefile demo/*.tex

Modified: trunk/demo/lscommnt.pdf
===================================================================
(Binary files differ)

Modified: trunk/demo/xhyper.pdf
===================================================================
(Binary files differ)

Modified: trunk/doc/userdef.texi
===================================================================
--- trunk/doc/userdef.texi	2022-10-03 00:49:11 UTC (rev 55)
+++ trunk/doc/userdef.texi	2022-10-03 01:21:28 UTC (rev 56)
@@ -2802,39 +2802,32 @@
 @node Checking for PDF output
 @section Checking for PDF output
 
- at cindex @acronym{URL} for pdf at TeX{}
- at cindex @acronym{PDF} output
- at pindex pdftex
+ at cindex PDF output
 @pindex .pdf @r{files}
-pdf at TeX{} is an extended @TeX{} that can output both @file{.dvi} and
- at file{.pdf} (Adobe's Portable Document Format) files (see
- at url{https://ctan.org/pkg/pdftex}).  You might sometimes want to know
-whether the target format is @file{.pdf} or @file{.dvi}.  The
- at code{\ifpdf}
 @findex ifpdf
-switch can be used to detect pdf at TeX{} in PDF mode:
+You might sometimes want to test whether the target format is
+ at file{.pdf} or @file{.dvi}.  The @code{\ifpdf} conditional can be used
+for this:
 
 @example
 \ifpdf
-   This text is produced when pdfTeX is in PDF mode.
+   This text is produced when the engine outputs PDF.
 \else
-   This text is produced when pdfTeX is in DVI mode,
-   or when some program other than pdfTeX is used.
+   This text is produced when the engine outputs DVI (or similar).
 \fi
 @end example
 
-Keep in mind that @code{\ifpdf} is set based on the value of the
- at code{\pdfoutput}
- at findex pdfoutput
-primitive of pdf at TeX{} at the time Eplain is loaded.  If you change
-the value of @code{\pdfoutput} after you load Eplain, @code{\ifpdf}
-will not reflect the change.
+At this writing, @code{\ifpdf} will be true when running pdf at TeX{}
+or Lua at TeX{} with PDF output. It will be false when running Xe at TeX{},
+or (of course) original @TeX{}, etc.
 
- at pindex ifpdf.sty
- at cindex Oberdiek, Heiko
-Eplain defines @code{\ifpdf} by incorporating Heiko Oberdiek's
- at file{ifpdf.sty}, which is available at
- at url{https://ctan.org/pkg/ifpdf}.
+ at pindex iftex.sty
+ at cindex engines, testing for
+Eplain defines @code{\ifpdf} by incorporating @file{iftex.sty}, a
+package now maintained by the @LaTeX{} Project Team.
+ at file{iftex.sty}, and therefore Eplain, defines numerous related
+conditionals to test for different engines; see its package
+documentation for details: @url{https://ctan.org/pkg/ifpdf}.
 
 
 @node Loading LaTeX packages

Deleted: trunk/ifpdf.sty
===================================================================
--- trunk/ifpdf.sty	2022-10-03 00:49:11 UTC (rev 55)
+++ trunk/ifpdf.sty	2022-10-03 01:21:28 UTC (rev 56)
@@ -1,48 +0,0 @@
-%%
-%% This is file `ifpdf.sty',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% ifpdf.dtx  (with options: `package')
-%% 
-%% Source File: ifpdf.dtx
-%% Copyright 2016 Heiko Oberdiek and LaTeX3 project
-%%
-%% This file may be distributed under the terms of the LPPL.
-%% See README for details.
-\ifx\ProvidesPackage\undefined
-\def\next#1#2[#3]{\wlog{#2 #3}}
-\expandafter\next\fi
-\ProvidesPackage{ifpdf}
-[2016/04/04 v3.0 Provides the ifpdf switch]
-\expandafter\ifx\csname ifpdf\endcsname\relax
- \csname newif\expandafter\endcsname\csname ifpdf\endcsname
-\else
- \ifx\pdftrue\undefined
-  \ifx\PackageError\undefined
-  \begingroup\def\PackageError#1#2#3{\endgroup\errmessage{#2}}
-  \fi
-  \PackageError{ifpdf}{incompatible ifpdf definition}{}
-  \expandafter\expandafter\expandafter
- \fi
-\fi
-\let\ifpdf\iffalse
-\ifx\directlua\undefined
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname pdfoutput\endcsname\relax
-\else
-  \ifnum\pdfoutput>0 %
-    \pdftrue
-  \fi
-\fi
-\else
-\directlua{%
-if (tex.outputmode or tex.pdfoutput or 0) > 0 then
-  tex.print('\string\\pdftrue')
-end
-}
-\fi
-\endinput
-%%
-%% End of file `ifpdf.sty'.

Added: trunk/iftex.sty
===================================================================
--- trunk/iftex.sty	                        (rev 0)
+++ trunk/iftex.sty	2022-10-03 01:21:28 UTC (rev 56)
@@ -0,0 +1,273 @@
+%% iftex TeX engine tests
+
+%% LaTeX3 Project
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3c of this license or (at your option) any later
+%% version.
+%%
+%% Using ideas from:
+%%
+%% ifetex Martin Scharrer
+%% ifxetex Will Robertson
+%% iftex 0.2 Persian TeX Group / Vafa Khalighi
+%% ifluatex ifvtex Heiko Oberdiek
+%% ifptex Takayuki YATO
+%% ifpdf Heiko Oberdiek and LaTeX3 Project
+
+% Only load once (not needed in LaTeX, but does no harm).
+\csname IFTEX\string @loaded\endcsname
+\expandafter\let\csname IFTEX\string @loaded\endcsname\endinput
+
+% File loadable in initex
+% require { } # with standard catcodes.
+\catcode123=1
+\catcode125=2
+\catcode35=6
+
+
+% ProvidesPackage declaration in LaTeX
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname ProvidesPackage\endcsname\relax\else
+  \ProvidesPackage{iftex}[2022/02/03 v1.0f TeX engine tests]
+\fi
+
+% Save @ catcode, to restore at end, not needed in LaTeX.
+\expandafter\chardef\csname IFTEX\string @atcatcode\endcsname\catcode64
+\catcode 64 11
+
+% Message format used in several pre-existing if*tex packages
+% Modified here to do a hard stop and not show any error context lines.
+\def\IFTEX at Require#1#2#3{%
+  #1\else
+      \newlinechar 64\relax
+      \errorcontextlines -1\relax
+      \immediate\write20{@
+      ********************************************@
+      * #2 is required to compile this document.@
+      * Sorry!@
+      ********************************************}%
+    \batchmode\read -1 to \@tempa
+    #3%
+}
+
+
+% eTeX \protected if available.
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname protected\endcsname\relax
+  \let\IFTEX at protected\relax
+\else
+  \let\IFTEX at protected\protected
+\fi
+
+% make sure \detokenize and \protected are available in lualatex,
+% but avoid defining them after the package if not already defined.
+  {
+  \catcode34 12 % "
+  \catcode40 12 % (
+  \catcode41 12 % )
+  \catcode44 12 % ,
+  \catcode46 12 % .
+  \expandafter\ifx\csname directlua\endcsname\relax\else
+    \directlua{tex.enableprimitives("IFTEX@", {"detokenize","protected"})}
+  \fi
+  }
+
+% \Require... commands that stop if the wrong engine detected.
+\IFTEX at protected\def\RequireeTeX{\IFTEX at Require\ifetex{eTeX}\fi}
+\IFTEX at protected\def\RequirePDFTeX{\IFTEX at Require\ifpdftex{pdfTeX}\fi}
+\IFTEX at protected\def\RequireXeTeX{\IFTEX at Require\ifxetex{XeTeX}\fi}
+\IFTEX at protected\def\RequireLuaTeX{\IFTEX at Require\ifluatex{LuaTeX}\fi}
+\IFTEX at protected\def\RequireLuaHBTeX{\IFTEX at Require\ifluahbtex{LuaHBTeX}\fi}
+\IFTEX at protected\def\RequirepTeX{\IFTEX at Require\ifptex{pTeX}\fi}
+\IFTEX at protected\def\RequireupTeX{\IFTEX at Require\ifuptex{upTeX}\fi}
+\IFTEX at protected\def\RequirepTeXng{\IFTEX at Require\ifptexng{pTeX-ng}\fi}
+\IFTEX at protected\def\RequireVTeX{\IFTEX at Require\ifvtex{VTeX}\fi}
+% alephtex as aleph name too generic
+\IFTEX at protected\def\RequireAlephTeX{\IFTEX at Require\ifalephtex{Aleph}\fi}
+% tutex == has \Umathchardef == XeTeX or Lua(HB)TeX currently
+\IFTEX at protected\def\RequireTUTeX{\IFTEX at Require\iftutex{LuaTeX or XeTeX}\fi}
+% TeXpad TeX
+\IFTEX at protected\def\RequireTexpadTeX{\IFTEX at Require\iftexpadtex{TexpadTeX}\fi}
+% HiTeX/HINT
+\IFTEX at protected\def\RequireHINT{\IFTEX at Require\ifhint{HINT}\fi}
+
+% As a matter of policy over-write any existing \if*tex macro and set
+% by the tests here.
+
+% \csname and \let construct useful for hiding \ifzzz tokens from
+% outer level \if tests.
+\def\IFTEX at let#1#2{%
+  \expandafter\let\csname if#1\expandafter\endcsname
+  \csname if#2\endcsname}
+
+% etex (should always be true in latex based formats)
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname numexpr\endcsname\relax
+  \IFTEX at let{etex}{false}
+\else
+  \IFTEX at let{etex}{true}
+\fi
+\IFTEX at let{eTeX}{etex}
+
+% pdftex (including in dvi mode)
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname pdftexversion\endcsname\relax
+  \IFTEX at let{pdftex}{false}
+\else
+  \IFTEX at let{pdftex}{true}
+\fi
+\IFTEX at let{PDFTeX}{pdftex}
+
+% xetex
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname XeTeXrevision\endcsname\relax
+  \IFTEX at let{xetex}{false}
+\else
+  \IFTEX at let{xetex}{true}
+\fi
+\IFTEX at let{XeTeX}{xetex}
+
+
+% luatex (including luahbtex)
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname directlua\endcsname\relax
+  \IFTEX at let{luatex}{false}
+\else
+  \IFTEX at let{luatex}{true}
+\fi
+\IFTEX at let{LuaTeX}{luatex}
+
+
+% luahbtex (or luatex + luaharfbuzz)
+% Use luaharfbuzz test rather than status.luatex_engine=="luahbtex"
+% for issue #2.
+\IFTEX at let{luahbtex}{false}
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname directlua\endcsname\relax
+\else
+  \directlua{\IFTEX at detokenize{
+   if(pcall(require, 'luaharfbuzz')) then
+     tex.print("\\let\\ifluahbtex\\iftrue ")
+   end
+  }}
+
+\fi
+\IFTEX at let{LuaHBTeX}{luahbtex}
+
+
+% ptex (including all variants)
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname kanjiskip\endcsname\relax
+  \IFTEX at let{ptex}{false}
+\else
+  \IFTEX at let{ptex}{true}
+\fi
+\IFTEX at let{pTeX}{ptex}
+
+% uptex (including euptex)
+\ifx\enablecjktoken \@undefined
+  \IFTEX at let{uptex}{false}
+\else
+  \IFTEX at let{uptex}{true}
+\fi
+\IFTEX at let{upTeX}{uptex}
+
+% ptex-ng
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname ngbanner\endcsname\relax
+  \IFTEX at let{ptexng}{false}
+\else
+  \IFTEX at let{ptexng}{true}
+\fi
+\IFTEX at let{pTeXng}{ptexng}
+
+% vtex
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname VTeXversion\endcsname\relax
+  \IFTEX at let{vtex}{false}
+\else
+  \IFTEX at let{vtex}{true}
+\fi
+\IFTEX at let{VTeX}{vtex}
+
+% aleph
+\IFTEX at let{alephtex}{false}
+\ifptex\else
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname omathchardef\endcsname\relax
+\else
+  \IFTEX at let{alephtex}{true}
+\fi
+\fi
+\IFTEX at let{AlephTeX}{alephtex}
+
+
+% tutex (LuaTeX or XeTeX)
+\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}
+
+
+% texpadtex
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname TexpadTeXMode\endcsname\relax
+  \IFTEX at let{texpadtex}{false}
+\else
+  \IFTEX at let{texpadtex}{true}
+  \ifcase\TexpadTeXMode\relax
+    % This is 8 bit mode
+  \or
+    \IFTEX at let{tutex}{true}
+  \fi
+\fi
+\IFTEX at let{TexpadTeX}{texpadtex}
+
+% HiTeX
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname HINTversion\endcsname\relax
+  \IFTEX at let{hint}{false}
+\else
+  \IFTEX at let{hint}{true}
+\fi
+\IFTEX at let{HINT}{hint}
+
+
+% Output mode
+% declare as if with \newif
+\def\pdftrue{\let\ifpdf\iftrue}
+\def\pdffalse{\let\ifpdf\iffalse}
+\pdffalse
+\ifluatex
+\directlua{\IFTEX at detokenize{
+if (tex.outputmode or tex.pdfoutput or 0) > 0 then
+  tex.print('\\pdftrue')
+end
+}}
+\else
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname pdfoutput\endcsname\relax
+\ifvtex
+  \ifnum\OpMode=3 %
+    \pdftrue
+  \fi
+\else
+  \iftexpadtex
+    \pdftrue
+  \fi
+\fi
+\else
+  \ifnum\pdfoutput>0 %
+    \pdftrue
+  \fi
+\fi
+\fi
+
+
+% restore things
+\catcode64 \IFTEX at atcatcode


Property changes on: trunk/iftex.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/util/mkdist-merge
===================================================================
--- trunk/util/mkdist-merge	2022-10-03 00:49:11 UTC (rev 55)
+++ trunk/util/mkdist-merge	2022-10-03 01:21:28 UTC (rev 56)
@@ -1,4 +1,5 @@
 #!/bin/sh
+# $Id$
 # This file is public domain.
 
 # Merge the constituent files with xeplain.tex to produce eplain.tex.
@@ -23,7 +24,7 @@
 
 rm -f eplain.tex
 
-# Use this regexp to strip comments with egrep.
+# Use this regexp to strip comments (but not %% comments) with egrep.
 commentre='^ *%([^%]|$)'
 
 # Extract the relevant parts of btxmac.tex (without comments).
@@ -44,13 +45,13 @@
         -e '1,/catcode.*\&.*4/w '"$arrow1tmp"			\
         -e '/catcode.*\&.*4/,$w '"$arrow2tmp"
 
-# Get ifpdf.sty
-egrep -v "$commentre"'|^ {0,6}\\immediate' ifpdf.sty > $ifpdftmp
+# Get iftex.sty.
+egrep -v "$commentre" iftex.sty > $ifpdftmp
 
 # Merge the above into xeplain, calling the result eplain.  Also change the
 # `filename' in the comment.%%
 egrep -v "$commentre" xeplain.tex					\
-  | sed -e 's/"xeplain.tex"/"eplain.tex"/'						\
+  | sed -e 's/"xeplain.tex"/"eplain.tex"/'				\
         -e "/^%% \[\[\[here is the first.*\]\]\]/r $common1tmp"		\
         -e "/^  %% \[\[\[here are the BibTeX.*\]\]\]/r $btxtmp"		\
         -e "/^%% \[\[\[here is the second.*\]\]\]/r $common2tmp"	\
@@ -58,7 +59,7 @@
         -e "/^%% \[\[\[include path.*\]\]\]/r $pathtmp"			\
         -e "/^  %% \[\[\[include arrow1\]\]\]/r $arrow1tmp"		\
         -e "/^  %% \[\[\[include arrow2\]\]\]/r $arrow2tmp"		\
-        -e "/^%% \[\[\[include ifpdf.*\]\]\]/r $ifpdftmp"		\
+        -e "/^%% \[\[\[include iftex.*\]\]\]/r $ifpdftmp"		\
     > $eplaintmp
 
 # Remove our [[[...]]] markers and \endinput's.
@@ -83,4 +84,4 @@
 #grep 'checksum.*=' eplain.tex
 
 rm -f $btxtmp $eplaintmp $common1tmp $common2tmp $common3tmp
-rm -f $arrow1tmp $arrow2tmp $pathtmp $ifpdftmp
+rm -f $arrow1tmp $arrow2tmp $pathtmp #$ifpdftmp


Property changes on: trunk/util/mkdist-merge
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id Revision
\ No newline at end of property
Modified: trunk/xeplain.tex
===================================================================
--- trunk/xeplain.tex	2022-10-03 00:49:11 UTC (rev 55)
+++ trunk/xeplain.tex	2022-10-03 01:21:28 UTC (rev 56)
@@ -1,3 +1,4 @@
+% $Id$
 % xeplain.tex: macros for nonformatting.  Written 1989--94 by (mostly)
 % Karl Berry. Some additions/changes 1997--98 by Adam Lewenberg,
 % with subsequent contributions from many people.
@@ -49,10 +50,9 @@
   \expandafter\let\expandafter\next\csname endinput\endcsname
 \fi
 \next
-% The ifpdf.sty file included below was written by Heiko Oberdiek.
-% See the complete source file (e.g., in this distribution) for
-% comments.
-%% [[[include ifpdf.sty]]]
+% The iftex.sty file included below was mainly written by Heiko Oberdiek
+% and is now maintained by the LaTeX Project.
+%% [[[include iftex.sty]]]
 % 
 % 
 % Category codes, etc.


Property changes on: trunk/xeplain.tex
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id Revision
\ No newline at end of property


More information about the tex-eplain-commits mailing list.