summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/csplain/base/etex-mac.tex
blob: 76a078f4d4403888ccd04c9b59f104a5a5caaad2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
% etex-mac.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Petr Olsak                                 January 2016

% This file is a part of csplain package. It is inputted during
% csplain format generation when eTeX is detected (from <Jan 2016>).

% The \newcount, \newdimen, etc. allocators are redefined here in order
% to access the extension register fields from eTeX (up to index 32768).

% See the end of the file for more details

\ifx\loccount\undefined \else
   \errmessage{etex.src macro package detected, don't use etex-mac}
   \endpinput \fi

\chardef\tmp=\catcode`@ \catcode`@=11

\let\inscOunt=\insc@unt
\chardef\insc@unt=200
\def\et@xmaxregs{32768}  % maximal index of registers in eTeX

\outer\def\newinsert#1{% \newinsert re-defined:
   \global\advance\inscxunt by\m@ne
   \ifnum\inscOunt<\insc@out
      \errmessage{No room for a new \string\insert, try to \chardef\insc@unt < 200}%
   \else \allocationnumber=\inscOunt
      \global\chardef#1=\allocationnumber
      \wlog{\string#1=\string\insert\the\allocationnumber}%
   \fi
}
\outer\def\et@newcount{\alloc@0\count\countdef\et@xmaxregs}
\outer\def\et@newdimen{\alloc@1\dimen\dimendef\et@xmaxregs}
\outer\def\et@newskip{\alloc@2\skip\skipdef\et@xmaxregs}
\outer\def\et@newbox{\alloc@4\box\mathchardef\et@xmaxregs}

\outer\def\newmuskip{\alloc@3\muskip\muskipdef\et@xmaxregs}
\outer\def\newtoks{\alloc@5\toks\toksdef\et@xmaxregs}

\def\ch@ck#1#2#3{%  \ch@ck re-defined
   \ifnum\count1#1<#2\relax\else
      \ifnum#1<6 
         \ifnum#2<\et@xmaxregs 
             \wlog{eTeX allocation of \string#3: skipping range \string\insc@unt...255}% 
             \begingroup \escapechar=-1
                \global \expandafter\let \csname new\string#3\expandafter\endcsname
                                         \csname et@new\string#3\endcsname
             \endgroup
             \count1#1=256
             \ifx#3\box \ch@ckboxch \fi
         \else \errmessage{No room for a new #3}%
   \fi\fi\fi
}
\def\ch@ckboxch #1\global\chardef{#1\global\mathchardef}

\newcount\marks@count \marks@count=0  % allocation starts from 1, 2, 3, ...

\outer\def\newmarks{\et@alloc \marks@count \marks \mathchardef \et@xmaxregs} 
\def\et@alloc #1#2#3#4#5{%
   \global\advance#1by\@ne
   \ifnum#1<#4\relax 
      \allocationnumber=#1%
      \global#3#5=\allocationnumber
      \wlog{\string#5=\string#2\the\allocationnumber}%
   \else \errmessage{No room for a new #3}\fi
}

\expandafter\def\expandafter\loggingall\expandafter{\loggingall
   \tracingcommands=3 \tracinglostchars=2
   \errorstopmode
   \tracinggroups=1 \tracingifs=1 \tracingscantokens=1
   \tracingnesting=1 \tracingassigns=2
}

\catcode`@=\tmp

\endinput

The \newcount, \newdimen, \newskip and \newbox allocators are kept from
plainTeX, but if the maximal number from plainTeX \insc@unt is reached then
the range \insc@unt...255 is skipped and next indexes are set to 256, 257, ...
The appropriate allocator macro is redefined to the macro \et@newcount, 
\et@newdimen etc. in such case.

The \insc@unt is set as a constant 200. The \newinsert macro is redefined:
it operates with \inscOunt register instead of \insc@unt. The allocated
indexes are 254, 253, ..., \insc@unt. If the limit is reached then the error
"No room for a new \insert" is printed. User can try to set \insc@unt
constant to the value less than 200 in such case. 

The macros \newmuskip, \newtoks are redefined to allocate linear array of
indexes 10, 11, ..., \et@xmaxregs.

Another allocators (\newread, \newwrite, \newfam, \newlanguage) are unchanged.

The new allocator \newmarks is defined as an example how to do this without
the Knuth's dirty trick \count1#1.

The \tracingall, \loggingall macros are re-defined in order to print more
information provided by eTeX.