summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/oberdiek/luatex.dtx
blob: ea11f64bd6ce9e55b75e758eeace4248d3dbe80b (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
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
% \iffalse meta-comment
%
% File: luatex.dtx
% Version: 2016/05/16 v0.6
% Info: LuaTeX basic definition package
%
% Copyright (C) 2007, 2009, 2010 by
%    Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%    2016
%    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
%    http://www.latex-project.org/lppl/lppl-1-3c.txt
% and the latest version of this license is in
%    http://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".
%
% This Current Maintainer of this work is Heiko Oberdiek.
%
% 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:doc/latex/oberdiek/test/luatex-test1.tex
%    TDS:doc/latex/oberdiek/test/luatex-test2.tex
%    TDS:doc/latex/oberdiek/test/luatex-test3.tex
%    TDS:doc/latex/oberdiek/test/luatex-test4.tex
%    TDS:doc/latex/oberdiek/test/luatex-test5.tex
%    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 2016/05/16 v0.6 LuaTeX basic definition package (HO)}
\Msg{************************************************************************}

\keepsilent
\askforoverwritefalse

\let\MetaPrefix\relax
\preamble

This is a generated file.

Project: luatex
Version: 2016/05/16 v0.6

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
   http://www.latex-project.org/lppl/lppl-1-3c.txt
and the latest version of this license is in
   http://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".

This Current Maintainer of this work is Heiko Oberdiek.

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}}%
  \nopreamble
  \nopostamble
  \usedir{source/latex/oberdiek/catalogue}%
  \file{luatex.xml}{\from{luatex.dtx}{catalogue}}%
}
\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}%
  [2016/05/16 v0.6 LuaTeX basic definition package (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}[2011/11/22]
\usepackage{paralist}
\begin{document}
  \DocInput{luatex.dtx}%
\end{document}
%</driver>
% \fi
%
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \GetFileInfo{luatex.drv}
%
% \title{The \xpackage{luatex} package}
% \date{2016/05/16 v0.6}
% \author{Heiko Oberdiek\thanks
% {Please report any issues at https://github.com/ho-tex/oberdiek/issues}\\
% \xemail{heiko.oberdiek at googlemail.com}}
%
% \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}
%
% \LaTeXe\ is frozen and therefore refuses to even notice
% the new \TeX\ variants. Not even the old \eTeX\ is supported
% by its kernel. At least there is a third party package \xpackage{etex}
% that manages the new \eTeX\ resources.
%
% This package tries to do the same for \LuaTeX\ and starts to
% support at least a few of the new features.
%
% \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 ver@luatex.sty\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 ver@luatex.sty\endcsname
\ProvidesPackage{luatex}%
  [2016/05/16 v0.6 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
    }%
  \else
    \errmessage{No room for a new \string\catcodetable}%
  \fi
}%
\fi
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\IncCatcodeTableStack}
%    \begin{macrocode}
\LuT@newcommand\IncCatcodeTableStack[0]{%
  \ifnum\CatcodeTableStack<268435454 %
    \global\advance\CatcodeTableStack by\tw@
  \else
    \@PackageError{luatex}{%
      Catcode table stack overflow%
    }\@ehd
  \fi
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\DecCatcodeTableStack}
%    \begin{macrocode}
\LuT@newcommand\DecCatcodeTableStack[0]{%
  \ifnum\CatcodeTableStack>\z@
    \global\advance\CatcodeTableStack by-2 %
  \else
    \@PackageError{luatex}{%
      Catcode table stack is empty%
    }\@ehd
  \fi
}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{\cs{SetCatcodeRange}}
%
%    \begin{macro}{\SetCatcodeRange}
%    \begin{macrocode}
\LuT@newcommand\SetCatcodeRange[3]{%
  \edef\LuT@temp{%
    \noexpand\@tempcnta=\the\@tempcnta
    \noexpand\@tempcntb=\the\@tempcntb
    \noexpand\count@=\the\count@
    \relax
  }%
  \@tempcnta=\numexpr#1\relax
  \@tempcntb=\numexpr#2\relax
  \count@=\numexpr#3\relax
  \loop
    \unless\ifnum\@tempcnta>\@tempcntb
    \catcode\@tempcnta=\count@
    \advance\@tempcnta by \@ne
  \repeat
  \LuT@temp
}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{Predefined catcode tables}
%
%    \begin{macrocode}
\newcatcodetable\CatcodeTableIniTeX
\newcatcodetable\CatcodeTableString
\newcatcodetable\CatcodeTableOther
\newcatcodetable\CatcodeTableLaTeX
%    \end{macrocode}
%
%    \begin{macrocode}
\luatexinitcatcodetable\CatcodeTableIniTeX
\begingroup
  \def\@makeother#1{\catcode#1=12\relax}%
  \@firstofone{%
    \luatexcatcodetable\CatcodeTableIniTeX
    \begingroup
      \SetCatcodeRange{0}{8}{15}%
      \catcode9=10 % tab
      \catcode11=15 %
      \catcode12=13 % form feed
      \SetCatcodeRange{14}{31}{15}%
      \catcode35=6 % hash
      \catcode36=3 % dollar
      \catcode38=4 % ampersand
      \catcode94=7 % circumflex
      \catcode95=8 % underscore
      \catcode123=1 % brace left
      \catcode125=2 % brace right
      \catcode126=13 % tilde
      \catcode127=15 %
      \luatexsavecatcodetable\CatcodeTableLaTeX
    \endgroup
    \@makeother{0}% nul
    \@makeother{13}% carriage return
    \@makeother{37}% percent
    \@makeother{92}% backslash
    \@makeother{127}%
    \SetCatcodeRange{65}{90}{12}% A-Z
    \SetCatcodeRange{97}{122}{12}% a-z
    \luatexsavecatcodetable\CatcodeTableString
    \@makeother{32}% space
    \luatexsavecatcodetable\CatcodeTableOther
  \endgroup
}%
%    \end{macrocode}
%
% \subsubsection{Number stack}
%
%    \begin{macro}{\LuT@NumStackEmpty}
%    A special empty stack value because of \cs{@cdr}'s brace removal.
%    \begin{macrocode}
\def\LuT@NumStackEmpty{0}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\LuT@NumStack}
%    \begin{macrocode}
\let\LuT@NumStack\LuT@NumStackEmpty
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\PushCatcodeTableNumStack}
%    \begin{macrocode}
\LuT@newcommand\PushCatcodeTableNumStack[0]{%
  \xdef\LuT@NumStack{%
    {\the\luatexcatcodetable}\LuT@NumStack
  }%
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\PopCatcodeTableNumStack}
%    \begin{macrocode}
\LuT@newcommand\PopCatcodeTableNumStack[0]{%
  \ifx\LuT@NumStack\LuT@NumStackEmpty
    \@PackageWarning{luatex}{Empty catcode table number stack}%
    \luatexcatcodetable\z@
  \else
    \luatexcatcodetable=\expandafter\@car\LuT@NumStack\@nil\relax
    \xdef\LuT@NumStack{%
      \expandafter\@cdr\LuT@NumStack\@nil
    }%
  \fi
}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{Catcode regime macros}
%
%    \begin{macro}{\BeginCatcodeRegime}
%    \begin{macrocode}
\LuT@newcommand\BeginCatcodeRegime[1]{%
  \PushCatcodeTableNumStack
  \luatexcatcodetable=\numexpr#1\relax
  \IncCatcodeTableStack
  \luatexsavecatcodetable\CatcodeTableStack
  \luatexcatcodetable\CatcodeTableStack
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\EndCatcodeRegime}
%    \begin{macrocode}
\LuT@newcommand\EndCatcodeRegime[0]{%
  \DecCatcodeTableStack
  \PopCatcodeTableNumStack
}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{Lua module loader}
%
%    \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
  \input luatex-loader.sty\relax
\else
  \RequirePackage{luatex-loader}[2010/03/09]%
\fi
%    \end{macrocode}
%    \begin{macrocode}
\LuT@AtEnd%
%</package>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*loader>
%    \end{macrocode}
%
%    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 ver@luatex-loader.sty\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-loader}{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 ver@luatex-loader.sty\endcsname
\ProvidesPackage{luatex-loader}%
  [2016/05/16 v0.6 Lua module loader (HO)]%
%    \end{macrocode}
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5\endlinechar=13\relax%
  \catcode10=12 % ^^J
  \catcode34=12 % "
  \catcode39=12 % '
  \catcode40=12 % (
  \catcode41=12 % )
  \catcode44=12 % ,
  \catcode46=12 % .
  \catcode60=12 % <
  \catcode61=12 % =
  \catcode95=12 % _ (other!)
  \catcode96=12 % `
  \catcode123=1 % {
  \catcode125=2 % }
  \endlinechar=10 %
  \ifnum\luatexversion<36 %
    \directlua0%
  \else %
    \expandafter\directlua %
  \fi %
  {%
     do
      local script = "oberdiek.luatex.lua"
      local file = kpse.find_file(script, "texmfscripts")
      if file then
        texio.write_nl("(" .. file .. ")")
        dofile(file)
      else
        error("File `" .. script .. "' not found")
      end
    end
  }%
\endgroup\endinput%
%    \end{macrocode}
%
%    \begin{macrocode}
%</loader>
%    \end{macrocode}
%
% \subsection{Lua script}
%
%    Currently \LuaTeX\ does not use KPSE when searching for module
%    files. The following Lua script implements a workaround.
%    It extends |package.loader| by another search method.
%    Modules are found by the module name with extension \xext{lua}
%    similar to
%    \begin{quote}
%      \ttfamily |kpsewhich --format=texmfscripts| \meta{module}|.lua|
%    \end{quote}
%    Unhappily \textsf{kpsewhich} does not support directory components
%    in the file name. Therefore a module |a.b.c| cannot be installed
%    as \xfile{a/b/c.lua}. The script must be named \xfile{a.b.c.lua}.
%    \begin{macrocode}
%<*lua>
%    \end{macrocode}
%    \begin{macrocode}
module("oberdiek.luatex", package.seeall)
%    \end{macrocode}
%    \begin{macrocode}
function kpse_module_loader(module)
  local script = module .. ".lua"
  local file = kpse.find_file(script, "texmfscripts")
  if file then
    local loader, error = loadfile(file)
    if loader then
      texio.write_nl("(" .. file .. ")")
      return loader
    end
    return "\n\t[oberdiek.luatex.kpse_module_loader] Loading error:\n\t"
           .. error
  end
  return "\n\t[oberdiek.luatex.kpse_module_loader] Search failed"
end
%    \end{macrocode}
% following line changed to use package.searchers instead of
% package.loaders for current luatex; this is the only change in the
% code.  eroux, 28apr13, (or package.loaders), 29mar14.
%    \begin{macrocode}
table.insert(package.searchers or package.loaders, kpse_module_loader)
%    \end{macrocode}
%    \begin{macrocode}
%</lua>
%    \end{macrocode}
%
% \section{Test}
%
%    \begin{macrocode}
%<*test2>
\documentclass{article}
\def\LoadCommand{%
  \RequirePackage{luatex}[2010/03/09]%
}
%</test2>
%    \end{macrocode}
%    \begin{macrocode}
%<*test3>
\documentclass{article}
\def\LoadCommand{%
  \RequirePackage{luatex-loader}[2010/03/09]%
}
%</test3>
%    \end{macrocode}
% \subsection{Catcode checks for loading}
%
%    \begin{macrocode}
%<*test1>
%    \end{macrocode}
%    \begin{macrocode}
\catcode`\{=1 %
\catcode`\}=2 %
\catcode`\#=6 %
\catcode`\@=11 %
\expandafter\ifx\csname count@\endcsname\relax
  \countdef\count@=255 %
\fi
\expandafter\ifx\csname @gobble\endcsname\relax
  \long\def\@gobble#1{}%
\fi
\expandafter\ifx\csname @firstofone\endcsname\relax
  \long\def\@firstofone#1{#1}%
\fi
\expandafter\ifx\csname loop\endcsname\relax
  \expandafter\@firstofone
\else
  \expandafter\@gobble
\fi
{%
  \def\loop#1\repeat{%
    \def\body{#1}%
    \iterate
  }%
  \def\iterate{%
    \body
      \let\next\iterate
    \else
      \let\next\relax
    \fi
    \next
  }%
  \let\repeat=\fi
}%
\def\RestoreCatcodes{}
\count@=0 %
\loop
  \edef\RestoreCatcodes{%
    \RestoreCatcodes
    \catcode\the\count@=\the\catcode\count@\relax
  }%
\ifnum\count@<255 %
  \advance\count@ 1 %
\repeat

\def\RangeCatcodeInvalid#1#2{%
  \count@=#1\relax
  \loop
    \catcode\count@=15 %
  \ifnum\count@<#2\relax
    \advance\count@ 1 %
  \repeat
}
\def\RangeCatcodeCheck#1#2#3{%
  \count@=#1\relax
  \loop
    \ifnum#3=\catcode\count@
    \else
      \errmessage{%
        Character \the\count@\space
        with wrong catcode \the\catcode\count@\space
        instead of \number#3%
      }%
    \fi
  \ifnum\count@<#2\relax
    \advance\count@ 1 %
  \repeat
}
\def\space{ }
\expandafter\ifx\csname LoadCommand\endcsname\relax
  \def\LoadCommand{\input luatex.sty\relax}%
\fi
\def\Test{%
  \RangeCatcodeInvalid{0}{47}%
  \RangeCatcodeInvalid{58}{64}%
  \RangeCatcodeInvalid{91}{96}%
  \RangeCatcodeInvalid{123}{255}%
  \catcode`\@=12 %
  \catcode`\\=0 %
  \catcode`\%=14 %
  \LoadCommand
  \RangeCatcodeCheck{0}{36}{15}%
  \RangeCatcodeCheck{37}{37}{14}%
  \RangeCatcodeCheck{38}{47}{15}%
  \RangeCatcodeCheck{48}{57}{12}%
  \RangeCatcodeCheck{58}{63}{15}%
  \RangeCatcodeCheck{64}{64}{12}%
  \RangeCatcodeCheck{65}{90}{11}%
  \RangeCatcodeCheck{91}{91}{15}%
  \RangeCatcodeCheck{92}{92}{0}%
  \RangeCatcodeCheck{93}{96}{15}%
  \RangeCatcodeCheck{97}{122}{11}%
  \RangeCatcodeCheck{123}{255}{15}%
  \RestoreCatcodes
}
\Test
\csname @@end\endcsname
\end
%    \end{macrocode}
%    \begin{macrocode}
%</test1>
%    \end{macrocode}
%
% \subsection{Catcode tables}
%
% \subsubsection{Predefined catcode tables}
%
%    \begin{macrocode}
%<*test4>
\NeedsTeXFormat{LaTeX2e}
%    \end{macrocode}
%    Remember \LaTeX's initial catcodes in count registers
%    starting at \cs{TestLaTeX}.
%    \begin{macrocode}
\count0=0 %
\chardef\TestLaTeX=1000 %
\chardef\TestMax=300 %
\loop
  \count\numexpr\TestLaTeX+\count0\relax=\catcode\count0 %
\ifnum\count0<\TestMax
  \advance\count0 by 1 %
\repeat
\documentclass{minimal}
\usepackage{luatex}[2010/03/09]
\usepackage{qstest}
\IncludeTests{*}
\LogTests{log}{*}{*}
\makeatletter
\def\Check#1{%
  \Expect*{\the\count@=\the\catcode\count@}%
         *{\the\count@=#1}%
}
\newcount\scratch
\def\Test#1#2{%
  \begin{qstest}{CatcodeTable#1}{CatcodeTable#1}%
    \luatexcatcodetable\csname CatcodeTable#1\endcsname
    \count@=\z@
    \loop
      \scratch=#2\relax
      \Expect*{\the\count@=\the\catcode\count@}%
             *{\the\count@=\the\scratch}%
    \ifnum\count@<\TestMax
      \advance\count@\@ne
    \repeat
  \end{qstest}%
}
\begingroup
  % luatex-unicode-letters.tex makes some slots to letters
  \def\TestMax{169}%
  \Test{LaTeX}{\the\count\numexpr\TestLaTeX+\count@}%
\endgroup
\Test{String}{\ifnum\count@=32 10\else 12\fi}
\Test{Other}{12}
\luatexinitcatcodetable99 %
\Test{IniTeX}{%
  0\relax
  \begingroup
    \luatexcatcodetable99 %
    \global\scratch=\the\catcode\count@
  \endgroup
}
%    \end{macrocode}
%
% \subsubsection{Catcode table number stack}
%
%    \begin{macrocode}
\begin{qstest}{CatcodeTableNumStack}{CatcodeTableNumStack}
  \def\TestStack#1{%
    \Expect*{\LuT@NumStack}{#1}%
  }%
  \TestStack{0}%
  \PushCatcodeTableNumStack
  \TestStack{{0}0}%
  \@firstofone{%
    \begingroup
      \luatexinitcatcodetable12 %
      \luatexcatcodetable12 %
      \PushCatcodeTableNumStack
      \TestStack{{12}{0}0}%
      \PopCatcodeTableNumStack
      \TestStack{{0}0}%
      \PopCatcodeTableNumStack
      \TestStack{0}%
      \def\TestWarning{Missing empty stack warning}%
      \def\@PackageWarning#1#2{\def\TestWarning{empty stack}}%
      \PopCatcodeTableNumStack
      \TestStack{0}%
      \Expect*{\TestWarning}{empty stack}%
    \endgroup
  }%
\end{qstest}
%    \end{macrocode}
%
% \subsubsection{Catcode table stack}
%
%    \begin{macrocode}
\begin{qstest}{CatcodeTableStack}{CatcodeTableStack}
  \def\TestStack#1{%
    \Expect*{\the\CatcodeTableStack}{#1}%
  }%
  \TestStack{0}%
  \IncCatcodeTableStack
  \TestStack{2}%
  \IncCatcodeTableStack
  \TestStack{4}%
  \begingroup
    \IncCatcodeTableStack
    \TestStack{6}%
  \endgroup
  \TestStack{6}%
  \begingroup
    \DecCatcodeTableStack
    \TestStack{4}%
  \endgroup
  \TestStack{4}%
  \DecCatcodeTableStack
  \TestStack{2}%
  \DecCatcodeTableStack
  \TestStack{0}%
  \begingroup
    \def\TestError{Missing error}%
    \def\@PackageError#1#2#3{%
      \def\TestError{Empty stack}%
    }%
    \DecCatcodeTableStack
    \TestStack{0}%
    \Expect*{\TestError}{Empty stack}%
  \endgroup
\end{qstest}
%    \end{macrocode}
%
% \subsubsection{Catcode regime macros}
%
%    \begin{macrocode}
\begin{qstest}{CatcodeRegime}{CatcodeRegime}
  \def\TestStacks#1#2#3{%
    \Expect*{\the\luatexcatcodetable}{#1}%
    \Expect*{\the\CatcodeTableStack}{#2}%
    \Expect*{\LuT@NumStack}{#3}%
  }%
  \TestStacks{0}{0}{0}%
  \catcode`\|=7 %
  \BeginCatcodeRegime\CatcodeTableLaTeX
    \TestStacks{2}{2}{{0}0}%
    \Expect*{\the\catcode`\|}{12}%
  \EndCatcodeRegime
  \TestStacks{0}{0}{0}%
  \Expect*{\the\catcode`\|}{7}%
\end{qstest}
%    \end{macrocode}
%
% \subsection{Attribute allocation}
%
%    \begin{macrocode}
\begin{qstest}{Attributes}{Attributes}
  \newattribute\TestAttr
  \Expect*{\meaning\TestAttr}%
         *{\string\attribute\number\allocationnumber}%
  \Expect*{\the\allocationnumber}{0}%
  \begingroup
    \newattribute\TestAttr
    \Expect*{\the\allocationnumber}{1}%
  \endgroup
  \Expect*{\the\allocationnumber}{0}%
  \Expect*{\meaning\TestAttr}*{\string\attribute1}%
  \Expect*{\the\TestAttr}*{\number\LuT@UnsetAttributeValue}%
  \def\Test#1{%
    \setattribute\TestAttr{#1}%
    \Expect*{\the\TestAttr}{#1}%
  }%
  \Test{0}%
  \Test{1}%
  \Test{-1}%
  \Test{123}%
  \unsetattribute\TestAttr
  \Expect*{\the\TestAttr}*{\number\LuT@UnsetAttributeValue}%
  \begingroup
    \Expect*{\the\TestAttr}*{\number\LuT@UnsetAttributeValue}%
    \Test{1234}%
  \endgroup
  \Expect*{\the\TestAttr}*{\number\LuT@UnsetAttributeValue}%
\end{qstest}
%    \end{macrocode}
%
%    \begin{macrocode}
\@@end
%</test4>
%    \end{macrocode}
%
% \subsection{Short test for \plainTeX}
%
%    \begin{macrocode}
%<*test5>
\input luatex.sty\relax
\newattribute\TestAttr
\setattribute\TestAttr{10}
\unsetattribute\TestAttr
\newcatcodetable\TestCTa
\begingroup
  \SetCatcodeRange{`A}{`Z}{12}%
\endgroup
\BeginCatcodeRegime\CatcodeTableLaTeX
\EndCatcodeRegime
\end
%</test5>
%    \end{macrocode}
%
% \section{Installation}
%
% \subsection{Download}
%
% \paragraph{Package.} This package is available on
% CTAN\footnote{\url{http://ctan.org/pkg/luatex}}:
% \begin{description}
% \item[\CTAN{macros/latex/contrib/oberdiek/luatex.dtx}] The source file.
% \item[\CTAN{macros/latex/contrib/oberdiek/luatex.pdf}] Documentation.
% \end{description}
%
%
% \paragraph{Bundle.} All the packages of the bundle `oberdiek'
% are also available in a TDS compliant ZIP archive. There
% the packages are already unpacked and the documentation files
% are generated. The files and directories obey the TDS standard.
% \begin{description}
% \item[\CTAN{install/macros/latex/contrib/oberdiek.tds.zip}]
% \end{description}
% \emph{TDS} refers to the standard ``A Directory Structure
% for \TeX\ Files'' (\CTAN{tds/tds.pdf}). Directories
% with \xfile{texmf} in their name are usually organized this way.
%
% \subsection{Bundle installation}
%
% \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the
% TDS tree (also known as \xfile{texmf} tree) of your choice.
% Example (linux):
% \begin{quote}
%   |unzip oberdiek.tds.zip -d ~/texmf|
% \end{quote}
%
% \paragraph{Script installation.}
% Check the directory \xfile{TDS:scripts/oberdiek/} for
% scripts that need further installation steps.
% Package \xpackage{attachfile2} comes with the Perl script
% \xfile{pdfatfi.pl} that should be installed in such a way
% that it can be called as \texttt{pdfatfi}.
% Example (linux):
% \begin{quote}
%   |chmod +x scripts/oberdiek/pdfatfi.pl|\\
%   |cp scripts/oberdiek/pdfatfi.pl /usr/local/bin/|
% \end{quote}
%
% \subsection{Package installation}
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip\ archive. The files are extracted by running the
% \xfile{.dtx} through \plainTeX:
% \begin{quote}
%   \verb|tex luatex.dtx|
% \end{quote}
%
% \paragraph{TDS.} Now the different files must be moved into
% the different directories in your installation TDS tree
% (also known as \xfile{texmf} tree):
% \begin{quote}
% \def\t{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
%   luatex.sty & tex/generic/oberdiek/luatex.sty\\
%   luatex-loader.sty & tex/generic/oberdiek/luatex-loader.sty\\
%   oberdiek.luatex.lua & scripts/oberdiek/oberdiek.luatex.lua\\
%   luatex.pdf & doc/latex/oberdiek/luatex.pdf\\
%   test/luatex-test1.tex & doc/latex/oberdiek/test/luatex-test1.tex\\
%   test/luatex-test2.tex & doc/latex/oberdiek/test/luatex-test2.tex\\
%   test/luatex-test3.tex & doc/latex/oberdiek/test/luatex-test3.tex\\
%   test/luatex-test4.tex & doc/latex/oberdiek/test/luatex-test4.tex\\
%   test/luatex-test5.tex & doc/latex/oberdiek/test/luatex-test5.tex\\
%   luatex.dtx & source/latex/oberdiek/luatex.dtx\\
% \end{tabular}^^A
% }^^A
% \sbox0{\t}^^A
% \ifdim\wd0>\linewidth
%   \begingroup
%     \advance\linewidth by\leftmargin
%     \advance\linewidth by\rightmargin
%   \edef\x{\endgroup
%     \def\noexpand\lw{\the\linewidth}^^A
%   }\x
%   \def\lwbox{^^A
%     \leavevmode
%     \hbox to \linewidth{^^A
%       \kern-\leftmargin\relax
%       \hss
%       \usebox0
%       \hss
%       \kern-\rightmargin\relax
%     }^^A
%   }^^A
%   \ifdim\wd0>\lw
%     \sbox0{\small\t}^^A
%     \ifdim\wd0>\linewidth
%       \ifdim\wd0>\lw
%         \sbox0{\footnotesize\t}^^A
%         \ifdim\wd0>\linewidth
%           \ifdim\wd0>\lw
%             \sbox0{\scriptsize\t}^^A
%             \ifdim\wd0>\linewidth
%               \ifdim\wd0>\lw
%                 \sbox0{\tiny\t}^^A
%                 \ifdim\wd0>\linewidth
%                   \lwbox
%                 \else
%                   \usebox0
%                 \fi
%               \else
%                 \lwbox
%               \fi
%             \else
%               \usebox0
%             \fi
%           \else
%             \lwbox
%           \fi
%         \else
%           \usebox0
%         \fi
%       \else
%         \lwbox
%       \fi
%     \else
%       \usebox0
%     \fi
%   \else
%     \lwbox
%   \fi
% \else
%   \usebox0
% \fi
% \end{quote}
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
% TDS installing feature, then some files can already be in the right
% place, see the documentation of \docstrip.
%
% \subsection{Refresh file name databases}
%
% If your \TeX~distribution
% (\teTeX, \mikTeX, \dots) relies on file name databases, you must refresh
% these. For example, \teTeX\ users run \verb|texhash| or
% \verb|mktexlsr|.
%
% \subsection{Some details for the interested}
%
% \paragraph{Attached source.}
%
% The PDF documentation on CTAN also includes the
% \xfile{.dtx} source file. It can be extracted by
% AcrobatReader 6 or higher. Another option is \textsf{pdftk},
% e.g. unpack the file into the current directory:
% \begin{quote}
%   \verb|pdftk luatex.pdf unpack_files output .|
% \end{quote}
%
% \paragraph{Unpacking with \LaTeX.}
% The \xfile{.dtx} chooses its action depending on the format:
% \begin{description}
% \item[\plainTeX:] Run \docstrip\ and extract the files.
% \item[\LaTeX:] Generate the documentation.
% \end{description}
% If you insist on using \LaTeX\ for \docstrip\ (really,
% \docstrip\ does not need \LaTeX), then inform the autodetect routine
% about your intention:
% \begin{quote}
%   \verb|latex \let\install=y\input{luatex.dtx}|
% \end{quote}
% Do not forget to quote the argument according to the demands
% of your shell.
%
% \paragraph{Generating the documentation.}
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
% the documentation. The process can be configured by the
% configuration file \xfile{ltxdoc.cfg}. For instance, put this
% line into this file, if you want to have A4 as paper format:
% \begin{quote}
%   \verb|\PassOptionsToClass{a4paper}{article}|
% \end{quote}
% An example follows how to generate the
% documentation with pdf\LaTeX:
% \begin{quote}
%\begin{verbatim}
%pdflatex luatex.dtx
%makeindex -s gind.ist luatex.idx
%pdflatex luatex.dtx
%makeindex -s gind.ist luatex.idx
%pdflatex luatex.dtx
%\end{verbatim}
% \end{quote}
%
% \section{Catalogue}
%
% The following XML file can be used as source for the
% \href{http://mirror.ctan.org/help/Catalogue/catalogue.html}{\TeX\ Catalogue}.
% The elements \texttt{caption} and \texttt{description} are imported
% from the original XML file from the Catalogue.
% The name of the XML file in the Catalogue is \xfile{luatex.xml}.
%    \begin{macrocode}
%<*catalogue>
<?xml version='1.0' encoding='us-ascii'?>
<!DOCTYPE entry SYSTEM 'catalogue.dtd'>
<entry datestamp='$Date$' modifier='$Author$' id='luatex'>
  <name>luatex</name>
  <caption>The LuaTeX engine.</caption>
  <authorref id='auth:oberdiek'/>
  <copyright owner='Heiko Oberdiek' year='2007,2009,2010'/>
  <license type='lppl1.3'/>
  <version number='0.6'/>
  <description>
    LuaTeX is an extended version of pdfTeX using Lua as an embedded
    scripting language.  The LuaTeX project&#x2019;s main objective
    is to provide an open and configurable variant of TeX while at the
    same time offering downward compatibility.
    <p/>
    LuaTeX uses Unicode (as UTF-8) as its default input encoding, and
    is able to use modern (OpenType) fonts (for both text and mathematics).
    <p/>
    It should be noted that LuaTeX is still under development; its
    specification has been declared stable, but absolute stability
    may not in practice be assumed.
    <p/>
    The package is part of the <xref refid='oberdiek'>oberdiek</xref> bundle.
  </description>
  <documentation details='Package documentation'
      href='ctan:/macros/latex/contrib/oberdiek/luatex.pdf'/>
  <ctan file='true' path='/macros/latex/contrib/oberdiek/luatex.dtx'/>
  <miktex location='oberdiek'/>
  <texlive location='oberdiek'/>
  <install path='/macros/latex/contrib/oberdiek/oberdiek.tds.zip'/>
</entry>
%</catalogue>
%    \end{macrocode}
%
% \begin{History}
%   \begin{Version}{2007/12/12 v0.1}
%   \item
%     First public version.
%   \end{Version}
%   \begin{Version}{2009/04/10 v0.2}
%   \item
%     Requires package \xpackage{ifluatex} in version 2.0 to ensure
%     \cs{luatexversion}.
%   \item
%     Updates the call of \cs{directlua}, the syntax has changed
%     in \LuaTeX\ 0.36.
%   \end{Version}
%   \begin{Version}{2009/12/02 v0.3}
%   \item
%     Unsetting of attributes updated for \LuaTeX\ 0.37.
%   \end{Version}
%   \begin{Version}{2010/03/09 v0.4}
%   \item
%     Support for lua states removed.
%   \item
%     Calling tex.enableprimitives for used primitives.
%   \end{Version}
%   \begin{Version}{2016/05/10 v0.5}
%   \item
%    Use package.searchers
%   \item only conditionally define commands such as
%   \verb|\newcatcodetable|
%   that are now defined in the Lua\LaTeX\ format.
%   \end{Version}
%   \begin{Version}{2016/05/16 v0.6}
%   \item
%     Documentation updates.
%   \end{Version}
% \end{History}
%
% \PrintIndex
%
% \Finale
\endinput