diff options
author | Karl Berry <karl@freefriends.org> | 2014-09-14 21:59:53 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-09-14 21:59:53 +0000 |
commit | 316a4982056f3d1332057d8b337e470357d69755 (patch) | |
tree | a0485a741ad02a6815d44e022fd875c201cd9a8d | |
parent | cb121761c0eab3885766e8a10e3f6068d746d4a3 (diff) |
zhnumber (14sep14)
git-svn-id: svn://tug.org/texlive/trunk@35169 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/zhnumber/zhnumber.pdf | bin | 294833 -> 296763 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/zhnumber/zhnumber.dtx | 389 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-big5.cfg | 5 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-gbk.cfg | 5 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-utf8.cfg | 5 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty | 338 |
6 files changed, 352 insertions, 390 deletions
diff --git a/Master/texmf-dist/doc/latex/zhnumber/zhnumber.pdf b/Master/texmf-dist/doc/latex/zhnumber/zhnumber.pdf Binary files differindex d404a36568e..c1e66f41434 100644 --- a/Master/texmf-dist/doc/latex/zhnumber/zhnumber.pdf +++ b/Master/texmf-dist/doc/latex/zhnumber/zhnumber.pdf 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 } { 萬 } diff --git a/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-big5.cfg b/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-big5.cfg index 623f99116fc..bd32e30c2af 100644 --- a/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-big5.cfg +++ b/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-big5.cfg @@ -19,11 +19,11 @@ %% This work has the LPPL maintenance status "maintained". %% The Current Maintainer of this work is Qing Lee. %% -\GetIdInfo$Id: zhnumber.dtx 715 2014-09-09 14:11:20Z sobenlee $ +\GetIdInfo$Id: zhnumber.dtx 718 2014-09-13 09:13:29Z sobenlee $ {Chinese numerals with Big5 encoding} \ProvidesExplFile {\ExplFileName-big5.cfg} - {\ExplFileDate}{2.0}{\ExplFileDescription} + {\ExplFileDate}{2.1}{\ExplFileDescription} \zhnum_set_digits_map:nn { minus } { t } \zhnum_set_digits_map:nn { 0 } { s } \zhnum_set_digits_map:nn { null } { } @@ -46,7 +46,6 @@ \zhnum_set_digits_map:nn { dot } { I } \zhnum_set_digits_map:nn { and } { S } \zhnum_set_digits_map:nn { parts } { } -\zhnum_set_digits_map:nn { s0 } { } \zhnum_set_digits_map:nn { s1 } { U } \zhnum_set_digits_map:nn { s2 } { } \zhnum_set_digits_map:nn { s3 } { } diff --git a/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-gbk.cfg b/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-gbk.cfg index ba98cc67668..ccba9ed19c0 100644 --- a/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-gbk.cfg +++ b/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-gbk.cfg @@ -19,11 +19,11 @@ %% This work has the LPPL maintenance status "maintained". %% The Current Maintainer of this work is Qing Lee. %% -\GetIdInfo$Id: zhnumber.dtx 715 2014-09-09 14:11:20Z sobenlee $ +\GetIdInfo$Id: zhnumber.dtx 718 2014-09-13 09:13:29Z sobenlee $ {Chinese numerals with GBK encoding} \ProvidesExplFile {\ExplFileName-gbk.cfg} - {\ExplFileDate}{2.0}{\ExplFileDescription} + {\ExplFileDate}{2.1}{\ExplFileDescription} \zhnum_set_digits_map:nnn { minus } { simp } { } \zhnum_set_digits_map:nnn { minus } { trad } { ؓ } \zhnum_set_digits_map:nn { 0 } { } @@ -48,7 +48,6 @@ \zhnum_set_digits_map:nnn { dot } { trad } { c } \zhnum_set_digits_map:nn { and } { } \zhnum_set_digits_map:nn { parts } { ֮ } -\zhnum_set_digits_map:nn { s0 } { } \zhnum_set_digits_map:nnn { s1 } { simp } { } \zhnum_set_digits_map:nnn { s1 } { trad } { f } \zhnum_set_digits_map:nnn { s2 } { simp } { } diff --git a/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-utf8.cfg b/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-utf8.cfg index 99291d70e57..9bdbebb6a2c 100644 --- a/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-utf8.cfg +++ b/Master/texmf-dist/tex/latex/zhnumber/config/zhnumber-utf8.cfg @@ -19,11 +19,11 @@ %% This work has the LPPL maintenance status "maintained". %% The Current Maintainer of this work is Qing Lee. %% -\GetIdInfo$Id: zhnumber.dtx 715 2014-09-09 14:11:20Z sobenlee $ +\GetIdInfo$Id: zhnumber.dtx 718 2014-09-13 09:13:29Z sobenlee $ {Chinese numerals with UTF8 encoding} \ProvidesExplFile {\ExplFileName-utf8.cfg} - {\ExplFileDate}{2.0}{\ExplFileDescription} + {\ExplFileDate}{2.1}{\ExplFileDescription} \zhnum_set_digits_map:nnn { minus } { simp } { 负 } \zhnum_set_digits_map:nnn { minus } { trad } { 負 } \zhnum_set_digits_map:nn { 0 } { 零 } @@ -48,7 +48,6 @@ \zhnum_set_digits_map:nnn { dot } { trad } { 點 } \zhnum_set_digits_map:nn { and } { 又 } \zhnum_set_digits_map:nn { parts } { 分之 } -\zhnum_set_digits_map:nn { s0 } { } \zhnum_set_digits_map:nnn { s1 } { simp } { 万 } \zhnum_set_digits_map:nnn { s1 } { trad } { 萬 } \zhnum_set_digits_map:nnn { s2 } { simp } { 亿 } diff --git a/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty b/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty index 3ff77026369..6d81896fdb3 100644 --- a/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty +++ b/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty @@ -21,11 +21,11 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: zhnumber.dtx 715 2014-09-09 14:11:20Z sobenlee $ +\GetIdInfo$Id: zhnumber.dtx 718 2014-09-13 09:13:29Z sobenlee $ {Typesetting numbers with Chinese glyphs} \ProvidesExplPackage {\ExplFileName} - {\ExplFileDate}{2.0}{\ExplFileDescription} + {\ExplFileDate}{2.1}{\ExplFileDescription} \msg_new:nnn { zhnumber } { l3-too-old } { Support~package~'expl3'~too~old. \\\\ @@ -39,14 +39,15 @@ \DeclareExpandableDocumentCommand \zhnumber { +o +m } { \IfNoValueTF {#1} - { \zhnum_number:n {#2} } - { \zhnumberwithoptions {#1} {#2} } + { \zhnum_number:f } + { \zhnumberwithoptions {#1} } + {#2} } \NewDocumentCommand \zhnumberwithoptions { +m +m } { \group_begin: \keys_set:nn { zhnum / options } {#1} - \zhnum_number:n {#2} + \zhnum_number:f {#2} \group_end: } \cs_new:Npn \zhnum_number:n #1 @@ -57,6 +58,7 @@ { \__zhnum_integer_or_fraction:www #1 / \q_nil / \q_stop } { \zhnum_decimal:nn {#1} {#2} } } +\cs_generate_variant:Nn \zhnum_number:n { f } \cs_new:Npn \__zhnum_integer_or_fraction:www #1 / #2 / #3 \q_stop { \quark_if_nil:nTF {#2} @@ -67,58 +69,56 @@ { \quark_if_nil:nTF {#3} { - \zhnum_blank_to_zero:f {#1} + \zhnum_blank_to_zero:n {#1} \c__zhnum_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__zhnum_and_tl } - \zhnum_blank_to_zero:f {#1} + \zhnum_blank_to_zero:n {#1} \c__zhnum_parts_tl - \zhnum_blank_to_zero:f {#3} + \zhnum_blank_to_zero:n {#3} } } -\cs_generate_variant:Nn \tl_if_blank:nF { f } \cs_new:Npn \zhnum_decimal:nn #1#2 { - \zhnum_blank_to_zero:f {#1} \c__zhnum_dot_tl - \tl_if_blank:fTF {#2} + \zhnum_blank_to_zero:n {#1} \c__zhnum_dot_tl + \tl_if_blank:nTF {#2} { \c__zhnum_zero_tl } { \zhnum_digits_zero:n {#2} } } -\cs_generate_variant:Nn \tl_if_blank:nTF { f } \cs_new:Npn \zhnum_blank_to_zero:n #1 { \tl_if_blank:nTF {#1} { \c__zhnum_zero_tl } { \zhnum_number:n {#1} } } -\cs_generate_variant:Nn \zhnum_blank_to_zero:n { f } -\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} \zhnum_counter:n {#2} \group_end: } -\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 } } + { \__zhnum_counter_error:n {#1} } } +\cs_new:Npn \__zhnum_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 @@ -132,6 +132,7 @@ { \c__zhnum_zero_tl } } } +\cs_generate_variant:Nn \zhnum_int:n { c } \cs_new:Npn \zhnum_integer:n #1 { \exp_after:wN \__zhnum_read_integer:www @@ -193,82 +194,63 @@ \exp_after:wN \use_ii:nn \fi: } -\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 \__zhnum_parse_number:nnn { \int_mod:nn {#1} \c_four } {#1} {#2} } -\cs_new_nopar:Npn \__zhnum_parse_number:nnn #1#2#3 +\cs_new:Npn \zhnum_parse_number:nn #1 + { \exp_args:Nf \__zhnum_parse_number:nnn { \int_mod:nn {#1} \c_four } {#1} } +\cs_new:Npn \__zhnum_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 } } } + { \__zhnum_split_number_aux:nnn {#1} {#2} } } } \cs_generate_variant:Nn \zhnum_parse_number:n { f } -\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 \__zhnum_split_number_aux:nnn #1#2 + { + \exp_after:wN \__zhnum_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_nopar:Npn \zhnum_split_number:nNNnn #1#2#3#4#5 +\cs_new:Npn \__zhnum_split_number_aux:wwn #1 ; #2 ; #3 + { \zhnum_split_number:nn {#1} { #2#3 } } +\cs_new:Npn \zhnum_split_number:nn #1#2 { - \__zhnum_split_number:fnNNnn { \zhnum_number_item:nn {#1} {#5} } - {#1} #2#3 {#4} {#5} + \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_new_nopar:Npn \__zhnum_split_number:nnNNnn #1#2#3#4#5#6 +\cs_generate_variant:Nn \zhnum_split_number:nn { f } +\cs_new:Npn \zhnum_split_number:NNnNNNNw #1#2#3#4#5#6#7#8 \q_recursion_stop { - \int_compare:nNnTF {#1} = \c_zero - { \__zhnum_split_number_aux:NNfnnn \c_false_bool \c_true_bool } + \quark_if_recursion_tail_stop:N #4 + \int_compare:nNnTF { #4#5#6#7 } = \c_zero + { \use_i:nn } { - \bool_if:NF #3 { \c__zhnum_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 - { \__zhnum_split_number_aux:NNfnnn \c_false_bool \c_true_bool } - { \__zhnum_split_number_aux:NNfnnn \c_true_bool \c_false_bool } + \bool_if:NF #1 { \c__zhnum_zero_tl } + \zhnum_process_number:NNNNNN #4#5#6#7#1#2 + \zhnum_scale_map:n {#3} + \int_compare:nNnTF {#7} = \c_zero } - { \int_eval:n { #6 + \c_one } } {#2} {#5} {#6} - } -\cs_new_nopar:Npn \__zhnum_split_number_aux:NNnnnn #1#2#3#4#5#6 - { - \int_compare:nNnF {#5} = {#6} - { \zhnum_split_number:nNNnn {#4} #1#2 {#5} {#3} } + { \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 \zhnum_split_number:nNNnn { fNNf } -\cs_generate_variant:Nn \__zhnum_split_number:nnNNnn { f } -\cs_generate_variant:Nn \__zhnum_split_number_aux:NNnnnn { NNf } -\cs_new_nopar:Npn \zhnum_number_item:nn #1#2 - { \__zhnum_number_item:nNNNN {#2} #1 \q_recursion_stop } -\cs_new_nopar:Npn \__zhnum_number_item:nNNNN #1#2#3#4#5 - { - \int_compare:nNnTF {#1} = \c_zero - { \__zhnum_recursion_stop:NNNNw #2#3#4#5 } - { \__zhnum_number_item:fNNNN { \int_eval:n { #1 - \c_one } } } - } -\cs_generate_variant:Nn \__zhnum_number_item:nNNNN { f } -\cs_new_nopar:Npn \__zhnum_recursion_stop:NNNNw #1#2#3#4#5 \q_recursion_stop - { #1#2#3#4 } -\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_generate_variant:Nn \zhnum_split_number:NNnNNNNw { NNf } +\cs_new:Npn \zhnum_process_number:NNNNNN #1#2#3#4#5#6 { \int_compare:nNnTF {#1} = \c_zero { \bool_if:NF #6 { \c__zhnum_zero_tl } } { \zhnum_digit_map:n {#1} \c__zhnum_thousand_tl } \int_compare:nNnTF {#2} = \c_zero - { \int_compare:nNnT { #1 * (#3#4) } > \c_zero { \c__zhnum_zero_tl } } + { \int_compare:nNnF { #1 * (#3#4) } = \c_zero { \c__zhnum_zero_tl } } { \bool_if:nTF { \l__zhnum_ancient_bool && \int_compare_p:nNn {#2} = \c_two } @@ -276,7 +258,7 @@ { \zhnum_digit_map:n {#2} \c__zhnum_hundred_tl } } \int_compare:nNnTF {#3} = \c_zero - { \int_compare:nNnT { #2 * #4 } > \c_zero { \c__zhnum_zero_tl } } + { \int_compare:nNnF { #2 * #4 } = \c_zero { \c__zhnum_zero_tl } } { \bool_if:nF { @@ -298,18 +280,14 @@ } \int_compare:nNnF {#4} = \c_zero { \zhnum_digit_map:n {#4} } } -\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} @@ -369,17 +347,17 @@ _tl \cs_end: } -\DeclareExpandableDocumentCommand \zhdate { s m } +\DeclareExpandableDocumentCommand \zhdate { +s +m } { \__zhnum_date:www #2 \q_stop - \IfBooleanT {#1} - { \__zhnum_week_day:www #2 \q_stop } + \IfBooleanT #1 + { \__zhnum_week_day:www #2 \q_stop } } -\cs_new_nopar:Npn \__zhnum_date:www #1/#2/#3 \q_stop +\cs_new:Npn \__zhnum_date:www #1/#2/#3 \q_stop { \zhnum_check_time:Nn \zhnum_digits_null:n {#1} \c__zhnum_year_tl - \zhnum_check_time:Nn \zhnum_integer:n {#2} \c__zhnum_month_tl - \zhnum_check_time:Nn \zhnum_integer:n {#3} \c__zhnum_day_tl + \zhnum_check_time:Nn \zhnum_int:n {#2} \c__zhnum_month_tl + \zhnum_check_time:Nn \zhnum_int:n {#3} \c__zhnum_day_tl } \cs_new_nopar:Npn \zhtoday { @@ -387,13 +365,13 @@ \zhnum_check_time:Nn \zhnum_int:n \tex_month:D \c__zhnum_month_tl \zhnum_check_time:Nn \zhnum_int:n \tex_day:D \c__zhnum_day_tl } -\cs_new_nopar:Npn \zhnum_check_time:Nn #1 - { \bool_if:NTF \l__zhnum_time_bool {#1} { \int_eval:n } } -\cs_new_nopar:Npn \zhweekday #1 +\cs_new:Npn \zhnum_check_time:Nn #1 + { \bool_if:NTF \l__zhnum_time_bool {#1} { \int_to_arabic:n } } +\cs_new:Npn \zhweekday #1 { \__zhnum_week_day:www #1 \q_stop } -\cs_new_nopar:Npn \__zhnum_week_day:www #1/#2/#3 \q_stop +\cs_new:Npn \__zhnum_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__zhnum_sat_tl \or: \c__zhnum_sun_tl \or: \c__zhnum_mon_tl @@ -403,7 +381,7 @@ \or: \c__zhnum_fri_tl \fi: } -\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 } @@ -411,18 +389,18 @@ { \__zhnum_Zeller_aux:Nnnn \zhnum_Zeller_Julian:nnn } {#1} {#2} {#3} } -\cs_new_nopar:Npn \__zhnum_Zeller_aux:Nnnn #1#2#3#4 +\cs_new:Npn \__zhnum_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} } -\cs_new_nopar:Npn \zhnum_Zeller_Gregorian:nnn #1#2#3 +\cs_new:Npn \zhnum_Zeller_Gregorian:nnn #1#2#3 { \int_mod:nn { @@ -435,7 +413,7 @@ } { \c_seven } } -\cs_new_nopar:Npn \zhnum_Zeller_Julian:nnn #1#2#3 +\cs_new:Npn \zhnum_Zeller_Julian:nnn #1#2#3 { \int_mod:nn { @@ -447,17 +425,17 @@ } { \c_seven } } -\cs_new_nopar:Npn \zhtime #1 +\cs_new:Npn \zhtime #1 { \__zhnum_time:ww #1 \q_stop } \group_begin: \char_set_lccode:nn { `\; } { `\: } \tl_to_lowercase:n { \group_end: - \cs_new_nopar:Npn \__zhnum_time:ww #1 ; #2 \q_stop + \cs_new:Npn \__zhnum_time:ww #1 ; #2 \q_stop { - \zhnum_check_time:Nn \zhnum_integer:n {#1} \c__zhnum_hour_tl - \zhnum_check_time:Nn \zhnum_integer:n {#2} \c__zhnum_minute_tl + \zhnum_check_time:Nn \zhnum_int:n {#1} \c__zhnum_hour_tl + \zhnum_check_time:Nn \zhnum_int:n {#2} \c__zhnum_minute_tl } } \cs_new_nopar:Npn \zhcurrtime @@ -467,33 +445,36 @@ \zhnum_check_time:Nn \zhnum_int:n { \int_mod:nn \tex_time:D { 60 } } \c__zhnum_minute_tl } -\cs_new_nopar:Npn \zhnum_digit_map:n #1 +\cs_new:Npn \zhnum_digit_map:n #1 { \use:c { c__zhnum_ #1 _tl } } -\cs_new_nopar:Npn \zhnum_scale_map:n #1 +\cs_new:Npn \zhnum_scale_map:n #1 { \cs_if_exist_use:cF { c__zhnum_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__zhnum_scale_int } } -\int_new:N \g__zhnum_scale_int -\int_set_eq:NN \g__zhnum_scale_int \c_eleven +\cs_new:Npn \zhnum_scale_map_loop:n #1 + { \zhnum_scale_map:n { \int_mod:nn {#1} \l__zhnum_scale_int } } +\cs_generate_variant:Nn \zhnum_scale_map:n { f } +\int_new:N \l__zhnum_scale_int +\int_set_eq:NN \l__zhnum_scale_int \c_eleven \cs_new_eq:NN \zhnum_scale_map_hook:n \zhnum_scale_map_loop:n -\NewDocumentCommand \zhnumExtendScaleMap { > { \TrimSpaces } o m } +\tl_const:cn { c__zhnum_s0_tl } { } +\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__zhnum_s \int_eval:n { \l_tmpa_int + \c_eleven } _tl } - \tl_if_exist:cF { \l_tmpa_tl } - { \int_incr:N \g__zhnum_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} } } +\cs_new_protected:Npn \zhnum_set_scale:n #1 + { + \int_incr:N \l_tmpa_int + \tl_set:Nx \l_tmpa_tl + { c__zhnum_s \int_eval:n { \l_tmpa_int + \c_eleven } _tl } + \tl_if_exist:cF { \l_tmpa_tl } + { \int_incr:N \l__zhnum_scale_int } + \tl_set:cn { \l_tmpa_tl } {#1} + } \group_begin: \tl_set:Nn \l_tmpa_tl @@ -543,16 +524,16 @@ \group_end: \keys_define:nn { zhnum / options } { \exp_not:o \l_tmpa_tl } } -\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__zhnum_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__zhnum_cfg_map_prop {#1} {#3} \prop_put:Nnn \l__zhnum_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__zhnum_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__zhnum_cfg_map_finan_prop {#1} {#3} \prop_put:Nnn \l__zhnum_cfg_map_var_prop { financial_#1_#2 } {#3} @@ -563,40 +544,40 @@ \cs_new_protected_nopar:Npn \zhnum_parse_config: { \prop_map_function:NN \l__zhnum_cfg_map_prop \zhnum_check_simp:nn - \bool_if:NF \l__zhnum_reset_bool - { \prop_map_function:NN \l__zhnum_cfg_map_prop \zhnum_check_financial:nn } \zhnum_set_zero: \zhnum_set_week_day: + \bool_if:NF \l__zhnum_reset_bool + { + \zhnum_assgin_const: + \bool_set_true:N \l__zhnum_reset_bool + } } -\cs_new_protected_nopar:Npn \zhnum_check_simp:nn #1#2 +\cs_new_protected:Npn \zhnum_check_simp:nn #1#2 { - \__zhnum_check_simp_aux:nn {#1} {#2} + \__zhnum_check_simp_aux:nn {#2} {#1} \prop_get:NnNT \l__zhnum_cfg_map_finan_prop {#1} \l_tmpa_tl - { \exp_args:Nno \__zhnum_check_simp_aux:nn { financial_ #1 } \l_tmpa_tl } + { \exp_args:No \__zhnum_check_simp_aux:nn { \l_tmpa_tl } { financial_ #1 } } } -\cs_new_protected_nopar:Npn \__zhnum_check_simp_aux:nn #1#2 +\cs_new_protected:Npn \__zhnum_check_simp_aux:nn #1#2 { - \prop_get:NnNTF \l__zhnum_cfg_map_var_prop { #1 _trad } \l_tmpa_tl + \prop_get:NnNTF \l__zhnum_cfg_map_var_prop { #2 _trad } \l_tmpa_tl { - \prop_get:NnNTF \l__zhnum_cfg_map_var_prop { #1 _simp } \l_tmpb_tl - { - \tl_set:cx { l__zhnum_ #1 _tl } - { - \exp_not:n { \bool_if:NTF \l__zhnum_simp_bool } - { \exp_not:o \l_tmpb_tl } { \exp_not:o \l_tmpa_tl } - } - } + \prop_get:NnNF \l__zhnum_cfg_map_var_prop { #2 _simp } \l_tmpb_tl + { \tl_set:Nn \l_tmpb_tl {#1} } + \tl_set:cx { l__zhnum_ #2 _tl } { - \tl_set:cx { l__zhnum_ #1 _tl } - { - \exp_not:n { \bool_if:NTF \l__zhnum_simp_bool } - { \exp_not:n {#2} } { \exp_not:o \l_tmpa_tl } - } + \exp_not:n { \bool_if:NTF \l__zhnum_simp_bool } + { \exp_not:o \l_tmpb_tl } { \exp_not:o \l_tmpa_tl } } } - { \tl_set:cn { l__zhnum_ #1 _tl } {#2} } + { \tl_set:cn { l__zhnum_ #2 _tl } {#1} } } -\cs_new_protected_nopar:Npn \zhnum_check_financial:nn #1#2 +\cs_new_protected_nopar:Npn \zhnum_assgin_const: + { + \prop_map_function:NN \l__zhnum_cfg_map_prop \zhnum_check_financial:nn + \zhnum_set_alias: + } +\cs_new_protected:Npn \zhnum_check_financial:nn #1#2 { \prop_get:NnNTF \l__zhnum_cfg_map_finan_prop {#1} \l_tmpa_tl { @@ -616,7 +597,7 @@ { \tl_set:cx { l__zhnum_0_tl } { - \exp_not:n { \bool_if:nTF \l__zhnum_null_bool } + \exp_not:n { \bool_if:NTF \l__zhnum_null_bool } { \exp_not:o \l__zhnum_null_tl } { \exp_not:v { l__zhnum_0_tl } } } } @@ -636,28 +617,27 @@ { \exp_not:N \c__zhnum_weekday_tl \exp_not:v { l__zhnum_6_tl } } \tl_set:Nx \l__zhnum_sun_tl { \exp_not:N \c__zhnum_weekday_tl \exp_not:o \l__zhnum_day_tl } - \bool_if:NF \l__zhnum_reset_bool - { - \clist_map_inline:nn { mon , tue , wed , thu , fri , sat , sun } - { - \zhnum_assgin_const_tl:cx - { c__zhnum_ ##1 _tl } { \exp_not:c { l__zhnum_ ##1 _tl } } - } - \bool_set_true:N \l__zhnum_reset_bool - } } +\clist_map_inline:nn { mon , tue , wed , thu , fri , sat , sun } + { \tl_const:cx { c__zhnum_ #1 _tl } { \exp_not:c { l__zhnum_ #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 } -\cs_new_protected_nopar:Npn \zhnum_set_alias: - { - \tl_const:Nx \c__zhnum_zero_tl { \exp_not:c { c__zhnum_ 0 _tl } } - \tl_const:Nx \c__zhnum_ten_tl { \exp_not:c { c__zhnum_ 10 _tl } } - \tl_const:Nx \c__zhnum_hundred_tl { \exp_not:c { c__zhnum_ 100 _tl } } - \tl_const:Nx \c__zhnum_thousand_tl { \exp_not:c { c__zhnum_ 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__zhnum_zero_tl + \exp_not:c { c__zhnum_ 0 _tl } + \zhnum_set_alias:NN \exp_not:N \c__zhnum_ten_tl + \exp_not:c { c__zhnum_ 10 _tl } + \zhnum_set_alias:NN \exp_not:N \c__zhnum_hundred_tl + \exp_not:c { c__zhnum_ 100 _tl } + \zhnum_set_alias:NN \exp_not:N \c__zhnum_thousand_tl + \exp_not:c { c__zhnum_ 1000 _tl } } -\AtEndOfPackage { \zhnum_set_alias: } -\cs_new_protected_nopar:Npn \zhnum_load_cfg:n #1 +\AtEndOfPackage + { \cs_set_eq:NN \zhnum_set_alias:NN \tl_set_eq:NN } +\cs_new_protected:Npn \zhnum_load_cfg:n #1 { \zhnum_set_cfg_name:Nn \l__zhnum_cfg_tl {#1} \tl_if_eq:NNF \l__zhnum_cfg_tl \l__zhnum_last_cfg_tl @@ -665,14 +645,14 @@ \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__zhnum_cfg_ \l__zhnum_cfg_tl _prop } { \tl_set_eq:NN \l__zhnum_last_cfg_tl \l__zhnum_cfg_tl } { \zhnum_input_cfg:n {#1} } \__zhnum_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 } { @@ -688,7 +668,7 @@ \__zhnum_update_cfg_prop:N \__zhnum_prop_gset_eq:Nn \group_end: } -\cs_new_protected_nopar:Npn \__zhnum_update_cfg_prop:N #1 +\cs_new_protected:Npn \__zhnum_update_cfg_prop:N #1 { #1 \l__zhnum_cfg_map_prop { g__zhnum_cfg_ \l__zhnum_cfg_tl _prop } #1 \l__zhnum_cfg_map_var_prop { g__zhnum_cfg_var_ \l__zhnum_cfg_tl _prop } @@ -727,7 +707,7 @@ } \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__zhnum_encoding_tl {#2} \tl_set:Nx #1 { \tl_to_str:N \l__zhnum_encoding_tl } @@ -754,7 +734,7 @@ } \int_new:N \l__zhnum_byte_min_int \int_new:N \l__zhnum_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__zhnum_encoding_tl {#2} \tl_set:Nx #1 @@ -812,8 +792,8 @@ \tl_new:N \l__zhnum_encoding_tl \msg_new:nnnn { zhnumber } { encoding-invalid } { The~encoding~`#1'~is~invalid. } - { Available~encoding~are~`UTF8',~`GBK'~and~`Big5'. } -\NewDocumentCommand \zhnumsetup { m } + { Available~encodings~are~`UTF8',~`GBK'~and~`Big5'. } +\NewDocumentCommand \zhnumsetup { +m } { \keys_set:nn { zhnum / options } {#1} \tex_ignorespaces:D |