summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/zhnumber
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/zhnumber')
-rw-r--r--Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx389
1 files changed, 187 insertions, 202 deletions
diff --git a/Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx b/Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx
index 59a56eb12e0..303221c5477 100644
--- a/Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx
+++ b/Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx
@@ -157,7 +157,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
%</!config>
-\GetIdInfo$Id: zhnumber.dtx 715 2014-09-09 14:11:20Z sobenlee $
+\GetIdInfo$Id: zhnumber.dtx 718 2014-09-13 09:13:29Z sobenlee $
%<*driver>
{zhnumber source file}
\ProvidesExplFile{\ExplFileName.\ExplFileExtension}
@@ -172,7 +172,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%<config&utf8> {\ExplFileName-utf8.cfg}
%<config&big5> {\ExplFileName-big5.cfg}
%<config&gbk> {\ExplFileName-gbk.cfg}
- {\ExplFileDate}{2.0}{\ExplFileDescription}
+ {\ExplFileDate}{2.1}{\ExplFileDescription}
%</driver|package|config>
%<*driver>
\ExplSyntaxOff
@@ -257,7 +257,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%</driver>
% \fi
%
-% \CheckSum{1071}
+% \CheckSum{1055}
% \GetFileInfo{\jobname.sty}
%
% \title{\bfseries\pkg{zhnumber} 宏包}
@@ -287,7 +287,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% 默认将使用 |GBK|。
% \end{function}
%
-% \begin{function}[updated=2014-09-09]{\zhnumber}
+% \begin{function}[rEXP, updated=2014-09-12]{\zhnumber}
% \begin{syntax}
% \tn{zhnumber} \Arg{number}
% \end{syntax}
@@ -306,7 +306,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \end{SideBySideExample}
% \end{function}
%
-% \begin{function}[updated=2014-09-09]{\zhdigits}
+% \begin{function}[rEXP, updated=2014-09-09]{\zhdigits}
% \begin{syntax}
% \tn{zhdigits} \Arg{number}
% \tn{zhdigits} * \Arg{number}
@@ -319,7 +319,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \end{SideBySideExample}
% \end{function}
%
-% \begin{function}[updated=2014-09-09]{\zhnum}
+% \begin{function}[rEXP, updated=2014-09-09]{\zhnum}
% \begin{syntax}
% \tn{zhnum} \Arg{counter}
% \end{syntax}
@@ -329,7 +329,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \end{SideBySideExample}
% \end{function}
%
-% \begin{function}[added=2012-5-25]{\zhweekday}
+% \begin{function}[rEXP, added=2012-05-25]{\zhweekday}
% \begin{syntax}
% \tn{zhweekday} \Arg{yyyy/mm/dd}
% \end{syntax}
@@ -339,7 +339,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \end{SideBySideExample}
% \end{function}
%
-% \begin{function}[added=2012-5-25]{\zhdate}
+% \begin{function}[rEXP, added=2012-05-25]{\zhdate}
% \begin{syntax}
% \tn{zhdate} \Arg{yyyy/mm/dd}
% \tn{zhdate} * \Arg{yyyy/mm/dd}
@@ -351,14 +351,14 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \end{SideBySideExample}
% \end{function}
%
-% \begin{function}[added=2012-5-25]{\zhtoday}
+% \begin{function}[rEXP, added=2012-05-25]{\zhtoday}
% 与 |\today| 类似,以中文输出当天的日期。例如
% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.6\linewidth,gobble=5]
% \zhtoday
% \end{SideBySideExample}
% \end{function}
%
-% \begin{function}[added=2012-5-25]{\zhtime}
+% \begin{function}[rEXP, added=2012-05-25]{\zhtime}
% \begin{syntax}
% \tn{zhtime} \Arg{hh:mm}
% \end{syntax}
@@ -368,14 +368,14 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \end{SideBySideExample}
% \end{function}
%
-% \begin{function}[added=2012-5-25]{\zhcurrtime}
+% \begin{function}[rEXP, added=2012-05-25]{\zhcurrtime}
% 输出当前的时间。例如
% \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.6\linewidth,gobble=5]
% \zhcurrtime
% \end{SideBySideExample}
% \end{function}
%
-% \begin{function}[added=2012-5-25]{\zhnumExtendScaleMap}
+% \begin{function}[added=2012-05-25]{\zhnumExtendScaleMap}
% \begin{syntax}
% \tn{zhnumExtendScaleMap} \oarg{character} \argbrace{\meta{character_1}, \meta{character_2}, ..., \meta{character_n}}
% \end{syntax}
@@ -392,7 +392,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% 用于在导言区或文档中,设置中文数字的输出格式。目前可以设置的 \meta{key} 如下介绍。
% \end{function}
%
-% \begin{function}[added=2012-5-25]{time}
+% \begin{function}[added=2012-05-25]{time}
% \begin{syntax}
% time = \argbrace{\meta{Arabic}\orvar\meta{Chinese}}
% \end{syntax}
@@ -404,7 +404,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \end{SideBySideExample}
% \end{function}
%
-% \begin{function}[updated=2012-5-25]{style}
+% \begin{function}[updated=2012-05-25]{style}
% \begin{syntax}
% style = \argbrace{\meta{Simplified}\orvar\meta{Traditional}\orvar\meta{Normal}\orvar\meta{Financial}\orvar\meta{Ancient}}
% \end{syntax}
@@ -452,7 +452,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% 可以将 2 映射成两。需要说明的是,\pkg{zhnumber} 将优先使用这里的设置,所以可能会影响
% 到 |style| 选项。如果要恢复 |style| 的功能,可以使用 |reset| 选项。
%
-% \begin{function}[updated=2014-09-09]{reset}
+% \begin{function}[updated=2014-09-12]{reset}
% \begin{syntax}
% reset
% \end{syntax}
@@ -520,8 +520,9 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\DeclareExpandableDocumentCommand \zhnumber { +o +m }
{
\IfNoValueTF {#1}
- { \zhnum_number:n {#2} }
- { \zhnumberwithoptions {#1} {#2} }
+ { \zhnum_number:f }
+ { \zhnumberwithoptions {#1} }
+ {#2}
}
% \end{macrocode}
% \end{macro}
@@ -533,7 +534,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{
\group_begin:
\keys_set:nn { zhnum / options } {#1}
- \zhnum_number:n {#2}
+ \zhnum_number:f {#2}
\group_end:
}
% \end{macrocode}
@@ -551,6 +552,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{ \@@_integer_or_fraction:www #1 / \q_nil / \q_stop }
{ \zhnum_decimal:nn {#1} {#2} }
}
+\cs_generate_variant:Nn \zhnum_number:n { f }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -574,22 +576,21 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{
\quark_if_nil:nTF {#3}
{
- \zhnum_blank_to_zero:f {#1}
+ \zhnum_blank_to_zero:n {#1}
\c_@@_parts_tl
- \zhnum_blank_to_zero:f {#2}
+ \zhnum_blank_to_zero:n {#2}
}
{
- \tl_if_blank:fF {#2}
+ \tl_if_blank:nF {#2}
{
\zhnum_number:n {#2}
\c_@@_and_tl
}
- \zhnum_blank_to_zero:f {#1}
+ \zhnum_blank_to_zero:n {#1}
\c_@@_parts_tl
- \zhnum_blank_to_zero:f {#3}
+ \zhnum_blank_to_zero:n {#3}
}
}
-\cs_generate_variant:Nn \tl_if_blank:nF { f }
% \end{macrocode}
% \end{macro}
%
@@ -598,12 +599,11 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{macrocode}
\cs_new:Npn \zhnum_decimal:nn #1#2
{
- \zhnum_blank_to_zero:f {#1} \c_@@_dot_tl
- \tl_if_blank:fTF {#2}
+ \zhnum_blank_to_zero:n {#1} \c_@@_dot_tl
+ \tl_if_blank:nTF {#2}
{ \c_@@_zero_tl }
{ \zhnum_digits_zero:n {#2} }
}
-\cs_generate_variant:Nn \tl_if_blank:nTF { f }
% \end{macrocode}
% \end{macro}
%
@@ -616,20 +616,20 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{ \c_@@_zero_tl }
{ \zhnum_number:n {#1} }
}
-\cs_generate_variant:Nn \zhnum_blank_to_zero:n { f }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhnum,\zhnumberwithoptions}
% 用于将 \LaTeX{} 计数器按中文格式输出。
% \begin{macrocode}
-\DeclareExpandableDocumentCommand \zhnum { o m }
+\DeclareExpandableDocumentCommand \zhnum { +o +m }
{
\IfNoValueTF {#1}
- { \zhnum_counter:n {#2} }
- { \zhnumwithoptions {#1} {#2} }
+ { \zhnum_counter:n }
+ { \zhnumwithoptions {#1} }
+ {#2}
}
-\NewDocumentCommand \zhnumwithoptions { m m }
+\NewDocumentCommand \zhnumwithoptions { +m +m }
{
\group_begin:
\keys_set:nn { zhnum / options } {#1}
@@ -639,17 +639,17 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[internal]{\zhnum_counter:n}
+% \begin{macro}[internal]{\zhnum_counter:n, \zhnum_int:n}
% 可以直接通过比较 \LaTeX{} 计数器的值来得到符号和绝对值。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_counter:n #1
- { \exp_args:Nc \zhnum_counter:Nn { c@#1 } {#1} }
-\cs_new:Npn \zhnum_counter:Nn #1#2
+\cs_new:Npn \zhnum_counter:n #1
{
- \token_if_int_register:NTF #1
- { \zhnum_int:n {#1} }
- { \__msg_expandable_error:n { `#2' is not a LaTeX counter. } }
+ \int_if_exist:cTF { c@#1 }
+ { \zhnum_int:c { c@#1 } }
+ { \@@_counter_error:n {#1} }
}
+\cs_new:Npn \@@_counter_error:n #1
+ { \__msg_expandable_error:n { `#1'~is~not~a~LaTeX~counter. } }
\cs_new:Npn \zhnum_int:n #1
{
\int_compare:nNnTF {#1} > \c_zero
@@ -663,6 +663,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{ \c_@@_zero_tl }
}
}
+\cs_generate_variant:Nn \zhnum_int:n { c }
% \end{macrocode}
% \end{macro}
%
@@ -763,106 +764,87 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \zhnum_parse_number:nn
% }
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_parse_number:n #1
+\cs_new:Npn \zhnum_parse_number:n #1
{ \exp_args:Nf \zhnum_parse_number:nn { \tl_count:n {#1} } {#1} }
-\cs_new_nopar:Npn \zhnum_parse_number:nn #1#2
- { \exp_args:Nf \@@_parse_number:nnn { \int_mod:nn {#1} \c_four } {#1} {#2} }
-\cs_new_nopar:Npn \@@_parse_number:nnn #1#2#3
+\cs_new:Npn \zhnum_parse_number:nn #1
+ { \exp_args:Nf \@@_parse_number:nnn { \int_mod:nn {#1} \c_four } {#1} }
+\cs_new:Npn \@@_parse_number:nnn #1#2
{
\int_compare:nNnTF {#2} < \c_two
- { \zhnum_digit_map:n {#3} }
+ { \zhnum_digit_map:n }
{
- \zhnum_split_number:fNNfn { \zhnum_insert_zeros:n {#1} #3 }
- \c_true_bool \c_true_bool
- {
- \int_compare:nNnTF {#1} = \c_zero
- { \int_eval:n { (#2) / \c_four - \c_one } }
- { \int_div_truncate:nn {#2} \c_four }
- }
- { \c_zero }
+ \int_compare:nNnTF {#1} = \c_zero
+ { \zhnum_split_number:fn { \int_eval:n { #2 / \c_four - \c_one } } }
+ { \@@_split_number_aux:nnn {#1} {#2} }
}
}
\cs_generate_variant:Nn \zhnum_parse_number:n { f }
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[internal]{\zhnum_insert_zeros:n}
+% \begin{macro}[aux]{\@@_split_number_aux:nnn}
% 为了处理的方便,在整数前面补上适当的 $0$,使其位数可以被 $4$ 整除。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_insert_zeros:n #1
- {
- \if_case:w \etex_numexpr:D #1 - \c_one \scan_stop:
- \or: \exp_after:wN \use_none:n
- \or: \exp_after:wN \use_none:nn
- \else: \exp_after:wN \use_none:nnn
- \fi:
- 0 0 0
+\cs_new:Npn \@@_split_number_aux:nnn #1#2
+ {
+ \exp_after:wN \@@_split_number_aux:wwn
+ \tex_number:D \int_div_truncate:nn {#2} \c_four
+ \if_case:w #1 \exp_stop_f:
+ \or: \exp_after:wN \use:n
+ \or: \exp_after:wN \use_i_ii:nnn
+ \or: \exp_after:wN \use_i:nnn
+ \fi:
+ { \exp_stop_f: ; 0 } 0 0 ;
}
+\cs_new:Npn \@@_split_number_aux:wwn #1 ; #2 ; #3
+ { \zhnum_split_number:nn {#1} { #2#3 } }
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[internal]{\zhnum_split_number:nNNnn}
-% 将输入的整数由高位到低位,以四位为一段进行处理。
+% \begin{macro}[internal]{\zhnum_split_number:nn}
+% 最后加入的 \cs{q_recursion_tail} 是停止递归的标志,而 \cs{q_nil} 用于占位。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_split_number:nNNnn #1#2#3#4#5
- {
- \@@_split_number:fnNNnn { \zhnum_number_item:nn {#1} {#5} }
- {#1} #2#3 {#4} {#5}
- }
-\cs_new_nopar:Npn \@@_split_number:nnNNnn #1#2#3#4#5#6
- {
- \int_compare:nNnTF {#1} = \c_zero
- { \@@_split_number_aux:NNfnnn \c_false_bool \c_true_bool }
- {
- \bool_if:NF #3 { \c_@@_zero_tl }
- \zhnum_process_number:NNn #3#4 {#1}
- \exp_args:Nf \zhnum_scale_map:n { \int_eval:n { #5 - #6 } }
- \int_compare:nNnTF { \int_mod:nn {#1} \c_ten } = \c_zero
- { \@@_split_number_aux:NNfnnn \c_false_bool \c_true_bool }
- { \@@_split_number_aux:NNfnnn \c_true_bool \c_false_bool }
- }
- { \int_eval:n { #6 + \c_one } } {#2} {#5} {#6}
- }
-\cs_new_nopar:Npn \@@_split_number_aux:NNnnnn #1#2#3#4#5#6
+\cs_new:Npn \zhnum_split_number:nn #1#2
{
- \int_compare:nNnF {#5} = {#6}
- { \zhnum_split_number:nNNnn {#4} #1#2 {#5} {#3} }
+ \zhnum_split_number:NNnNNNNw \c_true_bool \c_true_bool {#1}
+ #2 \q_recursion_tail \q_nil \q_nil \q_nil \q_recursion_stop
}
-\cs_generate_variant:Nn \zhnum_split_number:nNNnn { fNNf }
-\cs_generate_variant:Nn \@@_split_number:nnNNnn { f }
-\cs_generate_variant:Nn \@@_split_number_aux:NNnnnn { NNf }
+\cs_generate_variant:Nn \zhnum_split_number:nn { f }
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[internal]{\zhnum_number_item:nn}
-% 截取整数的其中四位数。
+% \begin{macro}[internal]{\zhnum_split_number:NNnNNNNw}
+% 将输入的整数由高位到低位,以四位为一段进行处理。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_number_item:nn #1#2
- { \@@_number_item:nNNNN {#2} #1 \q_recursion_stop }
-\cs_new_nopar:Npn \@@_number_item:nNNNN #1#2#3#4#5
+\cs_new:Npn \zhnum_split_number:NNnNNNNw #1#2#3#4#5#6#7#8 \q_recursion_stop
{
- \int_compare:nNnTF {#1} = \c_zero
- { \@@_recursion_stop:NNNNw #2#3#4#5 }
- { \@@_number_item:fNNNN { \int_eval:n { #1 - \c_one } } }
+ \quark_if_recursion_tail_stop:N #4
+ \int_compare:nNnTF { #4#5#6#7 } = \c_zero
+ { \use_i:nn }
+ {
+ \bool_if:NF #1 { \c_@@_zero_tl }
+ \zhnum_process_number:NNNNNN #4#5#6#7#1#2
+ \zhnum_scale_map:n {#3}
+ \int_compare:nNnTF {#7} = \c_zero
+ }
+ { \zhnum_split_number:NNfNNNNw \c_false_bool \c_true_bool }
+ { \zhnum_split_number:NNfNNNNw \c_true_bool \c_false_bool }
+ { \int_eval:n { #3 - \c_one } } #8 \q_recursion_stop
}
-\cs_generate_variant:Nn \@@_number_item:nNNNN { f }
-\cs_new_nopar:Npn \@@_recursion_stop:NNNNw #1#2#3#4#5 \q_recursion_stop
- { #1#2#3#4 }
+\cs_generate_variant:Nn \zhnum_split_number:NNnNNNNw { NNf }
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[internal]{\zhnum_process_number:NNn,\zhnum_process_number:NNNNNN}
+% \begin{macro}[internal]{\zhnum_process_number:NNNNNN}
% 对四位数字按情况进行处理。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_process_number:NNn #1#2#3
- { \zhnum_process_number:NNNNNN #3#1#2 }
-\cs_new_nopar:Npn \zhnum_process_number:NNNNNN #1#2#3#4#5#6
+\cs_new:Npn \zhnum_process_number:NNNNNN #1#2#3#4#5#6
{
\int_compare:nNnTF {#1} = \c_zero
{ \bool_if:NF #6 { \c_@@_zero_tl } }
{ \zhnum_digit_map:n {#1} \c_@@_thousand_tl }
\int_compare:nNnTF {#2} = \c_zero
- { \int_compare:nNnT { #1 * (#3#4) } > \c_zero { \c_@@_zero_tl } }
+ { \int_compare:nNnF { #1 * (#3#4) } = \c_zero { \c_@@_zero_tl } }
{
\bool_if:nTF
{ \l_@@_ancient_bool && \int_compare_p:nNn {#2} = \c_two }
@@ -870,7 +852,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{ \zhnum_digit_map:n {#2} \c_@@_hundred_tl }
}
\int_compare:nNnTF {#3} = \c_zero
- { \int_compare:nNnT { #2 * #4 } > \c_zero { \c_@@_zero_tl } }
+ { \int_compare:nNnF { #2 * #4 } = \c_zero { \c_@@_zero_tl } }
{
\bool_if:nF
{
@@ -898,18 +880,14 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{macro}{\zhdigits,\zhdigitswithoptions}
% 将输入的数字输出为中文数字串输出。
% \begin{macrocode}
-\DeclareExpandableDocumentCommand \zhdigits { s o m }
+\DeclareExpandableDocumentCommand \zhdigits { +s +o +m }
{
\IfNoValueTF {#2}
- { \zhnum_digits:Nn #1 {#3} }
- {
- \IfBooleanTF #1
- { \zhdigitswithoptions * }
- { \zhdigitswithoptions }
- {#2} {#3}
- }
+ { \zhnum_digits:Nn #1 }
+ { \zhdigitswithoptions {#1} {#2} }
+ {#3}
}
-\NewDocumentCommand \zhdigitswithoptions { s m m }
+\NewDocumentCommand \zhdigitswithoptions { +m +m +m }
{
\group_begin:
\keys_set:nn { zhnum / options } {#2}
@@ -987,17 +965,17 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{macro}{\zhdate}
% 输出中文日期。
% \begin{macrocode}
-\DeclareExpandableDocumentCommand \zhdate { s m }
+\DeclareExpandableDocumentCommand \zhdate { +s +m }
{
\@@_date:www #2 \q_stop
- \IfBooleanT {#1}
- { \@@_week_day:www #2 \q_stop }
+ \IfBooleanT #1
+ { \@@_week_day:www #2 \q_stop }
}
-\cs_new_nopar:Npn \@@_date:www #1/#2/#3 \q_stop
+\cs_new:Npn \@@_date:www #1/#2/#3 \q_stop
{
\zhnum_check_time:Nn \zhnum_digits_null:n {#1} \c_@@_year_tl
- \zhnum_check_time:Nn \zhnum_integer:n {#2} \c_@@_month_tl
- \zhnum_check_time:Nn \zhnum_integer:n {#3} \c_@@_day_tl
+ \zhnum_check_time:Nn \zhnum_int:n {#2} \c_@@_month_tl
+ \zhnum_check_time:Nn \zhnum_int:n {#3} \c_@@_day_tl
}
% \end{macrocode}
% \end{macro}
@@ -1017,15 +995,15 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{macro}[internal]{\zhnum_check_time:Nn}
% 判断是用中文数字还是用阿拉伯数组。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_check_time:Nn #1
- { \bool_if:NTF \l_@@_time_bool {#1} { \int_eval:n } }
+\cs_new:Npn \zhnum_check_time:Nn #1
+ { \bool_if:NTF \l_@@_time_bool {#1} { \int_to_arabic:n } }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhweekday}
% 输出星期
% \begin{macrocode}
-\cs_new_nopar:Npn \zhweekday #1
+\cs_new:Npn \zhweekday #1
{ \@@_week_day:www #1 \q_stop }
% \end{macrocode}
% \end{macro}
@@ -1033,9 +1011,9 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{macro}[internal]{\@@_week_day:www}
% 用 Zeller 公式计算的结果 $h$ 与实际星期的关系是 $d=h+5\pmod7+1$。
% \begin{macrocode}
-\cs_new_nopar:Npn \@@_week_day:www #1/#2/#3 \q_stop
+\cs_new:Npn \@@_week_day:www #1/#2/#3 \q_stop
{
- \if_case:w \etex_numexpr:D \zhnum_Zeller:nnn {#1} {#2} {#3} \scan_stop:
+ \if_case:w \zhnum_Zeller:nnn {#1} {#2} {#3} \exp_stop_f:
\c_@@_sat_tl
\or: \c_@@_sun_tl
\or: \c_@@_mon_tl
@@ -1052,7 +1030,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% 用 Zeller 公式\footnote{\url{http://en.wikipedia.org/wiki/Zeller's_congruence}}
% 计算星期几。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_Zeller:nnn #1#2#3
+\cs_new:Npn \zhnum_Zeller:nnn #1#2#3
{
\int_compare:nNnTF
{ #1 \zhnum_two_digits:n {#2} \zhnum_two_digits:n {#3} } > { 1582 10 04 }
@@ -1060,13 +1038,13 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{ \@@_Zeller_aux:Nnnn \zhnum_Zeller_Julian:nnn }
{#1} {#2} {#3}
}
-\cs_new_nopar:Npn \@@_Zeller_aux:Nnnn #1#2#3#4
+\cs_new:Npn \@@_Zeller_aux:Nnnn #1#2#3#4
{
\int_compare:nNnTF {#3} < \c_three
{ #1 { #2 - \c_one } { #3 + \c_twelve } {#4} }
{ #1 {#2} {#3} {#4} }
}
-\cs_new_nopar:Npn \zhnum_two_digits:n #1
+\cs_new:Npn \zhnum_two_digits:n #1
{
\int_compare:nNnT {#1} < \c_ten { 0 }
\int_eval:n {#1}
@@ -1083,7 +1061,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \]
% 其中 $Y$ 为年,$m$ 为月,$q$ 为日;若 $m=1,2$,则令 $m\mathbin{{+}{=}}12$,同时 $Y\mathop{--}{}$。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_Zeller_Gregorian:nnn #1#2#3
+\cs_new:Npn \zhnum_Zeller_Gregorian:nnn #1#2#3
{
\int_mod:nn
{
@@ -1106,7 +1084,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \biggl\lfloor\frac Y4\biggr\rfloor + 5\biggr) \pmod 7
% \]
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_Zeller_Julian:nnn #1#2#3
+\cs_new:Npn \zhnum_Zeller_Julian:nnn #1#2#3
{
\int_mod:nn
{
@@ -1124,17 +1102,17 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{macro}{\zhtime}
% 输出时间。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhtime #1
+\cs_new:Npn \zhtime #1
{ \@@_time:ww #1 \q_stop }
\group_begin:
\char_set_lccode:nn { `\; } { `\: }
\tl_to_lowercase:n
{
\group_end:
- \cs_new_nopar:Npn \@@_time:ww #1 ; #2 \q_stop
+ \cs_new:Npn \@@_time:ww #1 ; #2 \q_stop
{
- \zhnum_check_time:Nn \zhnum_integer:n {#1} \c_@@_hour_tl
- \zhnum_check_time:Nn \zhnum_integer:n {#2} \c_@@_minute_tl
+ \zhnum_check_time:Nn \zhnum_int:n {#1} \c_@@_hour_tl
+ \zhnum_check_time:Nn \zhnum_int:n {#2} \c_@@_minute_tl
}
}
% \end{macrocode}
@@ -1156,7 +1134,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{macro}[internal]{\zhnum_digit_map:n}
% 阿拉伯数字与中文数字的映射。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_digit_map:n #1
+\cs_new:Npn \zhnum_digit_map:n #1
{ \use:c { c_@@_ #1 _tl } }
% \end{macrocode}
% \end{macro}
@@ -1164,38 +1142,47 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{macro}[internal]{\zhnum_scale_map:n,\zhnum_scale_map_loop:n}
% 大数系统的映射。
% \begin{macrocode}
-\cs_new_nopar:Npn \zhnum_scale_map:n #1
+\cs_new:Npn \zhnum_scale_map:n #1
{
\cs_if_exist_use:cF { c_@@_s #1 _tl }
{ \zhnum_scale_map_hook:n {#1} }
}
-\cs_new_nopar:Npn \zhnum_scale_map_loop:n #1
- { \zhnum_scale_map:n { \int_mod:nn {#1} \g_@@_scale_int } }
-\int_new:N \g_@@_scale_int
-\int_set_eq:NN \g_@@_scale_int \c_eleven
+\cs_new:Npn \zhnum_scale_map_loop:n #1
+ { \zhnum_scale_map:n { \int_mod:nn {#1} \l_@@_scale_int } }
+\cs_generate_variant:Nn \zhnum_scale_map:n { f }
+\int_new:N \l_@@_scale_int
+\int_set_eq:NN \l_@@_scale_int \c_eleven
\cs_new_eq:NN \zhnum_scale_map_hook:n \zhnum_scale_map_loop:n
+\tl_const:cn { c_@@_s0_tl } { }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhnumExtendScaleMap}
+% 扩展进位系统。
% \begin{macrocode}
-\NewDocumentCommand \zhnumExtendScaleMap { > { \TrimSpaces } o m }
+\NewDocumentCommand \zhnumExtendScaleMap { > { \TrimSpaces } +o +m }
{
\int_zero:N \l_tmpa_int
- \clist_map_inline:nn {#2}
- {
- \int_incr:N \l_tmpa_int
- \tl_set:Nx \l_tmpa_tl
- { c_@@_s \int_eval:n { \l_tmpa_int + \c_eleven } _tl }
- \tl_if_exist:cF { \l_tmpa_tl }
- { \int_incr:N \g_@@_scale_int }
- \tl_set:cn { \l_tmpa_tl } {##1}
- }
+ \clist_map_function:nN {#2} \zhnum_set_scale:n
\IfNoValueF {#1}
{ \cs_set:Npn \zhnum_scale_map_hook:n ##1 {#1} }
}
% \end{macrocode}
% \end{macro}
+%
+% \begin{macro}[internal]{\zhnum_set_scale:n}
+% \begin{macrocode}
+\cs_new_protected:Npn \zhnum_set_scale:n #1
+ {
+ \int_incr:N \l_tmpa_int
+ \tl_set:Nx \l_tmpa_tl
+ { c_@@_s \int_eval:n { \l_tmpa_int + \c_eleven } _tl }
+ \tl_if_exist:cF { \l_tmpa_tl }
+ { \int_incr:N \l_@@_scale_int }
+ \tl_set:cn { \l_tmpa_tl } {#1}
+ }
+% \end{macrocode}
+% \end{macro}
% 根据需要设置中文阿拉伯数字。
% \begin{macrocode}
@@ -1261,16 +1248,16 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% }
% 将配置文件中的中文数字保存到 \texttt{prop} 变量中。
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \zhnum_set_digits_map:nn #1#2
+\cs_new_protected:Npn \zhnum_set_digits_map:nn #1#2
{ \prop_put:Nnn \l_@@_cfg_map_prop {#1} {#2} }
-\cs_new_protected_nopar:Npn \zhnum_set_digits_map:nnn #1#2#3
+\cs_new_protected:Npn \zhnum_set_digits_map:nnn #1#2#3
{
\prop_put_if_new:Nnn \l_@@_cfg_map_prop {#1} {#3}
\prop_put:Nnn \l_@@_cfg_map_var_prop {#1_#2} {#3}
}
-\cs_new_protected_nopar:Npn \zhnum_set_financial_map:nn #1#2
+\cs_new_protected:Npn \zhnum_set_financial_map:nn #1#2
{ \prop_put:Nnn \l_@@_cfg_map_finan_prop {#1} {#2} }
-\cs_new_protected_nopar:Npn \zhnum_set_financial_map:nnn #1#2#3
+\cs_new_protected:Npn \zhnum_set_financial_map:nnn #1#2#3
{
\prop_put_if_new:Nnn \l_@@_cfg_map_finan_prop {#1} {#3}
\prop_put:Nnn \l_@@_cfg_map_var_prop { financial_#1_#2 } {#3}
@@ -1294,40 +1281,40 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\cs_new_protected_nopar:Npn \zhnum_parse_config:
{
\prop_map_function:NN \l_@@_cfg_map_prop \zhnum_check_simp:nn
- \bool_if:NF \l_@@_reset_bool
- { \prop_map_function:NN \l_@@_cfg_map_prop \zhnum_check_financial:nn }
\zhnum_set_zero:
\zhnum_set_week_day:
+ \bool_if:NF \l_@@_reset_bool
+ {
+ \zhnum_assgin_const:
+ \bool_set_true:N \l_@@_reset_bool
+ }
}
-\cs_new_protected_nopar:Npn \zhnum_check_simp:nn #1#2
+\cs_new_protected:Npn \zhnum_check_simp:nn #1#2
{
- \@@_check_simp_aux:nn {#1} {#2}
+ \@@_check_simp_aux:nn {#2} {#1}
\prop_get:NnNT \l_@@_cfg_map_finan_prop {#1} \l_tmpa_tl
- { \exp_args:Nno \@@_check_simp_aux:nn { financial_ #1 } \l_tmpa_tl }
+ { \exp_args:No \@@_check_simp_aux:nn { \l_tmpa_tl } { financial_ #1 } }
}
-\cs_new_protected_nopar:Npn \@@_check_simp_aux:nn #1#2
+\cs_new_protected:Npn \@@_check_simp_aux:nn #1#2
{
- \prop_get:NnNTF \l_@@_cfg_map_var_prop { #1 _trad } \l_tmpa_tl
+ \prop_get:NnNTF \l_@@_cfg_map_var_prop { #2 _trad } \l_tmpa_tl
{
- \prop_get:NnNTF \l_@@_cfg_map_var_prop { #1 _simp } \l_tmpb_tl
- {
- \tl_set:cx { l_@@_ #1 _tl }
- {
- \exp_not:n { \bool_if:NTF \l_@@_simp_bool }
- { \exp_not:o \l_tmpb_tl } { \exp_not:o \l_tmpa_tl }
- }
- }
+ \prop_get:NnNF \l_@@_cfg_map_var_prop { #2 _simp } \l_tmpb_tl
+ { \tl_set:Nn \l_tmpb_tl {#1} }
+ \tl_set:cx { l_@@_ #2 _tl }
{
- \tl_set:cx { l_@@_ #1 _tl }
- {
- \exp_not:n { \bool_if:NTF \l_@@_simp_bool }
- { \exp_not:n {#2} } { \exp_not:o \l_tmpa_tl }
- }
+ \exp_not:n { \bool_if:NTF \l_@@_simp_bool }
+ { \exp_not:o \l_tmpb_tl } { \exp_not:o \l_tmpa_tl }
}
}
- { \tl_set:cn { l_@@_ #1 _tl } {#2} }
+ { \tl_set:cn { l_@@_ #2 _tl } {#1} }
+ }
+\cs_new_protected_nopar:Npn \zhnum_assgin_const:
+ {
+ \prop_map_function:NN \l_@@_cfg_map_prop \zhnum_check_financial:nn
+ \zhnum_set_alias:
}
-\cs_new_protected_nopar:Npn \zhnum_check_financial:nn #1#2
+\cs_new_protected:Npn \zhnum_check_financial:nn #1#2
{
\prop_get:NnNTF \l_@@_cfg_map_finan_prop {#1} \l_tmpa_tl
{
@@ -1347,7 +1334,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{
\tl_set:cx { l_@@_0_tl }
{
- \exp_not:n { \bool_if:nTF \l_@@_null_bool }
+ \exp_not:n { \bool_if:NTF \l_@@_null_bool }
{ \exp_not:o \l_@@_null_tl } { \exp_not:v { l_@@_0_tl } }
}
}
@@ -1367,16 +1354,9 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
{ \exp_not:N \c_@@_weekday_tl \exp_not:v { l_@@_6_tl } }
\tl_set:Nx \l_@@_sun_tl
{ \exp_not:N \c_@@_weekday_tl \exp_not:o \l_@@_day_tl }
- \bool_if:NF \l_@@_reset_bool
- {
- \clist_map_inline:nn { mon , tue , wed , thu , fri , sat , sun }
- {
- \zhnum_assgin_const_tl:cx
- { c_@@_ ##1 _tl } { \exp_not:c { l_@@_ ##1 _tl } }
- }
- \bool_set_true:N \l_@@_reset_bool
- }
}
+\clist_map_inline:nn { mon , tue , wed , thu , fri , sat , sun }
+ { \tl_const:cx { c_@@_ #1 _tl } { \exp_not:c { l_@@_ #1 _tl } } }
\cs_new_eq:NN \zhnum_assgin_const_tl:cx \tl_const:cx
\AtEndOfPackage
{ \cs_set_eq:NN \zhnum_assgin_const_tl:cx \tl_set:cx }
@@ -1386,21 +1366,27 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{macro}[internal]{\zhnum_set_alias:}
% 一些易于使用的别名。
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \zhnum_set_alias:
- {
- \tl_const:Nx \c_@@_zero_tl { \exp_not:c { c_@@_ 0 _tl } }
- \tl_const:Nx \c_@@_ten_tl { \exp_not:c { c_@@_ 10 _tl } }
- \tl_const:Nx \c_@@_hundred_tl { \exp_not:c { c_@@_ 100 _tl } }
- \tl_const:Nx \c_@@_thousand_tl { \exp_not:c { c_@@_ 1000 _tl } }
+\cs_new_eq:NN \zhnum_set_alias:NN \cs_new_eq:NN
+\cs_new_protected_nopar:Npx \zhnum_set_alias:
+ {
+ \zhnum_set_alias:NN \exp_not:N \c_@@_zero_tl
+ \exp_not:c { c_@@_ 0 _tl }
+ \zhnum_set_alias:NN \exp_not:N \c_@@_ten_tl
+ \exp_not:c { c_@@_ 10 _tl }
+ \zhnum_set_alias:NN \exp_not:N \c_@@_hundred_tl
+ \exp_not:c { c_@@_ 100 _tl }
+ \zhnum_set_alias:NN \exp_not:N \c_@@_thousand_tl
+ \exp_not:c { c_@@_ 1000 _tl }
}
-\AtEndOfPackage { \zhnum_set_alias: }
+\AtEndOfPackage
+ { \cs_set_eq:NN \zhnum_set_alias:NN \tl_set_eq:NN }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}[internal]{\zhnum_load_cfg:n}
% 根据选定编码载入配置文件。
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \zhnum_load_cfg:n #1
+\cs_new_protected:Npn \zhnum_load_cfg:n #1
{
\zhnum_set_cfg_name:Nn \l_@@_cfg_tl {#1}
\tl_if_eq:NNF \l_@@_cfg_tl \l_@@_last_cfg_tl
@@ -1408,14 +1394,14 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\zhnum_parse_config:
}
\cs_generate_variant:Nn \zhnum_load_cfg:n { o }
-\cs_new_protected_nopar:Npn \zhnum_update_cfg:n #1
+\cs_new_protected:Npn \zhnum_update_cfg:n #1
{
\prop_if_exist:cTF { g_@@_cfg_ \l_@@_cfg_tl _prop }
{ \tl_set_eq:NN \l_@@_last_cfg_tl \l_@@_cfg_tl }
{ \zhnum_input_cfg:n {#1} }
\@@_update_cfg_prop:N \prop_set_eq:Nc
}
-\cs_new_protected_nopar:Npn \zhnum_input_cfg:n #1
+\cs_new_protected:Npn \zhnum_input_cfg:n #1
{
\file_if_exist_input:nTF { zhnumber - #1 .cfg }
{
@@ -1431,7 +1417,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\@@_update_cfg_prop:N \@@_prop_gset_eq:Nn
\group_end:
}
-\cs_new_protected_nopar:Npn \@@_update_cfg_prop:N #1
+\cs_new_protected:Npn \@@_update_cfg_prop:N #1
{
#1 \l_@@_cfg_map_prop { g_@@_cfg_ \l_@@_cfg_tl _prop }
#1 \l_@@_cfg_map_var_prop { g_@@_cfg_var_ \l_@@_cfg_tl _prop }
@@ -1489,7 +1475,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
% \begin{macrocode}
\if_predicate:w \zhnum_if_unicode_engine_p:
\cs_new_eq:NN \zhnum_set_catcode: \prg_do_nothing:
- \cs_new_protected_nopar:Npn \zhnum_set_cfg_name:Nn #1#2
+ \cs_new_protected:Npn \zhnum_set_cfg_name:Nn #1#2
{
\tl_set:Nx \l_@@_encoding_tl {#2}
\tl_set:Nx #1 { \tl_to_str:N \l_@@_encoding_tl }
@@ -1516,7 +1502,7 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
}
\int_new:N \l_@@_byte_min_int
\int_new:N \l_@@_byte_max_int
- \cs_new_protected_nopar:Npn \zhnum_set_cfg_name:Nn #1#2
+ \cs_new_protected:Npn \zhnum_set_cfg_name:Nn #1#2
{
\tl_set:Nx \l_@@_encoding_tl {#2}
\tl_set:Nx #1
@@ -1580,14 +1566,14 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
\tl_new:N \l_@@_encoding_tl
\msg_new:nnnn { zhnumber } { encoding-invalid }
{ The~encoding~`#1'~is~invalid. }
- { Available~encoding~are~`UTF8',~`GBK'~and~`Big5'. }
+ { Available~encodings~are~`UTF8',~`GBK'~and~`Big5'. }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhnumsetup}
% 在文档中设置 \pkg{zhnumber} 的接口。
% \begin{macrocode}
-\NewDocumentCommand \zhnumsetup { m }
+\NewDocumentCommand \zhnumsetup { +m }
{
\keys_set:nn { zhnum / options } {#1}
\tex_ignorespaces:D
@@ -1662,7 +1648,6 @@ and some specific Chinese Simplified fonts (TrueType or OpenType).
%</big5>
\zhnum_set_digits_map:nn { and } { 又 }
\zhnum_set_digits_map:nn { parts } { 分之 }
-\zhnum_set_digits_map:nn { s0 } { }
%<*!big5>
\zhnum_set_digits_map:nnn { s1 } { simp } { 万 }
\zhnum_set_digits_map:nnn { s1 } { trad } { 萬 }