summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/ctablestack/ctablestack.sty
blob: 0a118a124efc6296d61286d83734d6b21ee5849f (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
\ifx
  \ProvidesPackage\undefined\begingroup\def\ProvidesPackage
    #1#2[#3]{\endgroup\immediate\write-1{Package: #1 #3}}
\fi
\ProvidesPackage{ctablestack}
  [2015/10/01 v1.0 Catcode table stable support]
\edef\ctstackatcatcode{\the\catcode`\@}
\catcode`\@=11
\ifx\newluafunction\@undefined
  \input{ltluatex}%
\fi
\def\@setcatcodetable#1#2{%
  \begingroup
    #2%
    \savecatcodetable#1%
  \endgroup
}
\def\@setrangecatcode#1#2#3{%
  \ifnum#1>#2 %
    \expandafter\@gobble
  \else
    \expandafter\@firstofone
  \fi
    {%
      \catcode#1=#3 %
      \expandafter\@setrangecatcode\expandafter
        {\number\numexpr#1+1\relax}{#2}{#3}%
    }%
}
\def\@catcodetablelist{}
\def\@catcodetablestack{}
\newcount\@catcodetablestackcnt
\def\@pushcatcodetable{%
  \ifx\@catcodetablelist\empty
    \global\advance\@catcodetablestackcnt by\@ne
    \edef\@tempa{\csname ct@\the\@catcodetablestackcnt\endcsname}%
    \expandafter\newcatcodetable\@tempa
    \xdef\@catcodetablelist{\@tempa}%
  \fi
  \expandafter\@pushctbl\@catcodetablelist\@nil
}
\def\@pushctbl#1#2\@nil{%
  \gdef\@catcodetablelist{#2}%
  \xdef\@catcodetablestack{#1\@catcodetablestack}%
  \savecatcodetable#1%
}
\def\@popcatcodetable{%
  \if!\@catcodetablestack!%
    \errmessage{Attempt to pop empty catcodetable stack}%
  \else
    \expandafter\@popctbl\@catcodetablestack\@nil
  \fi
}
\def\@popctbl#1#2\@nil{%
  \gdef\@catcodetablestack{#2}%
  \xdef\@catcodetablelist{\@catcodetablelist#1}%
  \catcodetable#1%
}
\catcode`\@\ctstackatcatcode\relax