texlive[71220] Master: ifis-macros (9may24)
commits+karl at tug.org
commits+karl at tug.org
Thu May 9 21:26:34 CEST 2024
Revision: 71220
https://tug.org/svn/texlive?view=revision&revision=71220
Author: karl
Date: 2024-05-09 21:26:34 +0200 (Thu, 09 May 2024)
Log Message:
-----------
ifis-macros (9may24)
Modified Paths:
--------------
trunk/Master/tlpkg/bin/tlpkg-ctan-check
trunk/Master/tlpkg/libexec/ctan2tds
trunk/Master/tlpkg/tlpsrc/collection-plaingeneric.tlpsrc
Added Paths:
-----------
trunk/Master/texmf-dist/doc/plain/ifis-macros/
trunk/Master/texmf-dist/doc/plain/ifis-macros/README
trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.pdf
trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.tex
trunk/Master/texmf-dist/tex/plain/ifis-macros/
trunk/Master/texmf-dist/tex/plain/ifis-macros/ifisdimension.tex
trunk/Master/texmf-dist/tex/plain/ifis-macros/ifisinteger.tex
trunk/Master/tlpkg/tlpsrc/ifis-macros.tlpsrc
Added: trunk/Master/texmf-dist/doc/plain/ifis-macros/README
===================================================================
--- trunk/Master/texmf-dist/doc/plain/ifis-macros/README (rev 0)
+++ trunk/Master/texmf-dist/doc/plain/ifis-macros/README 2024-05-09 19:26:34 UTC (rev 71220)
@@ -0,0 +1,21 @@
+
+
+This package contains two files with macros. The first contains a
+macro to test an input string if it represents a valid number for
+TeX. The second checks if an input string is a valid dimension for
+TeX.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 3 of the License.
+
+The package consists of the following files:
+
+ifisinteger.tex -- 1st macro file
+ifisdimension.tex -- 2nd macro file
+ifis-macros-doc.pdf -- instructions
+ifis-macros-doc.tex -- the source of ifis-macros-doc.pdf
+README -- this file
+
+Copyright (C) 2024 Udo Wermuth (author)
+ u dot wermuth (at) icloud dot com
Property changes on: trunk/Master/texmf-dist/doc/plain/ifis-macros/README
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.pdf 2024-05-09 19:24:35 UTC (rev 71219)
+++ trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.pdf 2024-05-09 19:26:34 UTC (rev 71220)
Property changes on: trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.tex (rev 0)
+++ trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.tex 2024-05-09 19:26:34 UTC (rev 71220)
@@ -0,0 +1,138 @@
+% This file is part of the CTAN package named isIntDim.
+%
+% info.tex: instructions for two macro packages: ifisinteger.tex
+% and ifisdimension.tex
+%
+% Copyright (C) 2024 Udo Wermuth (author)
+%
+% This program is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+% %%%
+% %%% verbatim macros (from manmac.tex)
+% %%%
+\newskip\ttglue {\tt\global\ttglue=0.5em plus 0.25em minus 0.15em }
+\def\ttverbatim{\begingroup \frenchspacing
+ \catcode`\\=12 \catcode`\{=12 \catcode`\}=12 \catcode`\$=12 \catcode`\&=12
+ \catcode`\#=12 \catcode`\%=12 \catcode`\~=12 \catcode`\_=12 \catcode`\^=12
+ \obeyspaces \obeylines \tt}
+\def\verbatimspace{\ifvmode\indent\fi\space}
+{\obeyspaces \gdef\makespaceverbspace{\def {\verbatimspace}}}
+\outer\def\verbatim{$$\ifdim\parskip>0pt
+ \abovedisplayskip=\parskip \abovedisplayshortskip=\parskip
+ \belowdisplayskip=\parskip \belowdisplayshortskip=\parskip
+ \else
+ \abovedisplayskip=3pt \abovedisplayshortskip=3pt
+ \belowdisplayskip=3pt \belowdisplayshortskip=3pt
+ \fi
+ \let\par=\endgraf \ttverbatim \makespaceverbspace \parskip=0pt
+ \catcode`\\xA7=0 \advance\leftskip by 10pt \ttfinish}
+{\catcode`\\xA7=0 \xA7catcode`\xA7\=12 % \xA7 is temporary escape character
+ \xA7obeylines % end of line is active
+ \xA7gdef\xA7ttfinish#1^^M#2\endverbatim{\xA7vbox{#2}\xA7endgroup$$}}
+\catcode`\|=\active
+{\obeylines \gdef|{\ttverbatim \spaceskip\ttglue \let^^M=\ \let|=\endgroup}}
+
+\def\noitem{\item{\phantom{0.}}}
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\font\titlefont=cmssdc10 at 36pt
+\font\subtitlefont=cmssdc10 at 17pt
+%
+\centerline{\titlefont ifis-macros}
+\bigskip
+\centerline{\subtitlefont Version 1.0, 7.04.2024}
+\bigskip
+\centerline{Macros for plain \TeX}
+\medskip
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\noindent
+There are two main macros in the files {\tt ifisinteger.tex} and {\tt
+ifisdimension.tex}. The macro |\ifisint| tests if a given input string
+represents a number for \TeX. The macro |\ifisdim| does this for
+dimensions.
+
+Both macros generate errors but hide them from the terminal as they
+work in |\batchmode|. There is one configuration parameter:
+|\IIcurrentmode|. The default is |\errorstopmode|. Change this if you
+call the macros in a different interaction mode so that they can
+return to this mode.
+
+\bigskip
+
+\beginsection 0.\ Installation
+
+To use the macro |\ifisint| load via |\input ifisinteger.tex| the file
+that contains the code. For |\ifisdim| use |\input ifisdimension.tex|.
+
+\bigskip
+
+\beginsection 1.\ File {\tt ifisinteger.tex}
+
+The main macro is called |\ifisint| and must be used like an
+|\if|-conditional except that its argument is delimited by |\Boolend|:
+|\ifisint <argument>\Boolend <true branch>\else <false branch>\fi|.
+
+\medskip
+
+The implemented algorithm has four steps:
+\smallskip
+\item{1.}1)~Remove signs with or without braces; add sentinel |W|.
+\noitem 2)~Test that the input isn't now |"W|, etc.; otherwise
+ return false.
+\item{2.}Create a canonical form with a leading zero.
+\item{3.}1)~Assign the input to a |\count| register inside an
+ |\hbox|.
+\noitem 2)~Test that the box width is the width of the sentinel.
+\noitem 3)~Otherwise return false.
+\item{4.}1)~Return true if the number isn't \TeX's maximum.
+\noitem 2)~Otherwise test if the canonical form is \TeX's maximum.
+ If yes, return true.
+\noitem 3)~Otherwise return false.
+\medskip
+
+For more details see my article in TUGboat {\bf45}:1 (2024), 106--109.
+
+\bigskip
+
+\beginsection 2.\ File {\tt ifisdimension.tex}
+
+The main macro is called |\ifisdim| and must be used like an
+|\if|-conditional except that its argument is delimited by |\Boolend|:
+|\ifisdim <argument>\Boolend <true branch>\else <false branch>\fi|.
+
+\medskip
+
+The implemented algorithm has four steps:
+\smallskip
+\item{1.}1)~Remove signs with or without braces; add sentinel |mm|.
+\noitem 2)~Exclude trivial non-numerics as done in |\ifisint|.
+\noitem 3)~Otherwise return false.
+\item{2.}1)~Get the integer part.
+\noitem 2)~Get fraction and the unit.
+\noitem 3)~Get the width of the unit.
+\item{3.}1)~Assign the input to a |\dimen| register inside an
+ |\hbox|.
+\noitem 2)~Test that the box width is the width of the sentinel.
+\noitem 3)~Otherwise return false.
+\item{4.}1)~Return true if the dimension isn't \TeX's |\maxdimen|.
+\noitem 2)~Otherwise test if the coerced sum of the integer part
+ and the fraction expressed in the unit |sp| is |\maxdimen|.
+\noitem 3)~If no, return false.
+\noitem 4)~Otherwise return true.
+\medskip
+
+For more details see my article in TUGboat {\bf45}:1 (2024), 109--112.
+
+\bye
Property changes on: trunk/Master/texmf-dist/doc/plain/ifis-macros/ifis-macros-doc.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/plain/ifis-macros/ifisdimension.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/ifis-macros/ifisdimension.tex (rev 0)
+++ trunk/Master/texmf-dist/tex/plain/ifis-macros/ifisdimension.tex 2024-05-09 19:26:34 UTC (rev 71220)
@@ -0,0 +1,93 @@
+\catcode`\@=11
+\newif\ifII at itis %% reused from \ifisint %%
+\def\II at rmsign #1{\ifx#1+\else\ifx#1-\else %%
+ \II at endrm#1\fi\fi\II at rmsign}% remove signs: %%
+\def\II at endrm #1\fi\fi#2{\fi\fi#1}% `+' & `-' %%
+\let\Boolend=\iffalse \font\II at font=cmr10 % %%
+\let\IIcurrentmode=\errorstopmode % CONFIGURE %%
+\def\II at W{W}\def\II at octW{'W}\def\II at hexW{"W}% %%
+%% declarations
+\newdimen\II at frac
+\countdef\II at cnt=255 \dimendef\II at dim=255
+%% helper macros; some use \ifisint's sentinel W
+\def\II at bad #1#2#3#4#5#6\II at end{% numeric part
+ \def\II at id{#1W}% is missing but maybe with unit
+ \edef\II at X{#6}\ifx\II at X\empty
+ \edef\II at X{#5}\ifx\II at X\empty\else\II at Bad\fi
+ \else \edef\II at X{\II at mklc#2#3#4W}%
+ \ifx\II at X\II at rueW
+ \else\ifx\II at X\II at truW\II at Bad
+ \else \II at itistrue
+ \fi\fi\fi}
+\def\II at rueW{rueW}\def\II at truW{truW}
+\def\II at Bad{\ifx\II at id\II at W
+ \else\ifx\II at id\II at octW
+ \else\ifx\II at id\II at hexW
+ \else \II at itistrue
+ \fi\fi\fi}
+\def\II at mklc #1{\if#1pp\else\if#1Pp\else
+ \if#1tt\else\if#1Tt\else
+ \if#1bb\else\if#1Bb\else
+ \if#1ss\else\if#1Ss\else
+ \if#1rr\else\if#1Rr\else
+ \if#1uu\else\if#1Uu\else
+ \if#1ee\else\if#1Ee\else
+ \II at endlc#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \fi\fi\fi \II at mklc}% `W' and `m' stop \II at mklc
+\def\II at endlc #1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \fi\fi\fi\fi#2{\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \fi\fi\fi\fi#1}
+\def\II at getfrac #1mm\II at end{\global\II at frac=0#1}
+\def\II at getcalc{%\II at calc=coerced\II at int\II at frac
+ \ifdim\II at unit=26.11119pt % \II at unit is ``pt''
+ \II at dim=\ifnum\II at int<16384
+ \II at int\else 0\fi pt
+ \else\ifdim\II at unit=27.77786pt % it is ``bp''
+ \II at dim=\ifnum\II at int<16323
+ \II at int\else 0\fi bp
+ \else\ifdim\II at unit=26.16673pt % it is ``sp''
+ \II at dim=\ifnum\II at int<1073741824
+ \II at int\else 0\fi sp
+ \else \II at dim=0pt \fi\fi\fi
+ \II at cnt=\II at dim \advance\II at cnt by \II at frac
+ \edef\II at calc{\number\II at cnt}}
+\def\II at point #1#2\II at end{% assign digits of the
+ \afterassignment\II at mklc % fraction to \II at cnt
+ \ifx#1.\II at cnt=0#2%
+ \else\ifx#1,\II at cnt=0#2%
+ \else \II at cnt=0#1#2%
+ \fi\fi}
+\def\II at getunit #1{\afterassignment\II at hdlfrac
+ \II at cnt=#1\relax}
+\def\II at rmtrue{\ifdim\wd0>40pt \the\II at dim
+ \else \the\wd0 \fi}
+%% main macro
+\def\ifisdim #1\Boolend{\II at itisfalse % S1.3
+ \edef\II at dist{\II at rmsign#1mm}% S1.1
+ \edef\II at dist{\expandafter\II at rmsign\II at dist}%
+ \expandafter\II at bad
+ \II at dist\empty\empty\empty\empty\II at end % S1.2
+ \ifII at itis % S4.1, S4.4
+ \wlog{=== start ignore}\batchmode\begingroup
+ \setbox0=\hbox{\II at font
+ \afterassignment\II at getfrac
+ \II at cnt=\II at dist\II at end % S2.2
+ \xdef\II at int{\the\II at cnt}}% S2.1
+ \setbox0=\hbox{\II at font
+ \afterassignment\II at point
+ \II at cnt=\II at dist\II at end}\II at dim=\wd0
+ \advance\II at dim by -17.80559pt % width `true'
+ \xdef\II at unit{\II at rmtrue}% S2.3
+ \setbox0=\hbox{\II at font\II at dim=#1mm% S3.1
+ \xdef\II at val{\ifdim\II at dim<0pt-\fi
+ \the\II at dim}}%
+ \xdef\II at wd{\the\wd0}%
+ \endgroup\IIcurrentmode\wlog{=== stop ignore}%
+ \ifdim\II at wd=16.66672pt % width ``mm'' S3.2
+ \ifdim\II at val=\maxdimen \II at getcalc
+ \ifnum\II at calc=1073741823 % S4.2
+ \else \II at itisfalse % S4.3
+ \fi\fi
+ \else \II at itisfalse % S3.3
+ \fi\fi \ifII at itis}
+\catcode`\@=12
Property changes on: trunk/Master/texmf-dist/tex/plain/ifis-macros/ifisdimension.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/plain/ifis-macros/ifisinteger.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/ifis-macros/ifisinteger.tex (rev 0)
+++ trunk/Master/texmf-dist/tex/plain/ifis-macros/ifisinteger.tex 2024-05-09 19:26:34 UTC (rev 71220)
@@ -0,0 +1,44 @@
+\catcode`\@=11 % use the private prefix ``II@''
+\newif\ifII at itis % main result of the macro
+%% helper macros
+\def\II at rmsign #1{\ifx#1+\else\ifx#1-\else
+ \II at endrm#1\fi\fi\II at rmsign}
+\def\II at endrm #1\fi\fi#2{\fi\fi#1}
+\def\II at zeros #1{\ifx#1''\else\ifx#1""\else
+ \II at cont#1\fi\fi\II at zeros}
+\def\II at cont #1\fi\fi#2{\fi\fi\II at hdlzero#1}
+\def\II at hdlzero #1{\ifx#10 \else
+ \II at xchgfi #1\fi\II at hdlzero}
+\def\II at xchgfi #1\fi#2{\fi\ifx#1`\else0\fi#1}
+%% constants with the sentinel `W'
+\def\II at cfd{02147483647W}% canonical forms with
+\def\II at cfh{"07FFFFFFFW}% W of TeX's max integer
+\def\II at cfo{'017777777777W}% in dec, hex, oct
+\def\II at W{W}\def\II at hexW{"W}% all unsigned input
+\def\II at octW{'W}% with W for which TeX inserts 0
+%% assignments
+\let\Boolend=\iffalse \font\II at font=cmr10
+\let\IIcurrentmode=\errorstopmode % CONFIGURE
+%% main macro
+\def\ifisint #1\Boolend{\II at itisfalse % see S1.2
+ \edef\II at digs{\II at rmsign#1W}% S1.1 with 2 \edef
+ \edef\II at digs{\expandafter\II at rmsign\II at digs}%
+ \ifx\II at digs\II at W\else\ifx\II at digs\II at octW
+ \else\ifx\II at digs\II at hexW\else % S1.2 finished
+ \edef\II at cf{\expandafter\II at zeros\II at digs}% S2
+ \wlog{=== start ignore}\batchmode\begingroup
+ \setbox0=\hbox{\count255=\II at cf
+ \xdef\II at val{\the\count255}}%
+ \setbox0=\hbox{\II at font\count255=#1W}% S3.1
+ \xdef\II at wd{\the\wd0}%
+ \endgroup\IIcurrentmode\wlog{=== stop ignore}%
+ \ifdim\II at wd=10.2778pt % \wd of hbox `W'; S3.2
+ \II at itistrue \ifnum\II at val=2147483647 % S4.1
+ \ifx\II at cf\II at cfd
+ \else\ifx\II at cf\II at cfh
+ \else\ifx\II at cf\II at cfo % S4.2
+ \else \II at itisfalse % S4.3
+ \fi\fi\fi\fi
+ \else \II at itisfalse % S3.3
+ \fi\fi\fi\fi \ifII at itis}
+\catcode`\@=12
Property changes on: trunk/Master/texmf-dist/tex/plain/ifis-macros/ifisinteger.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check 2024-05-09 19:24:35 UTC (rev 71219)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check 2024-05-09 19:26:34 UTC (rev 71220)
@@ -427,7 +427,7 @@
iaria iaria-lite ibarra ibrackets ibycus-babel ibygrk icite icsv
ideavault identkey idxcmds idxlayout
ieeeconf ieejtran ieeepes ieeetran ietfbibs iexec
- ifallfalse iffont ifmslide ifmtarg ifnextok ifoddpage
+ ifallfalse iffont ifis-macros ifmslide ifmtarg ifnextok ifoddpage
ifplatform ifptex ifsym iftex ifthenx ifxptex
iitem ijmart ijqc ijsra
imac image-gallery imakeidx impatient impatient-cn
Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds 2024-05-09 19:24:35 UTC (rev 71219)
+++ trunk/Master/tlpkg/libexec/ctan2tds 2024-05-09 19:26:34 UTC (rev 71220)
@@ -2245,6 +2245,7 @@
'iaria-lite', '\.cls', # not docstrip.cfg
'ibygrk', 'iby4extr.tex|ibycus4.tex|ibycusps.tex|pssetiby.tex|setiby4.tex|tlgsqq.tex|version4.tex|' . $standardtex,
'ieejtran', 'NULL', # not .py
+ 'ifis-macros', 'ifis[^-].*.tex', # not ifis-macros-doc
'ifmslide', '[^n]\.(eps|pdf|jpg)|' . $standardtex, # not ifmman.pdf
'ijsra', 'ijsra_logo.*|' . $standardtex,
'insbox', 'insbox.tex',
Modified: trunk/Master/tlpkg/tlpsrc/collection-plaingeneric.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-plaingeneric.tlpsrc 2024-05-09 19:24:35 UTC (rev 71219)
+++ trunk/Master/tlpkg/tlpsrc/collection-plaingeneric.tlpsrc 2024-05-09 19:26:34 UTC (rev 71220)
@@ -50,6 +50,7 @@
depend gtl
depend hlist
depend hyplain
+depend ifis-macros
depend inputnormalization
depend insbox
depend js-misc
Added: trunk/Master/tlpkg/tlpsrc/ifis-macros.tlpsrc
===================================================================
More information about the tex-live-commits
mailing list.