summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3int.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3int.dtx75
1 files changed, 56 insertions, 19 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
index 7f51f1d50f5..2d5be22ab66 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
@@ -35,7 +35,7 @@
%
%<*driver|package>
\RequirePackage{l3names}
-\GetIdInfo$Id: l3int.dtx 3029 2011-12-06 22:47:30Z joseph $
+\GetIdInfo$Id: l3int.dtx 3086 2011-12-22 17:55:46Z bruno $
{L3 Experimental integers}
%</driver|package>
%<*driver>
@@ -185,6 +185,16 @@
% Sets \meta{integer} to $0$.
% \end{function}
%
+% \begin{function}[added = 2011-12-13]
+% {\int_zero_new:N, \int_zero_new:c, \int_gzero_new:N, \int_gzero_new:c}
+% \begin{syntax}
+% \cs{int_zero_new:N} \meta{integer}
+% \end{syntax}
+% Ensures that the \meta{integer} exists globally by applying
+% \cs{int_new:N} if necessary, then applies \cs{int_(g)zero:N} to leave
+% the \meta{integer} is set to zero.
+% \end{function}
+%
% \begin{function}
% {
% \int_set_eq:NN, \int_set_eq:cN, \int_set_eq:Nc, \int_set_eq:cc,
@@ -966,7 +976,7 @@
% package.
% \begin{macrocode}
%<*package>
-\cs_new_protected_nopar:Npn \int_new:N #1
+\cs_new_protected:Npn \int_new:N #1
{
\chk_if_free_cs:N #1
\newcount #1
@@ -977,22 +987,25 @@
% \end{macro}
%
% \begin{macro}{\int_const:Nn, \int_const:cn}
+% \begin{macro}[aux]{\int_constdef:Nw}
+% \begin{variable}{\c_max_const_int}
% \UnitTested
% As stated, most constants can be defined as \tn{chardef} or
-% \tn{mathchardef} but that's engine dependent.
+% \tn{mathchardef} but that's engine dependent. As a result, there is some
+% set up code to determine what can be done.
% \begin{macrocode}
\cs_new_protected:Npn \int_const:Nn #1#2
{
\int_compare:nNnTF {#2} > \c_minus_one
{
- \int_compare:nNnTF {#2} > \c_max_register_int
+ \int_compare:nNnTF {#2} > \c_max_const_int
{
\int_new:N #1
\int_gset:Nn #1 {#2}
}
{
\chk_if_free_cs:N #1
- \tex_global:D \tex_mathchardef:D #1 =
+ \tex_global:D \int_constdef:Nw #1 =
\int_eval:w #2 \int_eval_end:
}
}
@@ -1002,8 +1015,19 @@
}
}
\cs_generate_variant:Nn \int_const:Nn { c }
+\pdftex_if_engine:TF
+ {
+ \cs_new_eq:NN \int_constdef:Nw \tex_mathchardef:D
+ \tex_mathchardef:D \c_max_const_int 32 767 ~
+ }
+ {
+ \cs_new_eq:NN \int_constdef:Nw \tex_chardef:D
+ \tex_chardef:D \c_max_const_int 1 114 111 ~
+ }
% \end{macrocode}
-% \end{macro}
+% \end{variable}
+% \end{macro}
+% \end{macro}
%
% \begin{macro}{\int_zero:N, \int_zero:c}
% \UnitTested
@@ -1011,14 +1035,27 @@
% \UnitTested
% Functions that reset an \meta{integer} register to zero.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \int_zero:N #1 { #1 = \c_zero }
-\cs_new_protected_nopar:Npn \int_gzero:N #1 { \tex_global:D #1 = \c_zero }
+\cs_new_protected:Npn \int_zero:N #1 { #1 = \c_zero }
+\cs_new_protected:Npn \int_gzero:N #1 { \tex_global:D #1 = \c_zero }
\cs_generate_variant:Nn \int_zero:N { c }
\cs_generate_variant:Nn \int_gzero:N { c }
% \end{macrocode}
% \end{macro}
% \end{macro}
%
+% \begin{macro}
+% {\int_zero_new:N, \int_zero_new:c, \int_gzero_new:N, \int_gzero_new:c}
+% Create a register if needed, otherwise clear it.
+% \begin{macrocode}
+\cs_new_protected:Npn \int_zero_new:N #1
+ { \cs_if_exist:NTF #1 { \int_zero:N #1 } { \int_new:N #1 } }
+\cs_new_protected:Npn \int_gzero_new:N #1
+ { \cs_if_exist:NTF #1 { \int_gzero:N #1 } { \int_new:N #1 } }
+\cs_generate_variant:Nn \int_zero_new:N { c }
+\cs_generate_variant:Nn \int_gzero_new:N { c }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\int_set_eq:NN,\int_set_eq:cN, \int_set_eq:Nc,\int_set_eq:cc}
% \UnitTested
% \begin{macro}
@@ -1027,10 +1064,10 @@
% Setting equal means using one integer inside the set function of
% another.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \int_set_eq:NN #1#2 { #1 = #2 }
+\cs_new_protected:Npn \int_set_eq:NN #1#2 { #1 = #2 }
\cs_generate_variant:Nn \int_set_eq:NN { c }
\cs_generate_variant:Nn \int_set_eq:NN { Nc , cc }
-\cs_new_protected_nopar:Npn \int_gset_eq:NN #1#2 { \tex_global:D #1 = #2 }
+\cs_new_protected:Npn \int_gset_eq:NN #1#2 { \tex_global:D #1 = #2 }
\cs_generate_variant:Nn \int_gset_eq:NN { c }
\cs_generate_variant:Nn \int_gset_eq:NN { Nc , cc }
% \end{macrocode}
@@ -1078,9 +1115,9 @@
% Incrementing and decrementing of integer registers is done with
% the following functions.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \int_incr:N #1
+\cs_new_protected:Npn \int_incr:N #1
{ \tex_advance:D #1 \c_one }
-\cs_new_protected_nopar:Npn \int_decr:N #1
+\cs_new_protected:Npn \int_decr:N #1
{ \tex_advance:D #1 \c_minus_one }
\cs_new_protected_nopar:Npn \int_gincr:N
{ \tex_global:D \int_incr:N }
@@ -1655,7 +1692,7 @@
\exp_after:wN \int_to_roman_aux:N
\int_to_roman:w \int_eval:n {#1} Q
}
-\cs_new_nopar:Npn \int_to_roman_aux:N #1
+\cs_new:Npn \int_to_roman_aux:N #1
{
\use:c { int_to_roman_ #1 :w }
\int_to_roman_aux:N
@@ -1665,7 +1702,7 @@
\exp_after:wN \int_to_Roman_aux:N
\int_to_roman:w \int_eval:n {#1} Q
}
-\cs_new_nopar:Npn \int_to_Roman_aux:N #1
+\cs_new:Npn \int_to_Roman_aux:N #1
{
\use:c { int_to_Roman_ #1 :w }
\int_to_Roman_aux:N
@@ -1685,7 +1722,7 @@
\cs_new_nopar:Npn \int_to_Roman_c:w { C }
\cs_new_nopar:Npn \int_to_Roman_d:w { D }
\cs_new_nopar:Npn \int_to_Roman_m:w { M }
-\cs_new_nopar:Npn \int_to_Roman_Q:w #1 { }
+\cs_new:Npn \int_to_Roman_Q:w #1 { }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1885,7 +1922,7 @@
% appropriate value for each letter and building up a sum. This is
% then evaluated by \TeX{}.
% \begin{macrocode}
-\cs_new_nopar:Npn \int_from_roman:n #1
+\cs_new:Npn \int_from_roman:n #1
{
\tl_if_blank:nF {#1}
{
@@ -1894,7 +1931,7 @@
\int_from_roman_aux:NN #1 Q \q_stop
}
}
-\cs_new_nopar:Npn \int_from_roman_aux:NN #1#2
+\cs_new:Npn \int_from_roman_aux:NN #1#2
{
\str_if_eq:nnTF {#1} { Q }
{#1#2}
@@ -1928,9 +1965,9 @@
}
}
}
-\cs_new_nopar:Npn \int_from_roman_end:w #1 Q #2 \q_stop
+\cs_new:Npn \int_from_roman_end:w #1 Q #2 \q_stop
{ \tl_if_empty:nTF {#2} {#1} {#2} }
-\cs_new_nopar:Npn \int_from_roman_clean_up:w #1 Q { + 0 Q -1 }
+\cs_new:Npn \int_from_roman_clean_up:w #1 Q { + 0 Q -1 }
% \end{macrocode}
% \end{macro}
% \end{macro}