Testing for variant/version

Joseph Wright joseph at texdev.net
Tue Apr 9 12:27:20 CEST 2024


On 09/04/2024 10:48, Peter Flynn wrote:
> A user has suggested the following code to make sure that a  macro is
> using the "right" string comparator macro:
>
> \ifdefined\pdftexversion
>    \let\switch at strcmp=\pdfstrcmp
> \else
>    \ifdefined\xetexversion
>      \let\switch at strcmp=\strcmp
>    \else
>      \ifdefined\luatexversion
>        \input pdftexcmds.sty
>        \let\switch at strcmp=\pdf at strcmp
>      \else
>        \let\switch at strcmp=\pdfstrcmp% Danger, Will Robinson!
>        \PackageWarningNoLine{stringswitch}{\protect\pdfstrcmp\space
> selected (no \protect\TeX\space variant version found, maybe very old?)}%
>      \fi
>    \fi
> \fi
>
> The final \else was added because TeX Live 2019/Debian in its xelatex
> incarnation was failing the first three tests. Is there another test
> than can be performed for earlier versions (some of them are probably
> still widespread)?

I see David has given a sensible approach. Just to note that the test
above fails as XeTeX uses \XeTeXversion not \xetexversion. If you want
to stick with a test, I would not mess about with testing engine but
rather functionality (so check for \pdfstrcmp/\strcmp/\directlua).

Joseph




More information about the tex-live mailing list.