-
Notifications
You must be signed in to change notification settings - Fork 0
/
luatex.dtx
1558 lines (1543 loc) · 44.6 KB
/
luatex.dtx
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
% File: luatex.dtx
% Version: 2019/07/25 v0.7
% Info: LuaTeX basic definition package
%
% Copyright (C) 2007, 2009, 2010 by
% Heiko Oberdiek <heiko.oberdiek at googlemail.com>
% 2016, 2019
% https://github.com/ho-tex/oberdiek/issues
%
% 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. This version of this license is in
% https://www.latex-project.org/lppl/lppl-1-3c.txt
% and the latest version of this license is in
% https://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainers of this work are
% Heiko Oberdiek and the Oberdiek Package Support Group
% https://github.com/ho-tex/oberdiek/issues
%
% The Base Interpreter refers to any `TeX-Format',
% because some files are installed in TDS:tex/generic//.
%
% This work consists of the main source file luatex.dtx
% and the derived files
% luatex.sty, luatex.pdf, luatex.ins, luatex.drv, luatex-loader.sty,
% luatex-test1.tex, luatex-test2.tex, luatex-test3.tex,
% luatex-test4.tex, luatex-test5.tex, oberdiek.luatex.lua.
%
% Distribution:
% CTAN:macros/latex/contrib/oberdiek/luatex.dtx
% CTAN:macros/latex/contrib/oberdiek/luatex.pdf
%
% Unpacking:
% (a) If luatex.ins is present:
% tex luatex.ins
% (b) Without luatex.ins:
% tex luatex.dtx
% (c) If you insist on using LaTeX
% latex \let\install=y\input{luatex.dtx}
% (quote the arguments according to the demands of your shell)
%
% Documentation:
% (a) If luatex.drv is present:
% latex luatex.drv
% (b) Without luatex.drv:
% latex luatex.dtx; ...
% The class ltxdoc loads the configuration file ltxdoc.cfg
% if available. Here you can specify further options, e.g.
% use A4 as paper format:
% \PassOptionsToClass{a4paper}{article}
%
% Programm calls to get the documentation (example):
% pdflatex luatex.dtx
% makeindex -s gind.ist luatex.idx
% pdflatex luatex.dtx
% makeindex -s gind.ist luatex.idx
% pdflatex luatex.dtx
%
% Installation:
% TDS:tex/generic/oberdiek/luatex.sty
% TDS:tex/generic/oberdiek/luatex-loader.sty
% TDS:scripts/oberdiek/oberdiek.luatex.lua
% TDS:doc/latex/oberdiek/luatex.pdf
% TDS:source/latex/oberdiek/luatex.dtx
%
%<*ignore>
\begingroup
\catcode123=1 %
\catcode125=2 %
\def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
\ifx\csname processbatchFile\endcsname\relax\else1\fi
\ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: luatex 2019/07/25 v0.7 LuaTeX basic definition package (HO)}
\Msg{************************************************************************}
\keepsilent
\askforoverwritefalse
\let\MetaPrefix\relax
\preamble
This is a generated file.
Project: luatex
Version: 2019/07/25 v0.7
Copyright (C) 2007, 2009, 2010 by
Heiko Oberdiek <heiko.oberdiek at googlemail.com>
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. This version of this license is in
https://www.latex-project.org/lppl/lppl-1-3c.txt
and the latest version of this license is in
https://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of
LaTeX version 2005/12/01 or later.
This work has the LPPL maintenance status "maintained".
The Current Maintainers of this work are
Heiko Oberdiek and the Oberdiek Package Support Group
https://github.com/ho-tex/oberdiek/issues
The Base Interpreter refers to any `TeX-Format',
because some files are installed in TDS:tex/generic//.
This work consists of the main source file luatex.dtx
and the derived files
luatex.sty, luatex.pdf, luatex.ins, luatex.drv, luatex-loader.sty,
luatex-test1.tex, luatex-test2.tex, luatex-test3.tex,
luatex-test4.tex, luatex-test5.tex, oberdiek.luatex.lua.
\endpreamble
\let\MetaPrefix\DoubleperCent
\generate{%
\file{luatex.ins}{\from{luatex.dtx}{install}}%
\file{luatex.drv}{\from{luatex.dtx}{driver}}%
\usedir{tex/generic/oberdiek}%
\file{luatex.sty}{\from{luatex.dtx}{package}}%
\file{luatex-loader.sty}{\from{luatex.dtx}{loader}}%
% \usedir{doc/latex/oberdiek/test}%
% \file{luatex-test1.tex}{\from{luatex.dtx}{test1}}%
% \file{luatex-test2.tex}{\from{luatex.dtx}{test1,test2}}%
% \file{luatex-test3.tex}{\from{luatex.dtx}{test1,test3}}%
% \file{luatex-test4.tex}{\from{luatex.dtx}{test4}}%
% \file{luatex-test5.tex}{\from{luatex.dtx}{test5}}%
}
\def\MetaPrefix{-- }
\def\defaultpostamble{%
\MetaPrefix^^J%
\MetaPrefix\space End of File `\outFileName'.%
}
\def\currentpostamble{\defaultpostamble}%
\generate{%
\usedir{scripts/oberdiek}%
\file{oberdiek.luatex.lua}{\from{luatex.dtx}{lua}}%
}
\catcode32=13\relax% active space
\let =\space%
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* files into a directory searched by TeX:}
\Msg{*}
\Msg{* luatex.sty, luatex-loader.sty}
\Msg{*}
\Msg{* And install the following script file:}
\Msg{*}
\Msg{* oberdiek.luatex.lua}
\Msg{*}
\Msg{* To produce the documentation run the file `luatex.drv'}
\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}
\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{luatex.drv}%
[2019/07/25 v0.7 LuaTeX basic definition package (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}[2011/11/22]
\usepackage{paralist}
\begin{document}
\DocInput{luatex.dtx}%
\end{document}
%</driver>
% \fi
%
%
%
% \GetFileInfo{luatex.drv}
%
% \title{The \xpackage{luatex} package}
% \date{2019/07/25 v0.7}
% \author{Heiko Oberdiek\thanks
% {Please report any issues at \url{https://github.com/ho-tex/oberdiek/issues}}}
%
% \maketitle
%
% \begin{abstract}
% This package manages the new and extended features and resources
% that \LuaTeX\ provides. Examples are attributes and catcode
% tables.
% \end{abstract}
%
% \tableofcontents
%
% \section{Documentation}
%
% \subsection{Introduction}
%
% \TeX\ provides global resources such as registers.
% But it does not provide an interface for managing these resources.
% For example, two packages want to use a counter register.
% If they take the same register
% number, then the use of both packages will conflict and they cannot
% be used together.
% Therefore formats such as \plainTeX\ or \LaTeX\ implement
% an allocation scheme for registers. A package reserves with
% \cs{newcount} an unused register number for its own exclusive use.
%
% Nowadays \TeX\ is not alone anymore: \eTeX, \pdfTeX\ and other
% compilers for \TeX\ are developed that extend and add new
% features and resources.
%
% Now \LuaTeX\ has reached beta state. It inherits most of
% \pdfTeX's features including \eTeX. Also it implements
% new concepts such as attributes or catcode tables.
%
% \subsubsection{\LaTeX}
%
% Since 2015 Lua\LaTeX\ includes support for luatex by default and so
% this package is essentially obsolete now, however it is kept for
% backwards compatibility.
%
% \subsubsection{\plainTeX}
%
% \LaTeX\ has inherited its resource handling from \plainTeX.
% The interface is basically the same: \cs{newcount}, \dots
% Therefore this package tries to follow this tradition by
% providing compatibility to \plainTeX. It can be loaded
% with \plainTeX\ and defines at least some of the
% features that this packages provides for \LaTeX.
%
% \subsection{Register allocation}
%
% \subsubsection{Register with 16 bit}
%
% Because \LuaTeX\ is a super set of \eTeX\ regarding registers,
% the register allocation scheme should not conflict with
% package \xpackage{etex}. Therefore this package is loaded
% to inherit its allocation scheme. The only change is currently
% that the limit is increased to 65536 registers for the following
% register classes:
% \begin{compactitem}
% \item count
% \item dimen
% \item skip
% \item muskip
% \item marks
% \item toks
% \item box
% \end{compactitem}
% This affects the number of global and local registers.
% Because it is done in a package and not in the kernel,
% it is possible that someone loads package \xpackage{etex}
% before uses the local allocation variants. This will prevent
% the extension for this register class. If more registers are
% needed, just load package \xpackage{luatex} earlier.
%
% \subsubsection{Insertions}
%
% Insertions need four registers \cs{count}, \cs{dimen}, \cs{skip},
% and \cs{box} with the same number. Usually they are allocated
% downwards from 254, 253, \dots Also \cs{newcount}, \cs{newdimen}, \dots
% fill up these register numbers from below before switching to
% higher register numbers by package \xpackage{etex}.
% When this occurs, no insertions can be allocated anymore.
%
% Therefore \cs{newcount}, \cs{newdimen}, \cs{newskip}, and
% \cs{newbox} are replaced by their global variants (\cs{globcount}, \dots)
% that use the higher numbers immediately, leaving the room for insertions.
% There should not be an efficiency penalty because \LuaTeX\ stores
% the registers of a class in the same Lua table unlike \eTeX, where
% registers below 256 are stored in an array and higher numbers
% are put in a tree structure.
%
% \subsection{Attributes}
%
% Nodes can have custom attributes in \LuaTeX. These attributes
% are organized by a new register class. As the other registers
% up to $2^{16}$ attributes are supported. An attribute value
% can be negative that means the attribute is not set. Otherwise
% \TeX's range of non-negative integers up to $2^31$ are available.
%
% \begin{declcs}{newattribute} \M{cmd}
% \end{declcs}
% Macro \cs{newattribute} defines command \meta{cmd} using \cs{attributedef}
% using an new attribute number. The new attribute is initially unset.
%
% \begin{declcs}{setattribute} \M{cmd} \M{value}
% \end{declcs}
% Macro \cs{setattribute} locally sets attribute command \meta{cmd}
% to the number \meta{value}. Valid values range from $-1$ until $2^31$
% (the upper limit is the same as for other \TeX\ integer numbers).
%
% \begin{declcs}{unsetattribute} \M{cmd}
% \end{declcs}
% Macro \cs{unsettattribute} clears the attribute command \meta{cmd}.
%
% \subsection{Catcode tables}
%
% \LuaTeX\ introduces catcode tables as new feature, see documentation.
% There is need for discussion, how to deal best:
% \begin{itemize}
% \item \cs{initcatcodetable} and \cs{setcatcodetable} act globally.
% \item \cs{catcodetable} causes an error if used with an uninitialized
% catcode table.
% \item Large catcode table numbers should be avoided because of
% performance breakdown.
% \item Use case \LaTeX\ package:
% The package must not be surprised by changed catcodes and
% must not surprise by changing catcodes accidently.
% Catcode tables could offer a solution. At the begin
% a catcode regime with standard catcodes is established
% and the old one is restored afterwards.
% \item Use case: \LuaTeX's |tex.print| might be used with
% a catcode table number, for example a table where all
% entries have catcode ``other''.
% \item Readonly catcode tables.
% \item Is there is a need for local allocations?
% (Package \xpackage{etex}'s \cs{loc} variants are not used in
% \TeX\ Live 2007.)
% \end{itemize}
%
% \subsubsection{Interface proposal}
%
% The idea: \cs{newcatcodetable} allocates odd numbered catcode
% tables. Even numbered tables are managed as stack.
% Also some catcode tables are defined. These must not be
% changed.
%
% \begin{declcs}{newcatcodetable} \M{cmd}
% \end{declcs}
% Macro \cs{newcatcodetable} reserves a new catcode table and
% remembers its number in \meta{cmd}. The catcode table is
% initialized with \iniTeX's catcodes.
%
% \begin{declcs}{CatcodeTableIniTeX}\\
% \cs{CatcodeTableString}\\
% \cs{CatcodeTableOther}\\
% \cs{CatcodeTableLaTeX}\\
% \end{declcs}
% These are catcode tables and must not be changed.
% \cs{CatcodeTableIniTeX} contains the catcode settings of \iniTeX.
% \cs{CatcodeTableString} follows \TeX's convention of
% \cs{string}, \cs{meaning} and friends. The space gets catcode
% 10 (space), the other characters have catcode 12 (other).
% In \cs{CatcodeTableOther} all entries have catcode 12 (other).
% \cs{CatcodeTableLaTeX} contains the setting of a pure \LaTeX\ format
% (`at' is other).
%
% \begin{declcs}{CatcodeTableStack}\\
% \cs{IncCatcodeTableStack}\\
% \cs{DecCatcodeTableStack}
% \end{declcs}
% \cs{CatcodeTableStack} is the stack pointer. Initially
% it is catcode table zero. \cs{IncCatcodeTableStack} and
% \cs{DecCatcodeTableStack} increments and decrements the
% stack pointer. Currently \cs{IncCatcodeTableStack} does not
% initialize a new catcode table. Both increment and decrement
% operations do not set a catcode table.
%
% \begin{declcs}{PushCatcodeTableNumStack}\\
% \cs{PopCatcodeTableNumStack}
% \end{declcs}
% It can be handy to have a global stack for catcode table
% numbers to deal with the global assignment property of
% \cs{initcatcodetable} and \cs{savecatcodetable}.
% \cs{PushCatcodeTableNumStack} pushes the current catcode table
% on the stack.
% \cs{PopCatcodeTableNumStack} pops the topmost number off the number
% stack to set the current catcode table. Catcode table zero is
% used in case of an empty stack.
%
% \begin{declcs}{BeginCatcodeRegime} \M{catcodetable}\\
% \cs{EndCatcodeRegime}
% \end{declcs}
% \cs{BeginCatcodeRegime} remembers the current catcode table number.
% Then it creates and uses a fresh catcode table on the stack
% that is initialized by \meta{catcodetable}:
% \begin{quote}\ttfamily
% \cs{PushCatcodeTableNumStack}\\
% \cs{catcodetable}\meta{catcodetable}||
% \cs{IncCatcodeTableStack}\\
% \cs{savecatcodetable}\cs{CatcodeTableStack}\\
% \cs{catcodetable}\cs{CatcodeTableStack}
% \end{quote}
% \cs{EndCatcodeRegime} drops the catcode table, created by
% \cs{BeginCatcodeRegime} and sets the catcode table that was
% active before:
% \begin{quote}
% \cs{DecCatcodeTableStack}\\
% \cs{PopCatcodeTableNumStack}
% \end{quote}
% These macros solve the use case, described earlier for a \LaTeX\ package:
% \begin{quote}
% |% package foobar.sty|\\
% |\BeginCatcodeRegime\CatcodeTableLaTeX|\\
% |\makeatletter|\\
% |% ... package contents ...|\\
% |\EndCatcodeRegime|\\
% |% end of package|
% \end{quote}
% If the package wants to change catcodes after its loading,
% \cs{AtBeginDocument} or \cs{AtEndOfPackage} can be used.
%
% \begin{declcs}{SetCatcodeRange} \M{from} \M{to} \M{catcode}
% \end{declcs}
% The catcodes of characters in range from \meta{from}
% to inclusive \meta{to} are set to \meta{catcode}.
%
% \subsection{Lua module loading}
%
% Currently \LuaTeX\ (version 0.20) does not support Lua script
% files inside \xfile{TDS:scripts//}, because Lua's mechanism
% for module loading does not use the \textsf{kpathsea} library.
% Therefore this packages appends a kpse loader to the list of
% Lua's module loaders. It finds the module \meta{module} by
% \begin{quote}
% \ttfamily |kpse.find_file("|\meta{module}|.lua", "texmfscripts")|
% \end{quote}
% Unhappily \textsf{kpathsea} does not support directory components
% in a file name. Therefore the Lua convention is not followed to
% replace dots in the module name by the directory separator.
%
% Example:
% A Lua script of a package \xpackage{foobar} wants the following
% modules:
% \begin{quote}
% |require("foobar.hello.world")|\\
% |require("org.somewhere.xyz")|
% \end{quote}
% Then they can be find in:
% \begin{quote}
% |TDS:scripts/foobar/foobar.hello.world.lua|\\
% |TDS:scripts/foobar/org.somewhere.xyz.lua|
% \end{quote}
% I would have preferred the following locations, following lua conventions,
% e.\,g.:
% \begin{quote}
% |TDS:scripts/foobar/hello/world.lua|\\
% |TDS:scripts/foobar/org/somewhere/xyz.lua|
% \end{quote}
% But I do not know, how to achieve this in a reliable way using
% \textsf{kpathsea}.
%
% \subsubsection{Package \xpackage{luatex-loader}}
%
% If someone do not need or want package \xpackage{luatex} but
% it's extension for module loading, then he can use
% package \xpackage{luatex-loader}. Both \plainTeX\ and \LaTeX\ are
% supported.
%
% \StopEventually{
% }
%
% \section{Implementation}
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% \subsection{Reload check and package identification}
% Reload check, especially if the package is not used with \LaTeX.
% \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
\catcode13=5 % ^^M
\endlinechar=13 %
\catcode35=6 % #
\catcode39=12 % '
\catcode44=12 % ,
\catcode45=12 % -
\catcode46=12 % .
\catcode58=12 % :
\catcode64=11 % @
\catcode123=1 % {
\catcode125=2 % }
\expandafter\let\expandafter\x\csname [email protected]\endcsname
\ifx\x\relax % plain-TeX, first loading
\else
\def\empty{}%
\ifx\x\empty % LaTeX, first loading,
% variable is initialized, but \ProvidesPackage not yet seen
\else
\expandafter\ifx\csname PackageInfo\endcsname\relax
\def\x#1#2{%
\immediate\write-1{Package #1 Info: #2.}%
}%
\else
\def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
\fi
\x{luatex}{The package is already loaded}%
\aftergroup\endinput
\fi
\fi
\endgroup%
% \end{macrocode}
% Package identification:
% \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
\catcode13=5 % ^^M
\endlinechar=13 %
\catcode35=6 % #
\catcode39=12 % '
\catcode40=12 % (
\catcode41=12 % )
\catcode44=12 % ,
\catcode45=12 % -
\catcode46=12 % .
\catcode47=12 % /
\catcode58=12 % :
\catcode64=11 % @
\catcode91=12 % [
\catcode93=12 % ]
\catcode123=1 % {
\catcode125=2 % }
\expandafter\ifx\csname ProvidesPackage\endcsname\relax
\def\x#1#2#3[#4]{\endgroup
\immediate\write-1{Package: #3 #4}%
\xdef#1{#4}%
}%
\else
\def\x#1#2[#3]{\endgroup
#2[{#3}]%
\ifx#1\@undefined
\xdef#1{#3}%
\fi
\ifx#1\relax
\xdef#1{#3}%
\fi
}%
\fi
\expandafter\x\csname [email protected]\endcsname
\ProvidesPackage{luatex}%
[2019/07/25 v0.7 LuaTeX basic definition package (HO)]%
% \end{macrocode}
%
% \subsection{Catcodes}
%
% \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
\catcode13=5 % ^^M
\endlinechar=13 %
\catcode123=1 % {
\catcode125=2 % }
\catcode64=11 % @
\def\x{\endgroup
\expandafter\edef\csname LuT@AtEnd\endcsname{%
\endlinechar=\the\endlinechar\relax
\catcode13=\the\catcode13\relax
\catcode32=\the\catcode32\relax
\catcode35=\the\catcode35\relax
\catcode61=\the\catcode61\relax
\catcode64=\the\catcode64\relax
\catcode123=\the\catcode123\relax
\catcode125=\the\catcode125\relax
}%
}%
\x\catcode61\catcode48\catcode32=10\relax%
\catcode13=5 % ^^M
\endlinechar=13 %
\catcode35=6 % #
\catcode64=11 % @
\catcode123=1 % {
\catcode125=2 % }
\def\TMP@EnsureCode#1#2{%
\edef\LuT@AtEnd{%
\LuT@AtEnd
\catcode#1=\the\catcode#1\relax
}%
\catcode#1=#2\relax
}
\TMP@EnsureCode{10}{12}% ^^J
\TMP@EnsureCode{34}{12}% "
\TMP@EnsureCode{36}{3}% $
\TMP@EnsureCode{39}{12}% '
\TMP@EnsureCode{40}{12}% (
\TMP@EnsureCode{41}{12}% )
\TMP@EnsureCode{42}{12}% *
\TMP@EnsureCode{43}{12}% +
\TMP@EnsureCode{44}{12}% ,
\TMP@EnsureCode{45}{12}% -
\TMP@EnsureCode{46}{12}% .
\TMP@EnsureCode{47}{12}% /
\TMP@EnsureCode{60}{12}% <
\TMP@EnsureCode{62}{12}% >
\TMP@EnsureCode{91}{12}% [
\TMP@EnsureCode{93}{12}% ]
\TMP@EnsureCode{95}{12}% _ (other!)
\TMP@EnsureCode{96}{12}% `
\edef\LuT@AtEnd{\LuT@AtEnd\noexpand\endinput}
% \end{macrocode}
%
% \subsection{Check for \LuaTeX}
%
% Without \LuaTeX\ there is no point in using this package.
% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
\input infwarerr.sty\relax
\input ifluatex.sty\relax
\else
\RequirePackage{infwarerr}[2007/09/09]%
\RequirePackage{ifluatex}[2009/04/10]%
\fi
% \end{macrocode}
% \begin{macrocode}
\ifluatex
\else
\@PackageError{luatex}{%
This package may only be run using LuaTeX%
}\@ehc
\expandafter\LuT@AtEnd
\fi%
% \end{macrocode}
%
% \subsection{Provide Lua\TeX\ primitives}
%
% \begin{macrocode}
\ifnum\luatexversion<36 %
\def\LuT@MakePrimitive#1{%
\expandafter\let\csname luatex#1\expandafter\endcsname
\csname #1\endcsname
}%
\else
\def\LuT@MakeLuatexPrimitive#1{%
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname luatex#1\endcsname\relax
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname #1\endcsname\relax
\else
\expandafter\let
\csname luatex#1\expandafter\endcsname
\csname #1\endcsname
\fi
\fi
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname luatex#1\endcsname\relax
\begingroup
\expandafter\let\csname luatex#1\endcsname\@undefined
\ifnum0%
\directlua{%
if tex.enableprimitives then %
tex.enableprimitives('luatex',{'#1'})%
tex.print('1')%
end%
}%
\expandafter\ifx\csname luatex#1\endcsname\relax\else1\fi
=11 %
\global\expandafter\let
\csname luatex#1\expandafter\endcsname
\csname luatex#1\endcsname
\else
\@PackageError{luatex}{%
tex.enableprimitives failed for `#1'%
}\@ehc
\fi
\endgroup
\fi
}%
\def\LuT@MakePrimitive#1{%
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname#1\endcsname\relax
\begingroup
\expandafter\let\csname#1\endcsname\@undefined
\ifnum0%
\directlua{%
if tex.enableprimitives then %
tex.enableprimitives('',{'#1'})%
tex.print('1')%
end%
}%
\expandafter\ifx\csname#1\endcsname\relax\else1\fi
=11 %
\global\expandafter\let
\csname#1\expandafter\endcsname
\csname#1\endcsname
\else
\@PackageError{luatex}{%
tex.enableprimitives failed for `#1'%
}\@ehc
\fi
\endgroup
\fi
}%
\fi
\LuT@MakeLuatexPrimitive{attribute}
\LuT@MakeLuatexPrimitive{attributedef}
\LuT@MakeLuatexPrimitive{catcodetable}
\LuT@MakeLuatexPrimitive{initcatcodetable}
\LuT@MakeLuatexPrimitive{luaescapestring}
\LuT@MakeLuatexPrimitive{savecatcodetable}
\LuT@MakePrimitive{numexpr}
% \end{macrocode}
%
% \subsection{Inherit support for \eTeX}
%
% Package \xpackage{etex} is not compatible for \plainTeX.
% But it could be present if a format is used that is based
% on \xfile{etex.src}. Therefore we only load the package
% in case of \LaTeX\ and tests its presence independently
% of the format by looking for \cs{et@xins}.
% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
\else
\RequirePackage{etex}[1998/03/26]%
\fi
% \end{macrocode}
%
% \subsection{Adaption of \eTeX's register allocation}
%
% \eTeX has increased the number of \TeX\ registers
% from $2^8$ (256) to $2^{15}$ (32768) for a register class.
% \LuaTeX\ extends the limit further to $2^16$ (65536).
% The allocation scheme of package \xpackage{etex} is not
% changed. But this can be subject for discussion.
%
% If a register class hasn't registered any local registers
% yet, then the limit can safely be pushed to 65536.
% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname et@xins\endcsname\relax
\@PackageWarningNoLine{luatex}{%
Support for eTeX is not loaded (etex.src)%
}%
\else
\def\LuT@temp#1{%
\ifnum\count27#1=32768 %
\count27#1=65536 %
\fi
}%
\LuT@temp0%
\LuT@temp1%
\LuT@temp2%
\LuT@temp3%
\LuT@temp4%
\LuT@temp5%
\LuT@temp6%
% \end{macrocode}
%
% \eTeX\ uses an array for the first 256 registers and then a tree
% structure. \LuaTeX\ stores all registers of a class in one Lua table.
% There shouldn't be large performance differences.
% This allows starting immediately in the extended
% area, leaving room for insertions.
% \begin{macrocode}
\let\newcount\globcount
\let\newdimen\globdimen
\let\newskip\globskip
\let\newbox\globbox
\fi
% \end{macrocode}
%
% \subsection{\plainTeX\ compatibility}
%
% \begin{macro}{\@empty}
% \begin{macrocode}
\expandafter\ifx\csname @empty\endcsname\relax
\def\@empty{}%
\fi
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@gobble}
% \begin{macrocode}
\expandafter\ifx\csname @gobble\endcsname\relax
\long\def\@gobble#1{}%
\fi
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@firstofone}
% \begin{macrocode}
\expandafter\ifx\csname @firstofone\endcsname\relax
\long\def\@firstofone#1{#1}%
\fi
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@firstoftwo}
% \begin{macrocode}
\expandafter\ifx\csname @firstoftwo\endcsname\relax
\long\def\@firstoftwo#1#2{#1}%
\fi
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@car}
% \begin{macrocode}
\expandafter\ifx\csname @car\endcsname\relax
\def\@car#1#2\@nil{#1}%
\fi
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@cdr}
% \begin{macrocode}
\expandafter\ifx\csname @cdr\endcsname\relax
\def\@cdr#1#2\@nil{#2}%
\fi
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@ifstar}
% \begin{macrocode}
\expandafter\ifx\csname @ifstar\endcsname\relax
\def\@ifstar#1{%
\@ifnextchar*{\@firstoftwo{#1}}%
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@ifnextchar}
% \begin{macrocode}
\long\def\@ifnextchar#1#2#3{%
\let\reserved@d=#1%
\def\reserved@a{#2}%
\def\reserved@b{#3}%
\futurelet\@let@token\@ifnch
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@ifnch}
% \begin{macrocode}
\def\@ifnch{%
\ifx\@let@token\@sptoken
\let\reserved@c\@xifnch
\else
\ifx\@let@token\reserved@d
\let\reserved@c\reserved@a
\else
\let\reserved@c\reserved@b
\fi
\fi
\reserved@c
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@sptoken}
% \begin{macrocode}
\let\LuT@temp\:%
\def\:{\let\@sptoken= }%
\: % explicit space
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@xifnch}
% \begin{macrocode}
\def\:{\@xifnch}%
\expandafter\def\: {%
\futurelet\@let@token\@ifnch
}%
\let\:\LuT@temp
\fi
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tempcnta}
% \begin{macrocode}
\expandafter\ifx\csname @tempcnta\endcsname\relax
\csname newcount\endcsname\@tempcnta
\fi
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@tempcntb}
% \begin{macrocode}
\expandafter\ifx\csname @tempcntb\endcsname\relax
\csname newcount\endcsname\@tempcntb
\fi
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LuT@newcommand}
% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname newcommand\endcsname\relax
\def\LuT@newcommand#1[#2]#3{%
\ifx#1\@undefined
\let#1\relax
\else
\ifx#1\relax
\else
\@PackageError{luatex}{%
\string#1 is already defined.\MessageBreak
Redefinition is skipped%
}\@ehc
\fi
\fi
\ifx#1\relax
\ifcase#2 %
\def#1{#3}%
\or
\def#1##1{#3}%
\or
\def#1##1##2{#3}%
\or
\def#1##1##2##3{#3}%
\or
\@INTERNAL@ERROR
\fi
\fi
}%
\else
\def\LuT@newcommand{\newcommand*}%
\fi
% \end{macrocode}
% \end{macro}
%
% \subsection{Attributes}
%
% \subsubsection{Allocation}
%
% \begin{macro}{\LuT@AllocAttribute}
% \begin{macrocode}
\newcount\LuT@AllocAttribute
\LuT@AllocAttribute=\m@ne
% \end{macrocode}
% \end{macro}
% \begin{macro}{\newattribute}
% \begin{macrocode}
\ifx\newattribute\@undefined
\LuT@newcommand\newattribute[1]{%
\ifnum\LuT@AllocAttribute<65535 %
\global\advance\LuT@AllocAttribute\@ne
\allocationnumber\LuT@AllocAttribute
\global\luatexattributedef#1=\allocationnumber
\unsetattribute{#1}%
\wlog{\string#1=\string\attribute\the\allocationnumber}%
\else
\errmessage{No room for a new \string\attribute}%
\fi
}
\fi
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Interface}
%
% \begin{macro}{\setattribute}
% \begin{macrocode}
\ifx\setattribute\@undefined
\LuT@newcommand\setattribute[2]{%
#1=\numexpr#2\relax
}
\fi
% \end{macrocode}
% \end{macro}
% \begin{macro}{\unsetattribute}
% \begin{macrocode}
\ifx\unsetattribute\@undefined
\ifnum\luatexversion<37
\LuT@newcommand\LuT@UnsetAttributeValue[0]{}%
\let\LuT@UnsetAttributeValue\m@ne
\else
\LuT@newcommand\LuT@UnsetAttributeValue[0]{-2147483647 }%
\fi
\LuT@newcommand\unsetattribute[1]{%
#1=\LuT@UnsetAttributeValue
}
\fi
% \end{macrocode}
% \end{macro}
%
% \subsection{Catcode tables}
%
% \subsubsection{Allocation}
%
% \begin{macro}{\LuT@AllocCatcodeTable}
% \begin{macrocode}
\newcount\LuT@AllocCatcodeTable
\LuT@AllocCatcodeTable=\m@ne
\newcount\CatcodeTableStack
\CatcodeTableStack=\z@
% \end{macrocode}
% \end{macro}
% \begin{macro}{\newcatcodetable}
% \begin{macrocode}
\ifx\newcatcodetable\@undefined
\LuT@newcommand\newcatcodetable[1]{%
\ifnum\LuT@AllocCatcodeTable<1114110 % 0x10FFFF is maximal \chardef
% or < 268435455 % 2^28 - 1
\global\advance\LuT@AllocCatcodeTable by\tw@
\allocationnumber=\LuT@AllocCatcodeTable
\global\chardef#1=\allocationnumber
\wlog{%
\string#1=\string\catcodetable\the\allocationnumber
}%