OSDN Git Service

bugfix
[luatex-ja/luatexja.git] / src / ltj-base.sty
index a69fcb6..717105e 100644 (file)
 
 \ifltj@in@latex                 %<*LaTeX>
   \NeedsTeXFormat{LaTeX2e}
-  \ProvidesPackage{ltj-base}[2012/04/21 v0.2]
+  \ProvidesPackage{ltj-base}[2017/05/05]
 \fi                             %</LaTeX>
 
 %%------------------ Tiny helpers
 
 %% Registers
-\newcount\ltj@tempcnta
+%\newcount\ltj@tempcnta % defined at luatexja-core.sty
 \newcount\ltj@tempcntb
 \newcount\ltj@tempcntc
 \newdimen\ltj@tempdima
-\newskip\ltj@tempskipa
-\newtoks\ltj@temptoks
+% \newskip\ltj@tempskipa unused
+% \newtoks\ltj@temptoks unused
 
 \countdef\ltj@@count@zero=0 %
 \luatexattributedef\ltj@@attr@zero=0 %
   #4
 }
 
-%% \ltj@burst-`>TEXT
-%! トリックに使う \romannumeral をエイリアスしておく.
-% Gets the head of TEXT expanded repeatedly until an unexpandable
-% token is seen, and if the token is a space then it is gobbled.
-\let\ltj@burst\romannumeral
-
 %%------------------ LaTeX vs plain
 \ifltj@in@latex            %<*LaTeX>
 
 %% \ltj@gobble@num <number>
 %! 次に続く整数を(2 回展開で)読み捨てる. 
 \def\ltj@gobble@num{
-  \ltj@burst-`>\ltj@@gobble@num
-}
-\def\ltj@@gobble@num{
-  \expandafter\ltj@@gobble@numA\the\parshapeindent
-}
-\begingroup
-  \lccode`8=`p\lccode`9=`t
-\lowercase{\endgroup
-  \def\ltj@@gobble@numA#189{ }
+  \directlua{token.scan_int()}
 }
 
 %% \ltj@gobble@glue <glue>
 %! 次に続くグルー値を(2 回展開で)読み捨てる. 
-\def\ltj@gobble@glue{%
-  \ltj@burst-`>\ltj@@gobble@glue
+\def\ltj@gobble@glue{
+  \directlua{token.scan_glue()}
 }
-\def\ltj@@gobble@glue{
-  \expandafter\ltj@@gobble@glueA\the\glueshrinkorder
-}
-\def\ltj@@gobble@glueA#1{ }
 
 %% \ltj@gobble@dimen <dimen>
 %! 次に続く寸法値を(2 回展開で)読み捨てる. 
-\def\ltj@gobble@dimen{%
-  \ltj@burst-`>\ltj@@gobble@dimen
-}
-\def\ltj@@gobble@dimen{
-  \expandafter\ltj@@gobble@dimenA\the\glueshrinkorder
-  0pt minus
-}
-\def\ltj@@gobble@dimenA#1{ }
-
-%% \ltj@@scan@brace
-% This is to be followed by a macro with one argument; if the macro is
-% followed by an open-group token (catcode 1), then it receives as the
-% argument a token \bxnt@escape instead of the group initiated by the
-% open-group, which is left untouched.
-\def\ltj@@scan@brace{
-  \directlua{luatexja.base.scan_brace()}
-}
-
-%% \ltj@@scan@number
-\def\ltj@@scan@number{
-  \directlua{luatexja.base.scan_number()}
+\def\ltj@gobble@dimen{
+  \directlua{token.scan_dimen()}
 }
 
 %% \ltj@grab@num <number>
 %!   (command_name が "assign_int" であるトークン).
 %! (注意: まだ文字表記(`A)に対応していません.)
 \def\ltj@grab@num{
-  \ltj@burst-`>\ltj@@grab@num
-}
-\def\ltj@@grab@num{
-  \ltj@@scan@brace\ltj@@grab@numA
-}
-\def\ltj@@grab@numA#1{
-  \ltj@ifx{#1\ltj@@q@escape}{}{%else
-    \ltj@@scan@number\ltj@@grab@numB#1
-  }
-}
-\def\ltj@@grab@numB#1{
-  \ltj@ifx{#1\ltj@@q@escape}{
-    {0}
-  }{
-    \ltj@@grab@numC
-  }
-}
-\def\ltj@@grab@numC#1\ltj@@q@escapenum{
-  {#1}
+  \directlua{tex.sprint('{' .. token.scan_int() .. '}')}
 }
 
 %%------------------ Safe passing
   }
 }
 
-%% \ltj@safe@glue{<glue>}
-%! グルー値.
-% For a glue. The result is a gluespec object.
-\def\ltj@safe@glue{
-  \ltj@safe@glue@or\ltj@safe@invalid
-}
-\def\ltj@safe@glue@or#1#2{
-  \expandafter\expandafter\expandafter\ltj@@safe@glueA
-   \ltj@gobble@glue#2\ltj@@safe@end{#2}{#1}
-}
-\def\ltj@@safe@glueA#1\ltj@@safe@end#2#3{
-  \ltj@if@blank{#1}{
-    (luatexja.base.to_skip("\the\glueexpr#2\relax"))
-  }{
-    #3
-  }
-}
-
 %% \ltj@safe@real{<real>}
 %! 実数. これは十進表記に限る.
 % For a real number given in decimal notation or a macro that
@@ -512,6 +439,33 @@ luatexja.base._error_show(true)% and many spaces trail!
   \def#1{\ltj@package@debug{#2}}
 }
 
+%% \ltj@afterbox <token><box>
+%% -> \setbox\ltj@afbox<box><token>
+%% from Sonja Maus, ``Looking Ahead for a <box>'',
+%%      TUGBoat, 11, No. 4, 1990.
+\newbox\ltj@afbox
+\protected\def\ltj@afterbox#1{%
+  \def\ltj@afb@xarg{#1}%
+  \afterassignment\ltj@afb@x
+  \chardef\ltj@@next`.}
+\def\ltj@afb@x{\futurelet\ltj@@next\ltj@afb@xtest}
+\def\ltj@afb@xtest{%
+  \ifcase\ifx\ltj@@next\hbox\tw@\fi
+         \ifx\ltj@@next\vbox\tw@\fi
+         \ifx\ltj@@next\vtop\tw@\fi
+         \ifx\ltj@@next\box\@ne\fi
+         \ifx\ltj@@next\copy\@ne\fi
+         \ifx\ltj@@next\vsplit\@ne\fi
+         \ifx\ltj@@next\lastbox\@ne\fi
+         0% ``A <box> was ...'' error will be causes by \setbox later anyway.
+  \or\afterassignment\ltj@afb@xarg
+  \or\afterassignment\ltj@afb@xagarg
+  \fi
+  \setbox\ltj@afbox
+}
+\def\ltj@afb@xagarg{\aftergroup\ltj@afb@xarg}
+
+
 %%------------------ all done
 \ltj@base@AtEnd
 \endinput