r3tex

custom LuaTeX format
git clone git://git.rr3.xyz/r3tex
Log | Files | Refs | README | LICENSE

commit f33eb95b005fafb40af5f7880c72256fd47e135e
parent ec3bba310f2a1921c203b2e1a0b4350a0a28b5d8
Author: Robert Russell <robertrussell.72001@gmail.com>
Date:   Sat, 15 Apr 2023 19:12:26 -0700

Cleanup

Diffstat:
Malloc.tex | 62++++++++++++++++++++++++++++++--------------------------------
Mcatcode.tex | 4++--
Mdebug.tex | 3+--
Mfont.tex | 2+-
Mqueue.tex | 20++++++++++----------
Mutil.tex | 39++++++++++++++-------------------------
6 files changed, 58 insertions(+), 72 deletions(-)

diff --git a/alloc.tex b/alloc.tex @@ -27,7 +27,7 @@ % read, write: % 0--15: allocated % fam: -% 0 roman +% 0 body % 1 variables % 2 symbols % 3 extension @@ -38,21 +38,19 @@ % 256--32767: allocated % TODO: marks? How do eTeX marks classes work? -% TODO: some stuff in here should be marked private with \@... - -\countdef\allocnum=10 \allocnum=-1 -\countdef\countnext=11 \countnext=256 \chardef\countmax=65535 -\countdef\dimennext=12 \dimennext=256 \chardef\dimenmax=65535 -\countdef\skipnext=13 \skipnext=256 \chardef\skipmax=65535 -\countdef\muskipnext=14 \muskipnext=256 \chardef\muskipmax=65535 -\countdef\boxnext=15 \boxnext=256 \chardef\boxmax=65535 -\countdef\toksnext=16 \toksnext=256 \chardef\toksmax=65535 -\countdef\readnext=17 \readnext=0 \chardef\readmax=15 -\countdef\writenext=18 \writenext=0 \chardef\writemax=15 -\countdef\famnext=19 \famnext=4 \chardef\fammax=255 -\countdef\attrnext=20 \attrnext=256 \chardef\attrmax=65535 -\countdef\cctabnext=21 \cctabnext=256 \chardef\cctabmax=32767 -\countdef\insertnext=22 \insertnext=254 \chardef\insertmin=101 +\countdef\allocnum=10 \allocnum=-1 +\countdef\@countnext=11 \@countnext=256 \chardef\@countmax=65535 +\countdef\@dimennext=12 \@dimennext=256 \chardef\@dimenmax=65535 +\countdef\@skipnext=13 \@skipnext=256 \chardef\@skipmax=65535 +\countdef\@muskipnext=14 \@muskipnext=256 \chardef\@muskipmax=65535 +\countdef\@boxnext=15 \@boxnext=256 \chardef\@boxmax=65535 +\countdef\@toksnext=16 \@toksnext=256 \chardef\@toksmax=65535 +\countdef\@readnext=17 \@readnext=0 \chardef\@readmax=15 +\countdef\@writenext=18 \@writenext=0 \chardef\@writemax=15 +\countdef\@famnext=19 \@famnext=4 \chardef\@fammax=255 +\countdef\@attrnext=20 \@attrnext=256 \chardef\@attrmax=65535 +\countdef\@cctabnext=21 \@cctabnext=256 \chardef\@cctabmax=32767 +\countdef\@insertnext=22 \@insertnext=254 \chardef\@insertmin=101 \def\allocate#1#2#3#4#5{% \ifnum#3>#4% @@ -65,30 +63,30 @@ \fi } -\protected\def\newcount{\allocate\count\countdef\countnext\countmax} -\protected\def\newdimen{\allocate\dimen\dimendef\dimennext\dimenmax} -\protected\def\newskip{\allocate\skip\skipdef\skipnext\skipmax} -\protected\def\newmuskip{\allocate\muskip\muskipdef\muskipnext\muskipmax} -\protected\def\newbox{\allocate\box\chardef\boxnext\boxmax} -\protected\def\newtoks{\allocate\toks\toksdef\toksnext\toksmax} -\protected\def\newread{\allocate\read\chardef\readnext\readmax} -\protected\def\newwrite{\allocate\write\chardef\writenext\writemax} -\protected\def\newfam{\allocate\fam\chardef\famnext\fammax} -\protected\def\newattr{\allocate\attr\attrdef\attrnext\attrmax} -\protected\def\newcctab{\allocate\cctab\chardef\cctabnext\cctabmax} +\protected\def\newcount{\allocate\count\countdef\@countnext\@countmax} +\protected\def\newdimen{\allocate\dimen\dimendef\@dimennext\@dimenmax} +\protected\def\newskip{\allocate\skip\skipdef\@skipnext\@skipmax} +\protected\def\newmuskip{\allocate\muskip\muskipdef\@muskipnext\@muskipmax} +\protected\def\newbox{\allocate\box\chardef\@boxnext\@boxmax} +\protected\def\newtoks{\allocate\toks\toksdef\@toksnext\@toksmax} +\protected\def\newread{\allocate\read\chardef\@readnext\@readmax} +\protected\def\newwrite{\allocate\write\chardef\@writenext\@writemax} +\protected\def\newfam{\allocate\fam\chardef\@famnext\@fammax} +\protected\def\newattr{\allocate\attr\attrdef\@attrnext\@attrmax} +\protected\def\newcctab{\allocate\cctab\chardef\@cctabnext\@cctabmax} \protected\def\newinsert#1{% - \ifnum\insertnext<\insertmin + \ifnum\@insertnext<\@insertmin \errmessage{No room for a new \string\insert}% \else - \global\chardef#1=\insertnext - \wlog{\string#1=\string\insert\the\insertnext}% - \global\advance\insertnext-1 + \global\chardef#1=\@insertnext + \wlog{\string#1=\string\insert\the\@insertnext}% + \global\advance\@insertnext-1 \fi } % Temporaries of various types: -% TODO: distinguish between local and global temporaries +% TODO: distinguish between local and global temporaries? \countdef\countA=30 \countdef\countB=31 \countdef\countC=32 \dimendef\dimenA=30 \dimendef\dimenB=31 \dimendef\dimenC=32 \skipdef\skipA=30 \skipdef\skipB=31 \skipdef\skipC=32 diff --git a/catcode.tex b/catcode.tex @@ -1,4 +1,4 @@ -% Here are the catcode categories for reference: +% Here are the catcode numbers for reference: % 0 escape 8 subscript % 1 begin group 9 ingored % 2 end group 10 space @@ -18,7 +18,7 @@ \catcode`\&=4 % \catcode`\^^M=5 \catcode`\#=6 -\catcode`\^=7 +\catcode`\^=13 % Unlike plain, ^ is active. \catcode`\_=13 % Unlike plain, _ is active. % \catcode`\^^@=9 % \catcode`\ =10 diff --git a/debug.tex b/debug.tex @@ -18,11 +18,10 @@ } \def\tracingall{\tracingonline=1 \loggingall} -% TODO: is \tenrm defined? \def\showhyphens#1{% \setbox0=\vbox{% \parfillskip=0pt \hsize=\maxdimen \pretolerance=-1 \tolerance=-1 - \hbadness=0 \showboxdepth=0 \tenrm \ #1% + \hbadness=0 \showboxdepth=0 \ #1% }% } diff --git a/font.tex b/font.tex @@ -130,7 +130,7 @@ \def\ffont[#1]{\ifcs ffont:#1\endcs\cs{ffont:#1}\fi} \def\f[#1]{\fam=\ffam[#1]\ffont[#1]} -\countB=0 +\countB="80 \foreach /n s/s \do#1/#2 { \foreach l/l r/r m/m b/b \do##1/##2 { \foreach /u i/i \do####1/####2 { diff --git a/queue.tex b/queue.tex @@ -9,10 +9,10 @@ \newif\if@qapp \newif\if@qpeek -\protected\def\newq#1{\newbox#1\g\setbox#1=\hbox{\penalty0}} +\protected\def\newq#1{\newbox#1\gsetbox#1=\hbox{\penalty0}} \def\@qexec{% - \g\setbox\@qn=\hbox{\unhbox\@qn \g\@qt=\lastpenalty \unpenalty}% - \g\setbox\@qn=\hbox{% + \gsetbox\@qn=\hbox{\unhbox\@qn \global\@qt=\lastpenalty \unpenalty}% + \gsetbox\@qn=\hbox{% \if@qapp \unhbox\@qn \fi \@qop \unhbox\@qn % no op iff @qapp is true @@ -58,13 +58,13 @@ \protected\def\pushtoks{\@qapptrue \@qwtoks} \protected\def\pushtok {\@qapptrue \@qwtok} -\def\@qrnum {\@qmodify{\g\qnum\lastpenalty \if@qpeek\else\unpenalty\fi}} -\def\@qrdim {\@qmodify{\g\qdim\lastkern \if@qpeek\else\unkern\fi}} -\def\@qrskip{\@qmodify{\g\qskip\lastskip \if@qpeek\else\unskip\fi}} -\def\@qrmu {\@qmodify{\g\qmu\gluetomu\lastskip \if@qpeek\else\unskip\fi}} -\def\@qrbox {\@qmodify{\g\setbox\qbox\lastbox \if@qpeek\copy\qbox\fi}} -\def\@qrtoks{\@qmodify{{\if@qpeek\else\g\fi\decr\@qt \gletcs\qtok\@qcs \g\qtoks\ea{\qtok}}}} -\def\@qrtok {\@qmodify{{\if@qpeek\else\g\fi\decr\@qt \gletcs\qtok\@qcs}}} +\def\@qrnum {\@qmodify{\global\qnum\lastpenalty \if@qpeek\else\unpenalty\fi}} +\def\@qrdim {\@qmodify{\global\qdim\lastkern \if@qpeek\else\unkern\fi}} +\def\@qrskip{\@qmodify{\global\qskip\lastskip \if@qpeek\else\unskip\fi}} +\def\@qrmu {\@qmodify{\global\qmu\gluetomu\lastskip \if@qpeek\else\unskip\fi}} +\def\@qrbox {\@qmodify{\gsetbox\qbox\lastbox \if@qpeek\copy\qbox\fi}} +\def\@qrtoks{\@qmodify{{\if@qpeek\else\global\fi\decr\@qt \gletcs\qtok\@qcs \global\qtoks\ea{\qtok}}}} +\def\@qrtok {\@qmodify{{\if@qpeek\else\global\fi\decr\@qt \gletcs\qtok\@qcs}}} \protected\def\popnum {\@qpeekfalse \@qrnum} \protected\def\popdim {\@qpeekfalse \@qrdim} diff --git a/util.tex b/util.tex @@ -1,8 +1,6 @@ -% TODO: is there a meaningful difference between abbreviation and alias? % Primitive abbreviations -\let\g=\global \let\ea=\expandafter -\let\nx=\noexpand % TODO: replace noexpand with nx +\let\nx=\noexpand \let\attr=\attribute \let\attrdef=\attributedef \let\cctab=\catcodetable @@ -56,6 +54,8 @@ \protected\def\decr#1{\advance#1by-1 } \protected\def\gdecr{\global\decr} +\def\gsetbox{\global\setbox} + \def\cs#1{\begcs#1\endcs} \protected\def\csdef#1{\ea\def\begcs#1\endcs} @@ -86,11 +86,11 @@ % global (prefix \addhook with \global). \protected\def\defevent#1[#2]{% \toksA={#1}% Double hashes - \xcsdef{event:#2}{\def\noexpand\@hooks\the\toksA}% + \xcsdef{event:#2}{\def\nx\@hooks\the\toksA}% \ea\newtoks\begcs hooks:#2\endcs \cs{hooks:#2}={}% } \protected\def\event[#1]{% - \relax % events can appear in weird places (e.g., the standard \par event) + \relax % Events can appear in weird places (e.g., the standard \par event) \begcs event:#1\ea\endcs\ea{\the\cs{hooks:#1}}% \@hooks } @@ -131,14 +131,12 @@ \gdef\expandtabs{\afterassignment\@expandtabs \countA=} } \def\gobblespace{\let\csA= } -\def\@optionalspace{\ifcat\next\space\ea\gobblespace\fi} +\def\@optionalspace{\ifcat\next\space \ea\gobblespace \fi} \def\optionalspace{\futurelet\next\@optionalspace} % Mode control -% TODO: remove \leaveXmode and replace with \Ymode -% TODO: \vmode should be an error outside of normal horizontal mode -\def\leavevmode{\relax \ifvmode \unhbox\voidbox \fi} \def\hmode{\leavevmode} -\def\leavehmode{\relax \ifvmode \else \par \fi} \def\vmode{\leavehmode} +\def\leavevmode{\relax \ifvmode \unhbox\voidbox \fi} +\def\leavehmode{\relax \ifhmode \par \fi} \def\modechoice#1#2#3{% \relax \ifvmode @@ -153,8 +151,7 @@ % Generalized mathpalette---gives number to be used with \ifcase \def\mathpalette#1#2{\mathchoice{#10{#2}}{#11{#2}}{#12{#2}}{#13{#2}}} -% XXX: protect or start with \relax? -\def\sty#1{% +\protected\def\sty#1{% \ifcase\numexpr#1\relax \displaystyle \or\textstyle @@ -162,7 +159,7 @@ \or\scriptscriptstyle \fi } -\def\styfont#1{% +\protected\def\styfont#1{% \ifcase\numexpr#1\relax \textfont \or\textfont @@ -177,22 +174,14 @@ \let\rempt=\csA \def\decimal{\ea\rempt\the} -\def\@regnum#1#2\@END{% - \ifx\relax#1\else - \ifnum1<1#1 #1\fi - \@regnum#2\@END - \fi -} -\def\regnum#1{\ea\@regnum\meaning#1\relax\@END\relax} - % \defer defers execution of the given tokens until after the current group % (like \aftergroup, but with multiple tokens). -\newcount\defernext \defernext=0 +\newcount\@defernext \@defernext=0 \protected\def\defer#1{% \ifnum\currentgrouplevel>0 - \gcsdef{defer:\the\defernext}{#1}% - \ea\aftergroup\begcs defer:\the\defernext\endcs - \incr\defernext + \gcsdef{defer:\the\@defernext}{#1}% + \ea\aftergroup\begcs defer:\the\@defernext\endcs + \incr\@defernext \fi }