4 % Modified from jlisting.sty (by Thor) for LuaTeX-ja.
7 \NeedsTeXFormat{LaTeX2e}
8 \def\filedate{2012/01/11}
10 \ProvidesPackage{lltjp-listings}[\filedate\space\fileversion]
11 \RequirePackage{listings}
12 \newcount\lst@nextchar
13 \let\lst@@ProcessSpace\lst@ProcessSpace
14 \def\lst@ProcessSpace#1{%
15 \lst@check@chartype{#1}%
18 \let\lst@@ProcessLetter\lst@ProcessLetter
19 \def\lst@ProcessLetter#1#2{%
20 \lst@check@chartype{#2}%
21 {\lst@@ProcessLetter{#1}}%
23 \let\lst@@ProcessDigit\lst@ProcessDigit
24 \def\lst@ProcessDigit#1#2{%
25 \lst@check@chartype{#2}%
26 {\lst@@ProcessDigit{#1}}%
28 \let\lst@@ProcessOther\lst@ProcessOther
29 \def\lst@ProcessOther#1#2{%
30 \lst@check@chartype{#2}%
31 {\lst@@ProcessOther{#1}}%
33 \let\lst@@ProcessTabulator\lst@ProcessTabulator
34 \def\lst@ProcessTabulator#1{%
35 \lst@check@chartype{#1}%
36 \lst@@ProcessTabulator
38 \def\lst@check@chartype#1#2#3{%
39 \edef\@tempa{\lst@nextchar=`\string#1\relax}%
40 \afterassignment\remove@to@nnil
43 \ifnum\lst@nextchar<\@cclvi
46 \lst@ifletter \else \lst@OutputOther \fi
48 \expandafter\lst@AppendJchar
51 \def\lst@Append#1{\advance\lst@length\@ne%
52 \lst@token=\expandafter{\the\lst@token#1}}
53 \def\lst@AppendJchar#1#2{%
54 \lst@check@chartype{#2}%
55 {\advance\lst@length\@ne\lst@Append{#1}}%
57 \def\lst@check@chartype@BOL#1{%
58 \edef\@tempa{\lst@nextchar=`\string#1\relax}%
59 \afterassignment\remove@to@nnil
61 \ifnum\lst@nextchar<\@cclvi\else
63 \expandafter\lst@AppendJchar
66 \def\lst@InputListing#1{%
68 \lsthk@PreSet \gdef\lst@intname{#1}%
69 \expandafter\lstset\expandafter{\lst@set}%
71 \catcode\active=\active
72 \lst@Init\relax \let\lst@gobble\z@
74 \lst@ifprint \def\lst@next{\lst@get@filecontents{#1}}%
75 \else \let\lst@next\@empty
80 \newread\lst@inputfile
81 \def\lst@get@filecontents#1{%
82 \let\lst@filecontents\@empty
83 \openin\lst@inputfile=#1\relax
84 \let\@lst@get@filecontents@prevline\relax
85 \lst@get@filecontents@loop
86 \closein\lst@inputfile
87 \lst@filecontents\empty}
88 \def\lst@get@filecontents@loop{%
89 \read\lst@inputfile to\@lst@get@filecontents@currline
90 \ifx\@lst@get@filecontents@prevline\relax\else
91 \expandafter\expandafter\expandafter\def
92 \expandafter\expandafter\expandafter\lst@filecontents
93 \expandafter\expandafter\expandafter{%
94 \expandafter\lst@filecontents\@lst@get@filecontents@prevline}%
96 \let\@lst@get@filecontents@prevline\@lst@get@filecontents@currline
97 \ifeof\lst@inputfile\else
98 \expandafter\lst@get@filecontents@loop
102 \ifnum\lst@gobble>\z@
103 \@tempcnta\lst@gobble\relax
104 \expandafter\lst@BOLGobble@
106 \expandafter\lst@check@chartype@BOL
108 \def\lst@BOLGobble@#1{%
110 \ifx \lst@next\relax\else
111 \ifx \lst@next\lst@MProcessListing\else
112 \ifx \lst@next\lst@ProcessFormFeed\else
113 \ifx \lst@next\lstenv@backslash
114 \let\lst@next\lstenv@BOLGobble@@
116 \let\lst@next\lst@BOLGobble@@
117 \ifx #1\lst@ProcessTabulator
118 \advance\@tempcnta-\lst@tabsize\relax
120 \lst@length-\@tempcnta \lst@PreGotoTabStop
123 \edef\@tempa{\lst@nextchar=`\string#1\relax}%
125 \ifnum\lst@nextchar<\@cclvi\else
126 \advance\@tempcnta\m@ne
128 \advance\@tempcnta\m@ne
132 \def\lst@BOLGobble@@{%
134 \expandafter\lst@BOLGobble@
136 \expandafter\lst@check@chartype@BOL
143 \gdef\lst@breakProcessOther#1{\lst@ProcessOther#1}
144 % ソースコード目次における文字と番号の空き
145 \let \l@lstlisting = \l@figure
146 % キャプションとソースコード目次に対する日本語対応
147 \def\lstlistingname{ソースコード}
148 \def\lstlistlistingname{ソースコード目次}
152 % Changes for LuaTeX-ja:
153 % 1. \char"FFFFF は通常行末用コメント文字として使われる.
154 % \catcode"FFFFF を変更しないと \lstnewenvironment{env}[1] ...
155 % による env 環境等が異常動作(x19290 さんの報告)
156 \lst@AddToHook{Init}{\catcode"FFFFF=9\relax}
157 \lst@AddToHook{EOL}{\catcode"FFFFF=14\relax}
159 % 2. listing な環境の処理中に \DeclareFontShape の (s)sub が実行されると,なぜか
160 % ! Use of set@size@funct@args@ doesn't match its definition.
162 % \ifnot@nil #1-> \def\reserved@a{#1}... の \reserved@a=\set@size@funct@args@
164 % ad hoc な対策として事前に必要な (s)sub は実行しておくことにする.
165 %\lst@AddToHook{Init}{\begingroup\itshape\bfseries\upshape\bfseries\mdseries\endgroup}