summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-06-06 20:50:49 +0000
committerKarl Berry <karl@freefriends.org>2018-06-06 20:50:49 +0000
commite0b44a591ea65a8c11f15d8e4c0cfb50a6058782 (patch)
treeb600ee10570f565158fed6ca0495e80d40bc13ec /Master
parent8bcdad0a3fc9ea77205f11c711a7cfe2f95d1940 (diff)
cooking-units (6jun18)
git-svn-id: svn://tug.org/texlive/trunk@47943 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdfbin614258 -> 617911 bytes
-rw-r--r--Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx712
-rw-r--r--Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty546
3 files changed, 709 insertions, 549 deletions
diff --git a/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf b/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf
index 8a0308356e8..80fd68d708d 100644
--- a/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf
+++ b/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx b/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
index 5cf667c0dab..52b05783e36 100644
--- a/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
+++ b/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
@@ -235,7 +235,7 @@ and the derived file cooking-units.sty.
\NewDocumentCommand \PrintGroup { m }
{
\mygroup {#1} &
- \clist_use:cn { l__cooking_units_group_ #1 _clist } { ,~ }
+ \seq_use:cn { l__cooking_units_group_ #1 _seq } { ,~ }
}
@@ -418,7 +418,7 @@ and the derived file cooking-units.sty.
{ THEEND } { \\ \bottomrule }
}{
\__table_midrule:
- ##1
+ \texttt{##1}
&
\clist_if_in:NnTF \l_list_of_textunits_clist {##1}
{ \l_translation_does_not_exist_tl }
@@ -456,11 +456,11 @@ and the derived file cooking-units.sty.
\tl_set:Nn \l_tmpa_tl {#1}
\__cooking_units_phrase_list_get_for:NNTF \l_tmpa_prop \l_tmpa_tl
{
- \__cooking_units_translate_let:VNxx \l_tmpa_tl \l_tmpa_clist
+ \__cooking_units_translate_let:VNxx \l_tmpa_tl \l_tmpa_seq
{ phrase-clist } \c__cooking_units_postfix_phrase_tl
}
{ \ERROR }
- \clist_gput_right:Nn \l_tmpa_clist { THEEND }
+ \clist_gput_right:Nn \l_tmpa_seq { THEEND }
\cs_gset_eq:NN \__table_midrule: \__table_default_midrule:
\begin{tabular}{ l l l l l }
\toprule
@@ -471,7 +471,7 @@ and the derived file cooking-units.sty.
\NewDocumentCommand \CreatePhraseTableRow { m }
{
- \clist_map_inline:Nn \l_tmpa_clist
+ \seq_map_inline:Nn \l_tmpa_seq
{
\str_case:nnF {##1}
{
@@ -534,6 +534,7 @@ and the derived file cooking-units.sty.
\newcookingunit {st}
\newcookingunit [\ensuremath{ {} ^ { \circ } }\kern-\scriptspace R{\text{\o}}] {Ro}
+
\cuaddkeys {lb}
{
{st} { 1/14 } %% 1 lb are 1/14 st
@@ -678,8 +679,27 @@ and the derived file cooking-units.sty.
% \changes {2018/04/20} {1.30} {Cooking Units-keys are not allowed to contain
% either \enquote{,} or \enquote{/}.}
%
-%
-%
+% \changes {2018/06/05} {1.40} {This version introduces mayor internal changes.
+% For users not many things change.}
+% \changes {2018/06/05} {1.40} {Rework parsing code (again). As this is
+% basically an improved version of the old parsing algorithm, there is
+% no huge version change.}
+% \changes {2018/06/05} {1.40} {Improve error-recovery by a lot!}
+% \changes {2018/06/05} {1.40} {Bugfix: A range in \mycs{Cutext} (and numerals=true)
+% will print the second word small.}
+% \changes {2018/06/05} {1.40} {Add \enquote{range-sign} for translations (not usable yet).}
+% \changes {2018/06/05} {1.40} {Convert \texttt{clist} to \texttt{seq} if possible.}
+% \changes {2018/06/05} {1.40} {Remove unnecessary variants.}
+% \changes {2018/06/05} {1.40} {Fix some more argument specifiers.}
+% \changes {2018/06/05} {1.40} {Renaming of some internal commands.}
+% \changes {2018/06/05} {1.40} {\opt{set-unknown-message}: Fix default value.}
+% \changes {2018/06/05} {1.40} {Change (\texttt{amount-not-known}): Change message a bit.}
+% \changes {2018/06/05} {1.40} {Bugfix (\texttt{label-not-defined}): Add |'#1'|.}
+% \changes {2018/06/05} {1.40} {Bugfix (\texttt{unit-change}): \opt{convert-to-eV}
+% can be again used as a local argument.}
+% \changes {2018/06/05} {1.40} {Change order of boolean testing for |\@@_calc_references:NN|.}
+% \changes {2018/06/05} {1.40} {Bugfix (\texttt{phrases}): Use the phrase from the first amount to check
+% the second (and don't parse through the second amount).}
%
%
%
@@ -691,7 +711,7 @@ and the derived file cooking-units.sty.
%\title{The \pkg{\jobname} package^^A
%\thanks{This document corresponds to \textsf{Benedikt Vitecek}~\fileversion, dated~\filedate.}}
%\author{Ben Vitecek \\ b.vitecek@gmx.at}%
-%\date{2018/04/20}%
+%\date{\filedate}%
%
% \maketitle
%
@@ -718,6 +738,7 @@ and the derived file cooking-units.sty.
% \cuam{12} Eier \\
% \cuam{18} Eier \\
% \cuam{132--168} Eier \\
+% \cuam{12--60} Eier \\
% \cuam{12--24} Eier \\
% \cuam{12--24.2} Eier \\
% \cuam{24--12} Eier \\
@@ -873,6 +894,7 @@ and the derived file cooking-units.sty.
% \cutext{1}{l} \\
% \Cutext{1}{l} \\
% \cutext{1--2}{l} \\
+% \Cutext{1--2}{l} \\
% \cutext{12}{l} \\
% \Cutext{13}{l}
% \end{cuexamplecode}
@@ -3066,14 +3088,14 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\ProvidesExplPackage
{cooking-units}
- {2018/04/20}
- {1.30}
+ {2018/06/05}
+ {1.40}
{Ein Paket fuer Kocheinheiten}
% \end{macrocode}
%
% Checking if \pkg{expl3} is up-to-date, otherwise abort the loading of the package.
% \begin{macrocode}
-\@ifpackagelater { expl3 } { 2018/02/21 }
+\@ifpackagelater { expl3 } { 2018/06/01 }
{ }
{
\PackageError { cooking-units } { Support~package~expl3~too~old }
@@ -3151,8 +3173,8 @@ and the derived file cooking-units.sty.
% Some variations of commands we will need later.
% \begin{macrocode}
\cs_generate_variant:Nn \tl_replace_all:Nnn { NVn }
-\cs_generate_variant:Nn \tl_replace_once:Nnn { NnV, NVn }
-\cs_generate_variant:Nn \tl_if_in:nnTF { nV , xn }
+\cs_generate_variant:Nn \tl_replace_once:Nnn { NVn }
+\cs_generate_variant:Nn \tl_if_in:nnTF { nV }
\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF }
\cs_generate_variant:Nn \tl_if_in:NnT { NVT }
\cs_generate_variant:Nn \fp_compare:nNnT { vNnT }
@@ -3160,6 +3182,7 @@ and the derived file cooking-units.sty.
\cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV }
\cs_generate_variant:Nn \msg_error:nnnn { nnnV }
\cs_generate_variant:Nn \msg_error:nnn { nnV }
+\cs_generate_variant:Nn \msg_warning:nnn { nnV }
% \end{macrocode}
% \end{macro}
%
@@ -3397,22 +3420,22 @@ and the derived file cooking-units.sty.
%\end{macro}
%
%
-% \begin{macro} { \g_@@_allowed_unit_phrases_tl }
+% \begin{macro} { \g_@@_allowed_special_keys_seq }
% \changes {2016/06/12} {New: \cs{g_@@_allowed_unit_phrases_tl}}
% Used for the keys 'one(m)', 'one(f)', etc. Those are special keys
% which cannot be used as units, but are processed by the commands in
% the language section as such.
% \begin{macrocode}
-\clist_new:N \g_@@_allowed_special_keys_clist
+\seq_new:N \g_@@_allowed_special_keys_seq
% \end{macrocode}
% \end{macro}
%
-% \begin{macro} { \l_@@_phrase_numbers_clist }
+% \begin{macro} { \l_@@_phrase_numbers_seq }
% Inside this list the numbers for which a phrase is defined
% is stored in. As this is language specific, the list is stored
% inside a language-sensitive command and retrived when needed.
% \begin{macrocode}
-\clist_new:N \l_@@_phrase_numbers_clist
+\seq_new:N \l_@@_phrase_numbers_seq
% \end{macrocode}
% \end{macro}
%
@@ -3462,7 +3485,7 @@ and the derived file cooking-units.sty.
% \l_@@_lokal_persons_bool,
% \l_@@_cutext_to_cunum_bool,
% \l_@@_cutext_old_bool,
-% \l_@@_cutext_change_unit_bool,
+% \l_@@_cutext_keep_unit_bool,
% \l_@@_round_commercial_bool,
% \l_@@_use_phrases_bool,
% \l_@@_lokal_phrase_bool
@@ -3488,7 +3511,7 @@ and the derived file cooking-units.sty.
\bool_new:N \l_@@_lokal_persons_bool
\bool_new:N \l_@@_cutext_to_cunum_bool
\bool_new:N \l_@@_cutext_old_bool
-\bool_new:N \l_@@_cutext_change_unit_bool
+\bool_new:N \l_@@_cutext_keep_unit_bool
\bool_new:N \l_@@_round_commercial_bool
\bool_new:N \l_@@_use_phrases_bool
\bool_new:N \l_@@_lokal_phrase_bool
@@ -3496,6 +3519,7 @@ and the derived file cooking-units.sty.
\bool_new:N \l_@@_lokal_numeral_bool
\bool_new:N \l_@@_round_precision_positive_bool
\bool_new:N \l_@@_fourty_two_bool
+\bool_new:N \l_@@_phrase_negative_bool
% \end{macrocode}
%
% While rewriting the code I searched for those
@@ -3505,7 +3529,7 @@ and the derived file cooking-units.sty.
\bool_new:N \l_@@_lokal_fraction_bool
\bool_new:N \l_@@_print_fraction_bool
\bool_new:N \l_@@_lokal_mixed_fraction_bool
-\bool_new:N \l_@@_decimal_in_input_bool
+\bool_new:N \l_@@_check_decimal_bool
% \end{macrocode}
% \end{macro}
%
@@ -3513,7 +3537,7 @@ and the derived file cooking-units.sty.
%
% Setting some of them to \true\ or another boolean respectively.
% \begin{macrocode}
-\bool_set_true:N \l_@@_cutext_change_unit_bool
+\bool_set_false:N \l_@@_cutext_keep_unit_bool
\bool_set_eq:NN \l_@@_print_numeral_bool \g_@@_opt_numeral_bool
% \end{macrocode}
%
@@ -3531,11 +3555,11 @@ and the derived file cooking-units.sty.
% \end{macrocode}
%\end{macro}
%
-% \begin{macro}{ \q_@@_decimal , \q_@@_frac , \q_@@_mixed_frac }
+% \begin{macro}{ \q_@@_decimal , \q_@@_fraction , \q_@@_mixed_fraction }
% \begin{macrocode}
\quark_new:N \q_@@_decimal
-\quark_new:N \q_@@_frac
-\quark_new:N \q_@@_mixed_frac
+\quark_new:N \q_@@_fraction
+\quark_new:N \q_@@_mixed_fraction
% \end{macrocode}
%\end{macro}
%
@@ -3655,8 +3679,9 @@ and the derived file cooking-units.sty.
% \begin{macro}{ cutext-change-unit }
% Do not wanna change units in \mycs{cutext}? Use this option.
% \begin{macrocode}
- cutext-change-unit .bool_set:N = \l_@@_cutext_change_unit_bool ,
+ cutext-change-unit .bool_set_inverse:N = \l_@@_cutext_keep_unit_bool ,
cutext-change-unit .default:n = { true } ,
+ cutext-change-unit .groups:n = { change-unit } ,
% \end{macrocode}
% \end{macro}
%
@@ -3733,9 +3758,6 @@ and the derived file cooking-units.sty.
}
}
\use:n { \tl_set:Nn \l_@@_input_allowed_special_signs_tl {#1} }
-% \str_if_eq:nnTF {#1} { < }
-% { \msg_error:nn { cooking-units } { <-not-allowed-as-special-sign } }
-% { \tl_set:Nn \l_@@_input_allowed_special_signs_tl {#1} }
} ,
% \end{macrocode}
%\end{macro}
@@ -3753,9 +3775,6 @@ and the derived file cooking-units.sty.
\tl_put_right:Nn \l_@@_input_allowed_special_signs_tl {##1}
}
}
-% \str_if_eq:nnTF {#1} { < }
-% { \msg_error:nn { cooking-units } { <-not-allowed-as-special-sign } }
-% { \tl_put_right:Nn \l_@@_input_allowed_special_signs_tl {#1} }
} ,
add-special-sign .default:n = { } ,
% \end{macrocode}
@@ -3771,7 +3790,7 @@ and the derived file cooking-units.sty.
\msg_redirect_name:nnn { cooking-units } { amount-not-known }
{ \l_keys_choice_tl }
} ,
- set-unknown-message .default:n = { set-cutext-translation-message } ,
+ set-unknown-message .default:n = { warning } ,
% \end{macrocode}
%\end{macro}
%
@@ -3971,10 +3990,7 @@ and the derived file cooking-units.sty.
% \begin{macro}{ label }
% Defines a label \dots\ is \mycs{culabel} as a key.
% \begin{macrocode}
- label .code:n =
- {
- \@@_label_and_persons:n {#1}
- } ,
+ label .code:n = \@@_label_and_persons:n {#1} ,
label .value_required:n = { true } ,
% \end{macrocode}
% \end{macro}
@@ -3982,10 +3998,7 @@ and the derived file cooking-units.sty.
% \begin{macro}{ get-label }
% \mycs{curef} as a key.
% \begin{macrocode}
- get-label .code:n =
- {
- \@@_curef:n {#1}
- } ,
+ get-label .code:n = \@@_curef:n {#1} ,
label .value_required:n = { true } ,
% \end{macrocode}
% \end{macro}
@@ -3993,10 +4006,7 @@ and the derived file cooking-units.sty.
% \begin{macro}{ ref }
% The |<>| option for keys.
% \begin{macrocode}
- ref .code:n =
- {
- \@@_reference_label_and_persons:n {#1}
- } ,
+ ref .code:n = \@@_reference_label_and_persons:n {#1} ,
ref .value_required:n = { true } ,
% \end{macrocode}
% \end{macro}
@@ -4025,7 +4035,7 @@ and the derived file cooking-units.sty.
\@@_temperature_to_check_print_error:n
\@@_temperatures_to_check_define:nn
{#1}
- },
+ } ,
temperature-to-check .value_required:n = { true } ,
% \end{macrocode}
% \end{macro}
@@ -4119,8 +4129,15 @@ and the derived file cooking-units.sty.
%
%
%
-%
-%
+% \begin{macro}{}
+% \begin{macrocode}
+ curef-do-not-change .code:n =
+ {
+ \seq_if_in:NnF \l_@@_curef_do_not_change_seq {#1}
+ {\seq_put_right:Nn \l_@@_curef_do_not_change_seq {#1} }
+ } ,
+% \end{macrocode}
+% \end{macro}
%
%
%
@@ -4328,7 +4345,7 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { amount-not-known }
{
- The \ amount \ of \ #1 \ is \ not \ known \ at \ line \
+ The \ amount \ '#1' \ is \ not \ known \ at \ line \
\msg_line_number: .
}
{
@@ -4453,7 +4470,7 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\msg_new:nnnn { cooking-units } { label-not-defined }
{
- The \ label \ is \ not \ defined. \ Please \ note \ that \ a \ label
+ The \ label \ '#1' \ is \ not \ defined. \ Please \ note \ that \ a \ label
\ has \ to \ defined \ before \ it \ is \ referenced.
}{
Define \ the \ label \ before \ using \ it.
@@ -4609,7 +4626,7 @@ and the derived file cooking-units.sty.
{
\@@_if_integer:VF #3
{ \bool_set_false:N #1 }
- }
+ }
}
% \end{macrocode}
% \end{macro}
@@ -4666,12 +4683,12 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_define_unit_group:nn #1#2
{
- \clist_new:c { l_@@_group_ #1 _clist }
- \clist_set:cn { l_@@_group_ #1 _clist } {#2}
+ \seq_new:c { l_@@_group_ #1 _seq }
+ \seq_set_from_clist:cn { l_@@_group_ #1 _seq } {#2}
\keys_define:nn { cooking-units }
{
#1 .code:n = { \@@_unit_group_convert_units:nn {#1} {##1} } ,
- #1 .groups:n = { change-unit }
+ #1 .groups:n = { change-unit } ,
}
}
% \end{macrocode}
@@ -4681,7 +4698,7 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_error_if_group_not_defined:n #1
{
- \clist_if_exist:cF { l_@@_group_ #1 _clist }
+ \seq_if_exist:cF { l_@@_group_ #1 _seq }
{ \msg_error:nn { cooking-units} { group-key-unknown } }
}
% \end{macrocode}
@@ -4693,9 +4710,9 @@ and the derived file cooking-units.sty.
{
\@@_error_if_group_not_defined:n {#1}
\@@_error_if_unit_not_defined:n {#2}
- \clist_if_in:cnTF { l_@@_group_ #1 _clist } {#2}
+ \seq_if_in:cnTF { l_@@_group_ #1 _seq } {#2}
{
- \clist_map_inline:cn { l_@@_group_ #1 _clist }
+ \seq_map_inline:cn { l_@@_group_ #1 _seq }
{ \@@_keys_set:nnn { cooking-units } {##1} {#2} }
}{
\msg_error:nnxxx
@@ -4703,7 +4720,7 @@ and the derived file cooking-units.sty.
{ group-choice-not-allowed }
{#1}
{#2}
- { \clist_use:cnnn { l_@@_group_ #1 _clist } { ',~ ' } { ',~ ' } { ' ~ and ~ ' } }
+ { \seq_use:cnnn { l_@@_group_ #1 _seq } { ',~ ' } { ',~ ' } { ' ~ and ~ ' } }
}
}
\@@_define_unit_group:nn { weight } { kg , dag, g, oz, lb, stick }
@@ -4727,8 +4744,8 @@ and the derived file cooking-units.sty.
\clist_map_inline:nn {#2}
{
\@@_error_if_unit_not_defined:n {##1}
- \clist_if_in:cnF { l_@@_group_ #1 _clist } {##1}
- { \clist_put_right:cn { l_@@_group_ #1 _clist } {##1} }
+ \seq_if_in:cnF { l_@@_group_ #1 _seq } {##1}
+ { \seq_put_right:cn { l_@@_group_ #1 _seq } {##1} }
}
}
% \end{macrocode}
@@ -4742,7 +4759,7 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\seq_new:N \g_@@_natural_units_seq
\prop_new:N \g_@@_convert_to_eV_remember_prop
-\seq_set_split:Nnn \g_@@_natural_units_seq { , }
+\seq_set_from_clist:Nn \g_@@_natural_units_seq
{
eV ,
eVc-2 ,
@@ -5073,7 +5090,7 @@ and the derived file cooking-units.sty.
{
\SaveTranslationFor {#2} {#1} { #3 #4 }
}
-\cs_generate_variant:Nn \@@_translate:nn { xx }
+\cs_generate_variant:Nn \@@_translate:nn { xx , VV }
\cs_generate_variant:Nn \@@_translate_let:Nnn { Nxx }
\cs_generate_variant:Nn \@@_translate_let:nNnn { VNxx, nNxx }
% \end{macrocode}
@@ -5093,9 +5110,9 @@ and the derived file cooking-units.sty.
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_translate_one_to_and_check_existance:Nx }
+% \begin{macro}{\@@_translate_one_and_check_existance:Nx }
% \begin{macrocode}
-\cs_new:Npn \@@_translate_one_to_and_check_existance:Nx #1#2
+\cs_new:Npn \@@_translate_one_and_check_existance:Nn #1#2
{
\@@_translate_let:Nxx #1 {#2} \c_@@_postfix_gender_tl
\@@_unitname_get:NxF #1 { one (#1) }
@@ -5104,16 +5121,17 @@ and the derived file cooking-units.sty.
\msg_error:nnn { cooking-units } { Translation-not-available } { one (#1) }
}
}
+\cs_generate_variant:Nn \@@_translate_one_and_check_existance:Nn { Nx }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{ decimal-mark, one(m), one(f), one(n) }
% Defining the translation for the decimal-mark. Note that those
% 'phrases' are stored inside
-% \verb|\g_@@_allowed_special_keys_clist|.
+% \verb|\g_@@_allowed_special_keys_seq|.
% Furthermore some translations are defined.
% \begin{macrocode}
-\clist_gset:Nn \g_@@_allowed_special_keys_clist
+\seq_gset_from_clist:Nn \g_@@_allowed_special_keys_seq
{
decimal-mark ,
one (m) ,
@@ -5147,6 +5165,13 @@ and the derived file cooking-units.sty.
\@@_newtranslation_to:nnVn { German } { one (n) } \c_@@_postfix_unitname_tl { ein }
% \end{macrocode}
%
+% \begin{macrocode}
+\@@_newtranslation_base:nVn { range-sign } \c_@@_postfix_unitname_tl { -- }
+\@@_newtranslation_base:nVn { range-sign } \c_@@_postfix_unitname_pl_tl { \q_@@_no_translation }
+\@@_newtranslation_to:nnVn { German } { range-sign } \c_@@_postfix_unitname_tl { ~bis~ }
+\@@_newtranslation_to:nnVn { English } { range-sign } \c_@@_postfix_unitname_tl { ~to~ }
+% \end{macrocode}
+%
%
% \section{General}
%
@@ -5174,18 +5199,18 @@ and the derived file cooking-units.sty.
% Some units have options added to them. To get those options it is first
% needed to know which unit will be used at all. Therefore units will
% be changed first and afterwards the other options are processed.
+%
+% |\l_@@_convert_to_eV_bool| must be checked after processing the keys
+% as the option \opt{convert-to-eV} is set during this process.
% \begin{macrocode}
\cs_new_protected:Npn \@@_initialise_unit_change:n #1
{
\tl_if_empty:nF {#1}
- {
- \keys_set_groups:nnn { cooking-units } { change-unit } {#1}
- }
- \bool_if:NT \l_@@_convert_to_eV_bool { \@@_convert_to_eV: }
+ { \keys_set_groups:nnn { cooking-units } { change-unit } {#1} }
+ \bool_if:NT \l_@@_convert_to_eV_bool
+ { \@@_convert_to_eV: }
\prop_get:NVNF \l_@@_change_unit_prop \l_@@_given_unit_tl \l_@@_option_unit_tl
- {
- \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_given_unit_tl
- }
+ { \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_given_unit_tl }
}
% \end{macrocode}
% \begin{macrocode}
@@ -5288,8 +5313,7 @@ and the derived file cooking-units.sty.
% \begin{macro}{ \@@_print_fractions:nnn }
% The name of this function is the name of the game: It prints fractions.
% Furthermore it sets the boolean \lstinline|fraction_in_input_bool| to true
-% so that the correct unit is printed. Instead of \lstinline|\kern| I used the
-% \lstinline|\hbox_to_wd:nn| command (I don't have a better idea).
+% so that the correct unit is printed.
%
% Since v.1.10(alpha) it also prints the minus sign (hopefully correct).
% \begin{macrocode}
@@ -5307,17 +5331,55 @@ and the derived file cooking-units.sty.
% \end{macro}
%
%
+% \begin{macro}{ \@@_print_ranges:NN }
+% \begin{macrocode}
+\cs_new:Npn \@@_print_ranges:NN #1#2
+ {
+ \@@_print_input:N #1
+ \bool_if:NTF \l_@@_using_cutext_bool
+ {
+ \tl_use:N \l_@@_cutext_range_sign_tl
+% \@@_translate:VV { range-sign } \c_@@_postfix_unitname_tl
+ \bool_set_false:N \l_@@_cutext_uppercase_word_bool
+ }
+ { \tl_use:N \l_@@_cunum_range_sign_tl }
+ \@@_print_input:N #2
+ }
+% \end{macrocode}
+% \end{macro}
+%
%
%
%
%
% \subsection {Parsing and checking numbers}
%
-% This subsection contains macros helping an checking the input.
+% This subsection contains macros for splitting an checking the input.
+%
+% \begin{macro}{\@@_create_error:n, \@@_create_error_and_stop:n , \@@_create_error:nn }
+% \begin{macrocode}
+\cs_new:Npn \@@_create_error:n #1
+ {
+ \bool_set_true:N \l_@@_error_bool
+ \msg_error:nnV { cooking-units } {#1} \l_@@_given_amount_tl
+ }
+\cs_new:Npn \@@_create_error_and_stop:n #1
+ {
+ \bool_set_true:N \l_@@_error_bool
+ \msg_error:nnV { cooking-units } {#1} \l_@@_given_amount_tl
+ \use_none_delimit_by_q_nil:w
+ }
+\cs_new:Npn \@@_create_error:nn #1#2
+ {
+ \bool_set_true:N \l_@@_error_bool
+ \msg_error:nnnV { cooking-units } {#1} {#2} \l_@@_given_amount_tl
+ }
+% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{ \@@_parse_input:n }
% Rescans the input to get rid of spaces and to make \_ and ? inactive
-% (french with babel makes ? active and changes the definition of it).
+% (french with babel makes |?| active and changes the definition of it).
% \lstinline|--| is replaced by \lstinline|\q_@@_range| and the input is parsed
% (if not empty). Afterwards the units are printed.
% \begin{macrocode}
@@ -5326,7 +5388,7 @@ and the derived file cooking-units.sty.
\bool_if:NTF \l_@@_fourty_two_bool
{ \tl_clear:N \l_@@_given_amount_tl }
{ \@@_set_amount:Nn \l_@@_given_amount_tl {#1} }
- \tl_set_rescan:NnV \l_@@_tmpa_tl
+ \tl_set_rescan:NnV \l_@@_given_amount_tl
{
\char_set_catcode_letter:N \_ %
\char_set_catcode_ignore:N \ %
@@ -5334,63 +5396,130 @@ and the derived file cooking-units.sty.
} \l_@@_given_amount_tl
\bool_lazy_or:nnTF
{ \l_@@_draft_bool }
- { \tl_if_empty_p:N \l_@@_tmpa_tl }
+ { \tl_if_empty_p:N \l_@@_given_amount_tl }
{
\bool_if:NTF \l_@@_fourty_two_bool
{ 42 }
- { \l_@@_tmpa_tl }
+ { \l_@@_given_amount_tl }
}{
- \tl_if_in:NVT \l_@@_tmpa_tl \l_@@_input_range_sign_tl
- {
- \tl_replace_once:NVn \l_@@_tmpa_tl \l_@@_input_range_sign_tl { \q_@@_range }
- \bool_set_true:N \l_@@_range_in_input_bool
- }
- \@@_parsing_amount_input:V \l_@@_tmpa_tl
- \@@_split_input:
+ \tl_set_eq:NN \l_@@_tmpa_tl \l_@@_given_amount_tl
+ \@@_split_input:N \l_@@_tmpa_tl
+ \@@_process_and_print_input:
}
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{ \@@_parsing_amount_input:n }
+% \begin{macro}{ \@@_split_input:N , \@@_process_and_print_input: , \@@_process_tmp: }
+% I would need to check for |/| and |_| anyway. So let's do it here
+% and use the booleans for error-checking.
% \begin{macrocode}
-\cs_new:Npn \@@_parsing_amount_input:n #1
+\cs_new:Npn \@@_split_input:N #1
{
- \cs_set_eq:NN \@@_parse:N \@@_start_loop:N
- \tl_map_function:nN {#1} \@@_parse:N
+ \tl_if_in:NVT #1 \l_@@_input_range_sign_tl
+ {
+ \tl_replace_once:NVn #1 \l_@@_input_range_sign_tl { \q_@@_range }
+ \bool_set_true:N \l_@@_range_in_input_bool
+ }
+ \tl_if_in:NnT #1 { / }
+ {
+ \bool_set_true:N \l_@@_lokal_fraction_bool
+ \bool_if:NT \l_@@_range_in_input_bool
+ { \@@_create_error_and_stop:n { fraction-not-allowed-with-range } }
+ }
+ \tl_if_in:NnT #1 { _ }
+ {
+ \bool_set_true:N \l_@@_lokal_mixed_fraction_bool
+ \bool_if:NF \l_@@_lokal_fraction_bool
+ { \@@_create_error_and_stop:n { missing-slash } }
+ }
+ \@@_split:N #1
+ \use_none_delimit_by_q_nil:w \q_nil
+ }
+% \end{macrocode}
+% If an error was raised during parsing, just print the input. Else, go to the next set
+% of commands.
+% \begin{macrocode}
+\cs_new:Npn \@@_process_tmp: { }
+\cs_new:Npn \@@_process_and_print_input:
+ {
+ \bool_if:NTF \l_@@_error_bool
+ { \l_@@_given_amount_tl }
+ { \@@_process_tmp: }
}
-\cs_generate_variant:Nn \@@_parsing_amount_input:n { V }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{ \@@_split_input:}
-% Splits the input into fractions or ranges.
-% Depending on the input on of the four macros are used.
+% Splits the input into fractions or ranges.
+% Errors are already checked at this point.
% \begin{macrocode}
-\cs_new:Npn \@@_split_input:
+\cs_new:Npn \@@_split:N #1
{
\bool_if:NTF \l_@@_lokal_fraction_bool
+ { \@@_split_fraction:V }
{
- \tl_set_eq:NN \l_@@_number_tmpb_tl \l_@@_tmpa_tl
- \bool_lazy_or:nnT
- { \l_@@_lokal_persons_bool }{ \l_@@_eval_fractions_bool }
- { \bool_set_false:N \l_@@_lokal_fraction_bool }
- \bool_if:NTF \l_@@_lokal_mixed_fraction_bool
- { \@@_parse_mixed_fraction_in_input: }
- { \@@_parse_fraction_in_input: }
- }{
- \bool_if:NT \l_@@_lokal_mixed_fraction_bool
- { \msg_error:nnV { cooking-units } { missing-slash } \l_@@_given_amount_tl }
\bool_if:NTF \l_@@_range_in_input_bool
- {
- \tl_set_eq:NN \l_@@_number_tmpb_tl \l_@@_tmpa_tl
- \@@_parse_range_in_input:
- }{
- \tl_set_eq:NN \l_@@_number_tmpa_tl \l_@@_tmpa_tl
- \@@_parse_number_in_input:
- }
+ { \@@_split_range:V }
+ { \@@_split_number:V }
+ }
+ #1
+ }
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Npn \@@_split_number:n #1
+ {
+ \cs_set_eq:NN \@@_process_tmp: \@@_process_number_in_input:
+ \@@_parse_input_and_safe_in:nN {#1} \l_@@_number_tmpa_tl
+ }
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Npn \@@_split_range:n #1
+ {
+ \cs_set_eq:NN \@@_process_tmp: \@@_process_range_in_input:
+ \@@_split_range_aux:ww #1 \q_stop
+ }
+\cs_new:Npn \@@_split_range_aux:ww #1 \q_@@_range #2 \q_stop
+ {
+ \@@_parse_input_and_safe_in:nN {#1} \l_@@_number_tmpa_tl
+ \@@_parse_input_and_safe_in:nN {#2} \l_@@_number_tmpb_tl
+ }
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Npn \@@_split_fraction:n #1
+ {
+ \bool_if:NTF \l_@@_lokal_mixed_fraction_bool
+ {
+ \cs_set_eq:NN \@@_process_tmp: \@@_process_mixed_fraction_in_input:
+ \@@_split_fraction_mixed:ww
+ }{
+ \cs_set_eq:NN \@@_process_tmp: \@@_process_fraction_in_input:
+ \@@_split_fraction_frac:ww
}
+ #1 \q_stop / \q_recursion_tail \q_stop
+ \q_recursion_stop
+ \bool_lazy_or:nnT
+ { \l_@@_lokal_persons_bool }{ \l_@@_eval_fractions_bool }
+ { \bool_set_false:N \l_@@_lokal_fraction_bool }
}
+\cs_new:Npn \@@_split_fraction_frac:ww #1 / #2 \q_stop
+ {
+ \quark_if_recursion_tail_stop_do:nn {#2}
+ { \@@_create_error:n { fraction-wrong-order } }
+ \@@_parse_input_and_safe_in:nN {#1} \l_@@_number_tmpa_tl
+ \@@_parse_input_and_safe_in:nN {#2} \l_@@_number_tmpb_tl
+ \use_none_delimit_by_q_recursion_stop:w
+ }
+\cs_new:Npn \@@_split_fraction_mixed:ww #1 _ #2 \q_stop
+ {
+ \@@_parse_input_and_safe_in:nN {#1} \l_@@_mixed_fraction_tl
+ \@@_split_fraction_frac:ww #2 \q_stop
+ }
+% \end{macrocode}
+% \begin{macrocode}
+\cs_generate_variant:Nn \@@_split_number:n { V }
+\cs_generate_variant:Nn \@@_split_range:n { V }
+\cs_generate_variant:Nn \@@_split_fraction:n { V }
% \end{macrocode}
% \end{macro}
%
@@ -5399,15 +5528,16 @@ and the derived file cooking-units.sty.
% at the beginning. At first it checks if the first token
% is a sign or not. The parsed input is stored into \lstinline|\l_@@_tmpa_tl|.
% \begin{macrocode}
-%\cs_new:Npn \@@_parse_input_and_safe_in:nN #1 #2
-% {
-% \tl_clear:N \l_@@_tmpa_tl
-% \bool_set_false:N \l_@@_decimal_in_input_bool
-% \@@_start_loop:Nw #1 \q_stop
-% \bool_if:NTF \l_@@_error_bool
-% { \tl_set:Nn #2 {#1} }
-% { \tl_set_eq:NN #2 \l_@@_tmpa_tl }
-% }
+\cs_new:Npn \@@_parse_input_and_safe_in:nN #1 #2
+ {
+ \tl_clear:N \l_@@_tmpa_tl
+ \bool_set_false:N \l_@@_check_decimal_bool
+ \cs_set_eq:NN \@@_parse:N \@@_start_loop:N
+ \tl_map_function:nN {#1} \@@_parse:N
+ \bool_if:NTF \l_@@_error_bool
+ { \use_none_delimit_by_q_nil:w }
+ { \tl_set_eq:NN #2 \l_@@_tmpa_tl }
+ }
% \end{macrocode}
% \end{macro}
%
@@ -5423,8 +5553,6 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_start_loop:N #1
{
- \tl_clear:N \l_@@_tmpa_tl
- \bool_set_false:N \l_@@_decimal_in_input_bool
\cs_set_eq:NN \@@_parse:N \@@_parse_input_loop_aux:N
\tl_if_in:NnTF \l_@@_input_value_signs_tl {#1}
{ \tl_put_right:Nn \l_@@_tmpa_tl {#1} }
@@ -5449,9 +5577,7 @@ and the derived file cooking-units.sty.
{
\tl_if_in:NnTF \l_@@_input_decimal_mark_tl {#1}
{
- \@@_check_repitition:NN
- \q_@@_decimal
- \l_@@_decimal_in_input_bool
+ \@@_check_repitition:N \l_@@_check_decimal_bool
\tl_put_right:Nn \l_@@_tmpa_tl { . }
}{
\tl_if_in:NnTF \l_@@_input_allowed_special_signs_tl {#1}
@@ -5459,81 +5585,49 @@ and the derived file cooking-units.sty.
\bool_set_true:N \l_@@_special_sign_bool
\tl_put_right:Nn \l_@@_tmpa_tl {#1}
}{
- \bool_if:NTF \l_@@_range_in_input_bool
- {
- \tl_if_eq:nnTF \q_@@_range {#1}
- {
- \tl_set_eq:NN \l_@@_number_tmpa_tl \l_@@_tmpa_tl
- \cs_set_eq:NN \@@_parse:N \@@_start_loop:N
- }{
- \tl_if_in:xnTF
- {
- \exp_not:V \l_@@_input_fraction_sign_tl
- \exp_not:V \l_@@_input_mixed_fraction_sign_tl
- } {#1}
- { \msg_error:nnV { cooking-units } { fraction-not-allowed-with-range } \l_@@_given_amount_tl }
- { \msg_error:nnnV { cooking-units } { Token-not-allowed } {#1} \l_@@_given_amount_tl }
- \bool_set_true:N \l_@@_error_bool
- \tl_map_break:
- }
- }{
- \tl_if_in:NnTF \l_@@_input_fraction_sign_tl {#1}
- {
- \@@_check_repitition:NN
- \q_@@_frac
- \l_@@_lokal_fraction_bool
- \tl_set_eq:NN \l_@@_number_tmpa_tl \l_@@_tmpa_tl
- \cs_set_eq:NN \@@_parse:N \@@_start_loop:N
- }{
- \tl_if_in:NnTF \l_@@_input_mixed_fraction_sign_tl {#1}
- {
- \@@_check_repitition:NN
- \q_@@_mixed_frac
- \l_@@_lokal_mixed_fraction_bool
- \bool_if:NT \l_@@_lokal_fraction_bool
- { \msg_error:nnV { cooking-units } { fraction-wrong-order } \l_@@_given_amount_tl }
- \tl_set_eq:NN \l_@@_mixed_fraction_tl \l_@@_tmpa_tl
- \cs_set_eq:NN \@@_parse:N \@@_start_loop:N
- }{
- \msg_error:nnnV { cooking-units } { Token-not-allowed } {#1} \l_@@_given_amount_tl
- \bool_set_true:N \l_@@_error_bool
- \tl_map_break:
- }
- }
- }
+ \bool_set_true:N \l_@@_error_bool
+ \@@_check_error:n {#1}
}
}
}
}
-\cs_new:Npn \@@_check_repitition:NN #1#2
+% \end{macrocode}
+% The idea behind this error checking is the following:
+% At this point I already split the input. This means, a fraction
+% is already split into nominator and denominator and as such, all allowed
+% |/| in the input are already removed. The same goes for |_| (an error message
+% for |_| without |/| would happen before parsing starts). Therefore
+% all |/| and |_| in the input \emph{must} (hopefully) be inside a second time.
+% \begin{macrocode}
+\cs_new:Npn \@@_check_error:n #1
{
- \bool_if:NTF #2
+ \tl_if_in:NnTF \l_@@_input_fraction_sign_tl {#1}
+ { \@@_create_error:n { Second-fraction-sign-not-allowed } }
{
- \tl_case:NnTF #1
- {
- \q_@@_decimal
- { \msg_error:nnV { cooking-units } { Second-decimal-sign-not-allowed } \l_@@_given_amount_tl }
- \q_@@_frac
- { \msg_error:nnV { cooking-units } { Second-fraction-sign-not-allowed } \l_@@_given_amount_tl }
- \q_@@_mixed_frac
- { \msg_error:nnV { cooking-units } { Second-mixed-fraction-sign-not-allowed } \l_@@_given_amount_tl }
- }
- { \bool_set_true:N \l_@@_error_bool }
- { \msg_error:nn { cooking-units } { internal-error } }
+ \tl_if_in:NnTF \l_@@_input_mixed_fraction_sign_tl {#1}
+ { \@@_create_error:n { Second-mixed-fraction-sign-not-allowed } }
+ { \@@_create_error:nn { Token-not-allowed } {#1} }
}
- { \bool_set_true:N #2 }
+ }
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new:Npn \@@_check_repitition:N #1
+ {
+ \bool_if:NTF #1
+ { \@@_create_error:n { Second-decimal-sign-not-allowed } }
+ { \bool_set_true:N #1 }
}
% \end{macrocode}
% \end{macro}
%
%
-% \begin{macro}{\@@_parse_number_in_input:}
+% \begin{macro}{\@@_process_number_in_input:}
% If no fractions and ranges are used this macro activated.
% It just checks the input, stores the checked (and a bit
% changed) input into a macro. This macro is given to another
% function to calculate the input and print it.
% \begin{macrocode}
-\cs_new:Npn \@@_parse_number_in_input:
+\cs_new:Npn \@@_process_number_in_input:
{
\@@_process_and_print_number_in_input:N \l_@@_number_tmpa_tl
}
@@ -5547,28 +5641,27 @@ and the derived file cooking-units.sty.
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{ \@@_parse_range_in_input: }
+% \begin{macro}{ \@@_process_range_in_input: }
% Is used if a \lstinline|\q_@@_range| is found inside the input.
% Seperates the input, checks it and prints it (after calculating
% it). Furthermore a boolean is set to true, is used to check for
% errors (ergo if fractions are used).
+%
+% Set |\l_@@_cutext_uppercase_word_bool| to false
+% so that the second numeral is not capitalized.
% \begin{macrocode}
-\cs_new:Npn \@@_parse_range_in_input:
+\cs_new:Npn \@@_process_range_in_input:
{
\@@_pre_process_input:NN \l_@@_number_tmpa_tl \l_@@_number_tmpb_tl
\@@_calculate_and_store_in:N \l_@@_number_tmpa_tl
\@@_calculate_and_store_in:N \l_@@_number_tmpb_tl
\@@_post_process_input:NN \l_@@_number_tmpa_tl \l_@@_number_tmpb_tl
- \@@_print_input:N \l_@@_number_tmpa_tl
- \bool_if:NTF \l_@@_using_cutext_bool
- { \tl_use:N \l_@@_cutext_range_sign_tl }
- { \tl_use:N \l_@@_cunum_range_sign_tl }
- \@@_print_input:N \l_@@_number_tmpb_tl
+ \@@_print_ranges:NN \l_@@_number_tmpa_tl \l_@@_number_tmpb_tl
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{ \@@_parse_fraction_in_input: }
+% \begin{macro}{ \@@_process_fraction_in_input: }
% If a \lstinline|/| (but no \lstinline|_|) is found inside the input.
% Well \dots\ does the same as the functions before.
% If fractions should be evaluated the input is \dots\ well,
@@ -5577,7 +5670,7 @@ and the derived file cooking-units.sty.
% argument in \lstinline|\@@_print_fractions:nnn| indicates a
% \enquote{normal} fraction.
% \begin{macrocode}
-\cs_new:Npn \@@_parse_fraction_in_input:
+\cs_new:Npn \@@_process_fraction_in_input:
{
\bool_lazy_or:nnTF
{ \l_@@_lokal_fraction_bool }
@@ -5600,7 +5693,7 @@ and the derived file cooking-units.sty.
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{ \@@_parse_mixed_fraction_in_input: }
+% \begin{macro}{ \@@_process_mixed_fraction_in_input: }
% The same procedure as last function? The same procedure as every
% function!
%
@@ -5614,7 +5707,7 @@ and the derived file cooking-units.sty.
% \end{align}
%
% \begin{macrocode}
-\cs_new:Npn \@@_parse_mixed_fraction_in_input:
+\cs_new:Npn \@@_process_mixed_fraction_in_input:
{
\@@_tl_if_in_remove_and_set_bool:NnN \l_@@_mixed_fraction_tl { - } \l_@@_minus_bool
\@@_tl_if_in_remove_and_reverse_bool:NnN \l_@@_number_tmpa_tl { - } \l_@@_minus_bool
@@ -5663,25 +5756,17 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_calculate_and_store_in:N #1
{
- \bool_if:NF \l_@@_error_bool
- {
- \bool_if:NTF \l_@@_special_sign_bool
- {
- \tl_set_eq:NN \l_@@_tmpa_tl #1
- \msg_warning:nnx { cooking-units } { amount-not-known } \l_@@_tmpa_tl
- }{
- \bool_lazy_and:nnTF
- { \l_@@_using_cutext_bool } { ! \l_@@_cutext_change_unit_bool }
- { \tl_set_eq:NN \l_@@_tmpa_tl #1 }
- { \@@_calculate_input_and_store_in:nN {#1} \l_@@_tmpa_tl }
- \bool_if:NT \l_@@_lokal_persons_bool
- {
- \@@_calc_for_number_of_persons_and_store_in:NN
- \l_@@_tmpa_tl \l_@@_tmpa_tl
- }
- \@@_round_calculated_input:NV \l_@@_tmpa_tl \l_@@_tmpa_tl
- \@@_check_temperature_limit:N \l_@@_tmpa_tl
- }
+ \bool_if:NTF \l_@@_special_sign_bool
+ {
+ \msg_warning:nnV { cooking-units } { amount-not-known } #1
+ }{
+ \bool_lazy_and:nnTF
+ { \l_@@_using_cutext_bool } { \l_@@_cutext_keep_unit_bool }
+ { \tl_set_eq:NN \l_@@_tmpa_tl #1 }
+ { \@@_calculate_input_and_store_in:nN {#1} \l_@@_tmpa_tl }
+ \@@_calc_references:NN \l_@@_tmpa_tl \l_@@_tmpa_tl
+ \@@_round_calculated_input:NV \l_@@_tmpa_tl \l_@@_tmpa_tl
+ \@@_check_temperature_limit:N \l_@@_tmpa_tl
\tl_set_eq:NN #1 \l_@@_tmpa_tl
}
}
@@ -5698,35 +5783,54 @@ and the derived file cooking-units.sty.
\cs_new:Npn \@@_calculate_input_and_store_in:nN #1#2
{
\fp_set:Nn \l_@@_tmpa_fp {#1}
- \tl_if_in:cnTF { l_@@_tmpa_ \l_@@_given_unit_tl _ tl } { \l_@@_tmpa_fp }
+ \tl_if_in:cnTF { l_@@_unit_change_ \l_@@_given_unit_tl _tl } { \l_@@_tmpa_fp }
{
- \@@_tl_eval:Nv #2 { l_@@_tmpa_ \l_@@_given_unit_tl _ tl }
+ \@@_tl_eval:Nv #2 { l_@@_unit_change_ \l_@@_given_unit_tl _tl }
}{
\@@_tl_eval:Nn #2
- { \l_@@_tmpa_fp * \tl_use:c { l_@@_tmpa_ \l_@@_given_unit_tl _ tl } }
+ { \l_@@_tmpa_fp * \tl_use:c { l_@@_unit_change_ \l_@@_given_unit_tl _tl } }
}
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{ \@@_calc_for_number_of_persons_and_store_in:NN }
+% \begin{macro}{ \@@_calc_references:NN,\@@_calc_references_aux:NN }
+% As comparing integers is faster then checking if something is inside
+% the sequence, first (after the boolean) check if there needs to be a calculation
+% at all.
% \begin{macrocode}
-\cs_new:Npn \@@_calc_for_number_of_persons_and_store_in:NN #1#2
+\cs_new:Npn \@@_calc_references:NN #1#2
{
- \int_compare:nNnF
- { \l_@@_wanted_number_of_persons_int }
- =
- { \l_@@_local_number_of_persons_int }
- {
- \@@_tl_eval:Nn #1
+ \bool_if:NT \l_@@_lokal_persons_bool
+ {
+ \int_compare:nNnF
+ { \l_@@_wanted_number_of_persons_int }
+ =
+ { \l_@@_local_number_of_persons_int }
{
- \l_@@_wanted_number_of_persons_int /
- \l_@@_local_number_of_persons_int *
- #2
+ \@@_change_unit:TF
+ { \tl_set_eq:NN \l_@@_tmpb_tl \l_@@_option_unit_tl }
+ { \tl_set_eq:NN \l_@@_tmpb_tl \l_@@_given_unit_tl }
+ \seq_if_in:NVF \l_@@_curef_do_not_change_seq \l_@@_tmpb_tl
+ { \@@_calc_references_aux:NN #1 #2 }
}
}
}
% \end{macrocode}
+% I hope that by putting |#2| to the front of the calculation, it will increase the
+% precision of the calculation (not that it is necessary). I don't really know if this
+% makes sense, but \dots\ eh.
+% \begin{macrocode}
+\cs_new:Npn \@@_calc_references_aux:NN #1#2
+ {
+ \@@_tl_eval:Nn #1
+ {
+ #2 *
+ \l_@@_wanted_number_of_persons_int /
+ \l_@@_local_number_of_persons_int
+ }
+ }
+% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_check_number_for_rounding:n,\@@_check_number_after_dot_aux:ww}
@@ -5775,12 +5879,15 @@ and the derived file cooking-units.sty.
\cs_new:Npn \@@_round_calculated_input:Nn #1#2
{
\@@_check_number_for_rounding:n {#2}
- \tl_set:Nf #1
- {
- \bool_if:NTF \l_@@_round_number_bool
- { \fp_eval:n { round ( \@@_rounding_function:n {#2} ) } }
- {#2}
- }
+ \bool_if:NTF \l_@@_round_number_bool
+ { \@@_tl_eval:Nn #1 { round ( \@@_rounding_function:n {#2} ) } }
+ { \tl_set:Nn #1 {#2} }
+% \tl_set:Nf #1
+% {
+% \bool_if:NTF \l_@@_round_number_bool
+% { \fp_eval:n { round ( \@@_rounding_function:n {#2} ) } }
+% {#2}
+% }
}
\cs_generate_variant:Nn \@@_round_calculated_input:Nn { NV }
% \end{macrocode}
@@ -5882,7 +5989,7 @@ and the derived file cooking-units.sty.
% \end{macro}
%
%
-% \begin{macro}{ \@@_cunum }
+% \begin{macro}{ \@@_cunum:nnnnn }
% \begin{macrocode}
\cs_new:Npn \@@_cunum:nnnnn #1#2#3#4#5
{
@@ -5942,7 +6049,7 @@ and the derived file cooking-units.sty.
% \section { cutext \& Cutext }
%
%
-% A quite primitive implentation of \opt{cutext-to-cunum}, but
+% A better implemantation of \opt{cutext-to-cunum}, but
% sufficient for now.
% \begin{macrocode}
\NewDocumentCommand \cutext { d<> O{} m m }
@@ -5986,8 +6093,8 @@ and the derived file cooking-units.sty.
\bool_set_true:N \l_@@_using_cutext_bool
\@@_set_process_and_print_for_cutext:
\@@_initialise_default:n {#3}
- \bool_if:NTF \l_@@_cutext_change_unit_bool
- { \@@_initialise_unit_change:n {#2} }
+ \@@_initialise_unit_change:n {#2}
+ \bool_if:NT \l_@@_cutext_keep_unit_bool
{ \tl_set_eq:NN \l_@@_option_unit_tl \l_@@_given_unit_tl }
\@@_initialise_after_unit_change:nn {#1} {#2}
\bool_if:NT \l_@@_fourty_two_bool
@@ -6014,6 +6121,8 @@ and the derived file cooking-units.sty.
%
% \begin{macro} {\@@_cutext_print_input:Nn , \@@_cutext_print_input:NV}
% \changes {2016/06/11} {0.99} {New.}
+%
+%
% \begin{macrocode}
\cs_new_protected:Npn \@@_cutext_print_input:Nn #1#2
{
@@ -6021,7 +6130,7 @@ and the derived file cooking-units.sty.
{
\@@_int_if_equal_one:nTF {#1}
{
- \@@_translate_one_to_and_check_existance:Nx \l_@@_translation_tmpa_tl {#2}
+ \@@_translate_one_and_check_existance:Nx \l_@@_translation_tmpa_tl {#2}
\bool_if:NTF \l_@@_cutext_uppercase_word_bool
{
\exp_args:Nx \tl_upper_case:n { \tl_head:V \l_@@_translation_tmpa_tl }
@@ -6092,7 +6201,6 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_cutext_post_process_input_aux:NN #1#2
{
- \@@_bool_set_if_integers:NNN \l_@@_tmpa_bool #1 #2
\bool_if:NTF \l_@@_range_in_input_bool
{ \tl_set_eq:NN \l_@@_cutext_last_value_tl #2 }
{ \tl_set_eq:NN \l_@@_cutext_last_value_tl #1 }
@@ -6101,6 +6209,7 @@ and the derived file cooking-units.sty.
}
\cs_new:Npn \@@_cutext_post_process_input_numerals:NN #1#2
{
+ \@@_bool_set_if_integers:NNN \l_@@_tmpa_bool #1 #2
\bool_if:NTF \l_@@_tmpa_bool
{
\bool_if:NTF \l_@@_range_in_input_bool
@@ -6130,8 +6239,8 @@ and the derived file cooking-units.sty.
%
% \begin{macrocode}
\tl_const:Nn \c_@@_cuam_marker_tl { @@_cunum }
-\tl_new:c { l_@@_tmpa_ \c_@@_cuam_marker_tl _ tl }
-\tl_set:cn { l_@@_tmpa_ \c_@@_cuam_marker_tl _ tl } { 1.0 }
+\tl_new:c { l_@@_unit_change_ \c_@@_cuam_marker_tl _tl }
+\tl_set:cn { l_@@_unit_change_ \c_@@_cuam_marker_tl _tl } { 1.0 }
\clist_new:c { l_@@_predefined_option_ \c_@@_cuam_marker_tl _clist }
% \end{macrocode}
%
@@ -6144,9 +6253,7 @@ and the derived file cooking-units.sty.
{ \cuam }
{
\group_begin:
- \@@_cuam_initialise:nn {#1} {#2}
- \l_@@_cuam_hook_tl
- \@@_cuam:n {#3}
+ \@@_cuam:nnn {#1} {#2} {#3}
\group_end:
}
}
@@ -6154,14 +6261,16 @@ and the derived file cooking-units.sty.
% \end{macro}
%
% \begin{macrocode}
-\cs_new:Npn \@@_cuam:n #1
+\cs_new:Npn \@@_cuam:nnn #1#2#3
{
+ \@@_cuam_initialise:nn {#1} {#2}
+ \l_@@_cuam_hook_tl
\bool_if:NTF \l_@@_cuam_old_bool
- { \@@_cuam_old:n {#1} }
- {
- \@@_parse_input:n {#1}
- \@@_print_correct_unit:
- }
+ { \@@_cuam_old:n {#3} }
+ {
+ \@@_parse_input:n {#3}
+ \@@_print_correct_unit:
+ }
}
% \end{macrocode}
%
@@ -6197,13 +6306,9 @@ and the derived file cooking-units.sty.
\@@_bool_set_if_integers:NNN \l_@@_tmpa_bool #1 #2
\bool_lazy_and:nnT
{ \l_@@_use_phrases_bool } { \l_@@_tmpa_bool }
- {
- \@@_cuam_post_process_input_phrases:NN #1#2
- }
+ { \@@_cuam_post_process_input_phrases:NN #1#2 }
\bool_if:NT \l_@@_lokal_numeral_bool
- {
- \@@_cuam_post_process_input_numerals:NN #1#2
- }
+ { \@@_cuam_post_process_input_numerals:NN #1#2 }
}
% \end{macrocode}
%
@@ -6216,7 +6321,7 @@ and the derived file cooking-units.sty.
{
\@@_get_phrase_for_current_langauge:NNT
\l_@@_phrase_prop
- \l_@@_phrase_numbers_clist
+ \l_@@_phrase_numbers_seq
{
\@@_cuam_post_process_input_phrases_aux:NNN
#1 \l_@@_tmpa_int \l_@@_phrase_number_tl
@@ -6224,18 +6329,17 @@ and the derived file cooking-units.sty.
{
\bool_if:NTF \l_@@_range_in_input_bool
{
- \@@_cuam_post_process_input_phrases_aux:NNN
- #2 \l_@@_tmpb_int \l_@@_tmpb_tl
- \bool_lazy_and:nnF
- { \l_@@_lokal_phrase_bool }
- { \tl_if_eq_p:NN \l_@@_phrase_number_tl \l_@@_tmpb_tl }
- { \bool_set_false:N \l_@@_lokal_phrase_bool }
- \bool_if:NT \l_@@_lokal_phrase_bool
+ \bool_if:NF \l_@@_phrase_negative_bool
{
- \tl_set:NV #1 \l_@@_tmpa_int
- \tl_set:NV #2 \l_@@_tmpb_int
- \@@_cuam_get_phrase_name:NVN
- \l_@@_phrase_phrase_tl \l_@@_phrase_number_tl \l_@@_tmpb_int
+ \@@_cuam_post_process_input_phrases_range:NN
+ #2 \l_@@_tmpb_int
+ \bool_if:NT \l_@@_lokal_phrase_bool
+ {
+ \tl_set:NV #1 \l_@@_tmpa_int
+ \tl_set:NV #2 \l_@@_tmpb_int
+ \@@_cuam_get_phrase_name:NVN
+ \l_@@_phrase_phrase_tl \l_@@_phrase_number_tl \l_@@_tmpb_int
+ }
}
}{
\tl_set:NV #1 \l_@@_tmpa_int
@@ -6250,23 +6354,37 @@ and the derived file cooking-units.sty.
\cs_new:Npn \@@_cuam_post_process_input_phrases_aux:NNN #1#2#3
{
\bool_set_false:N \l_@@_lokal_phrase_bool
- \clist_map_inline:Nn \l_@@_phrase_numbers_clist
+ \seq_map_inline:Nn \l_@@_phrase_numbers_seq
{
\int_compare:nNnF { \int_abs:n {##1} } > {#1}
{
\int_compare:nNnTF {##1} < { 0 }
- { \int_set:Nn \l_tmpa_int { 1 } }
+ {
+ \bool_set_true:N \l_@@_phrase_negative_bool
+ \int_set:Nn \l_tmpa_int { 1 }
+ }
{ \int_set:Nn \l_tmpa_int { \int_div_truncate:nn {#1} {##1} } }
\int_compare:nNnT { \int_abs:n {##1} * \l_tmpa_int } = {#1}
{
\int_set_eq:NN #2 \l_tmpa_int
\tl_set:Nn #3 {##1}
\bool_set_true:N \l_@@_lokal_phrase_bool
- \clist_map_break:
+ \seq_map_break:
}
}
}
}
+\cs_new:Npn \@@_cuam_post_process_input_phrases_range:NN #1#2
+ {
+ \int_set:Nn \l_tmpa_int { \int_div_truncate:nn {#1} { \l_@@_phrase_number_tl } }
+ \int_compare:nNnTF { \l_@@_phrase_number_tl * \l_tmpa_int } = {#1}
+ {
+ \int_set_eq:NN #2 \l_tmpa_int
+ \bool_set_true:N \l_@@_lokal_phrase_bool
+ }{
+ \bool_set_false:N \l_@@_lokal_phrase_bool
+ }
+ }
\cs_new:Npn \@@_cuam_get_phrase_name:NnN #1#2#3
{
\@@_int_if_equal_one:nTF {#3}
@@ -6308,7 +6426,7 @@ and the derived file cooking-units.sty.
% used to decide whetever or not to print numerals. This is due to
% the $1$ being dependent (in some languages) depending on the gender
% of the following word. Currently testing only |\l_@@_lokal_numeral_bool| doesn't
-% work due to the $1$ having a special parsing.
+% work due to the $1$ having a special parsing.
% \begin{macrocode}
\cs_new_protected:Npn \@@_cuam_print_numerical_input:N #1
{
@@ -6318,7 +6436,8 @@ and the derived file cooking-units.sty.
{
\@@_int_if_equal_one:nTF {#1}
{
- \@@_translate_one_to_and_check_existance:Nx \l_@@_translation_tmpa_tl
+ \@@_translate_one_and_check_existance:Nx
+ \l_@@_translation_tmpa_tl
{ \l_@@_phrase_number_tl -phrase-gender }
\l_@@_translation_tmpa_tl
}
@@ -6497,7 +6616,7 @@ and the derived file cooking-units.sty.
\seq_map_inline:Nn \l_@@_tmpa_seq
{
\prop_set_eq:cN { l_@@_cukeys_ ##1 _prop } \l_@@_tmpb_prop
- \tl_set:cn { l_@@_tmpa_ ##1 _tl } { 1.0 }
+ \tl_set:cn { l_@@_unit_change_ ##1 _tl } { 1.0 }
\seq_map_inline:Nn \l_@@_tmpa_seq
{
\prop_put:cnx { l_@@_cukeys_ ##1 _prop }
@@ -6559,7 +6678,7 @@ and the derived file cooking-units.sty.
\prop_get:cVc
{ l_@@_cukeys_#1_prop }
\l_keys_choice_tl
- { l_@@_tmpa_ #1_tl }
+ { l_@@_unit_change_ #1_tl }
\prop_put:NnV \l_@@_change_unit_prop {#1} \l_keys_choice_tl
}
% \end{macrocode}
@@ -6606,7 +6725,7 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_cusinglekeys_create_key_prop:n #1
{
- \tl_set:cn { l_@@_tmpa_ #1 _tl } { 1.0 }
+ \tl_set:cn { l_@@_unit_change_ #1 _tl } { 1.0 }
\prop_set_eq:cN { l_@@_cukeys_ #1 _prop } \l_@@_tmpa_prop
\prop_put:cnn { l_@@_cukeys_ #1 _prop } { Erstes Ding } {#1}
\prop_put:cnV { l_@@_cukeys_ #1 _prop } { Liste } \l_@@_tmpa_seq
@@ -6618,7 +6737,7 @@ and the derived file cooking-units.sty.
\cs_new:Npn \@@_cukeys_define_singlekey:nn #1#2
{
\seq_if_in:NnF \l_@@_list_of_defined_keys_seq {#1}
- { \seq_put_right:Nn \l_@@_list_of_defined_keys_seq {#1} }
+ { \seq_put_right:Nn \l_@@_list_of_defined_keys_seq {#1} }
\keys_define:nn { cooking-units }
{
#1 .choices:Vn =
@@ -6652,9 +6771,7 @@ and the derived file cooking-units.sty.
\NewDocumentCommand \cuaddkeys { m m }
{
\bool_set_false:N \l_@@_single_key_bool
- \tl_set:Nn \l_@@_tmpa_tl {#1}
- \tl_set:Nn \l_@@_tmpb_tl {#2}
- \@@_cukeys_add_keys_or_single_keys:VV \l_@@_tmpa_tl \l_@@_tmpb_tl
+ \@@_cukeys_add_keys_or_single_keys:nn {#1} {#2}
}
% \end{macrocode}
%
@@ -6662,9 +6779,7 @@ and the derived file cooking-units.sty.
\NewDocumentCommand \cuaddsinglekeys { m m }
{
\bool_set_true:N \l_@@_single_key_bool
- \tl_set:Nn \l_@@_tmpa_tl {#1}
- \tl_set:Nn \l_@@_tmpb_tl {#2}
- \@@_cukeys_add_keys_or_single_keys:VV \l_@@_tmpa_tl \l_@@_tmpb_tl
+ \@@_cukeys_add_keys_or_single_keys:nn {#1} {#2}
}
% \end{macrocode}
%
@@ -6672,9 +6787,8 @@ and the derived file cooking-units.sty.
\NewDocumentCommand \cuaddtokeys { m m m }
{
\bool_set_false:N \l_@@_single_key_bool
- \tl_set:Nn \l_@@_tmpa_tl {#1}
\tl_set:Nn \l_@@_tmpb_tl { {#2} { \fp_eval:n { 1.0 / (#3) } } }
- \@@_cukeys_add_keys_or_single_keys:VV \l_@@_tmpa_tl \l_@@_tmpb_tl
+ \@@_cukeys_add_keys_or_single_keys:nV {#1} \l_@@_tmpb_tl
}
% \end{macrocode}
%
@@ -6694,7 +6808,7 @@ and the derived file cooking-units.sty.
{ \@@_cukeys_parse_and_create_keys:nn {#1} {#2} }
}
}
-\cs_generate_variant:Nn \@@_cukeys_add_keys_or_single_keys:nn { VV }
+\cs_generate_variant:Nn \@@_cukeys_add_keys_or_single_keys:nn { nV }
% \end{macrocode}
%
%
@@ -6749,8 +6863,8 @@ and the derived file cooking-units.sty.
{ \msg_error:nnn { cooking-units } { character-not-allowed } {#2} }
}
\seq_put_right:Nn \g_@@_list_of_defined_units_seq {#2}
- \tl_new:c { l_@@_tmpa_ #2 _tl }
- \tl_set:cn { l_@@_tmpa_ #2 _tl } { 1.0 }
+ \tl_new:c { l_@@_unit_change_ #2 _tl }
+ \tl_set:cn { l_@@_unit_change_ #2 _tl } { 1.0 }
\clist_new:c { l_@@_predefined_option_#2_clist }
\keys_define:nn { cooking-units }
{
@@ -6867,7 +6981,7 @@ and the derived file cooking-units.sty.
{
\@@_cuname_parse_unit_symbol:nw {#1}
}{
- \clist_if_in:NnTF \g_@@_allowed_special_keys_clist {#1}
+ \seq_if_in:NnTF \g_@@_allowed_special_keys_seq {#1}
{ \@@_cuname_parse_input_aux:nn {#1} }
{ \@@_cuname_parse_unit_symbol:nw {#1} [ \q_no_value ] }
}
@@ -6903,7 +7017,7 @@ and the derived file cooking-units.sty.
\quark_if_recursion_tail_stop:n {#1}
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
- \clist_if_in:NnF \g_@@_allowed_special_keys_clist {#1}
+ \seq_if_in:NnF \g_@@_allowed_special_keys_seq {#1}
{ \@@_error_if_unit_not_defined:n {#1} }
\@@_deftranslation_to:Vxxn
\l_@@_language_tl {#1}
@@ -6917,7 +7031,7 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\cs_new:Npn \@@_cuname_parse_bracket:nw #1 [#2]
{
- \clist_if_in:NnF \g_@@_allowed_special_keys_clist {#1}
+ \seq_if_in:NnF \g_@@_allowed_special_keys_seq {#1}
{
\@@_deftranslation_to:Vxxn \l_@@_language_tl {#1}
\c_@@_postfix_unitname_pl_tl {#2}
@@ -6959,7 +7073,7 @@ and the derived file cooking-units.sty.
\quark_if_recursion_tail_stop:n {#1}
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
- \clist_if_in:NnTF \g_@@_allowed_special_keys_clist {#1}
+ \seq_if_in:NnTF \g_@@_allowed_special_keys_seq {#1}
{
\@@_deftranslation_to:Vxxn \l_@@_language_tl {#1}
\c_@@_postfix_unitname_tl {#2}
@@ -7013,11 +7127,11 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\@@_phrase_list_get_for:NNTF \l_@@_phrase_prop \l_@@_language_tl
{
- \@@_translate_let:VNxx \l_@@_language_tl \l_@@_phrase_numbers_clist
+ \@@_translate_let:VNxx \l_@@_language_tl \l_@@_phrase_numbers_seq
{ phrase-clist } \c_@@_postfix_phrase_tl
}{
\prop_clear:N \l_@@_phrase_prop
- \clist_clear:N \l_@@_phrase_numbers_clist
+ \seq_clear:N \l_@@_phrase_numbers_seq
}
% \end{macrocode}
% \begin{macrocode}
@@ -7027,7 +7141,7 @@ and the derived file cooking-units.sty.
\q_recursion_tail \q_recursion_tail \q_recursion_stop
% \end{macrocode}
% \begin{macrocode}
- \clist_sort:Nn \l_@@_phrase_numbers_clist
+ \seq_sort:Nn \l_@@_phrase_numbers_seq
{
\int_compare:nNnTF { \int_abs:n {##1} } < { \int_abs:n {##2} }
{ \sort_return_swapped: }
@@ -7048,7 +7162,7 @@ and the derived file cooking-units.sty.
\l_@@_phrase_prop
\@@_deftranslation_to:VxxV
\l_@@_language_tl { phrase-clist }
- \c_@@_postfix_phrase_tl \l_@@_phrase_numbers_clist
+ \c_@@_postfix_phrase_tl \l_@@_phrase_numbers_seq
}
% \end{macrocode}
%
@@ -7076,8 +7190,8 @@ and the derived file cooking-units.sty.
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
\prop_put:Nnn \l_@@_phrase_prop {#1} {#2}
- \clist_if_in:NnF \l_@@_phrase_numbers_clist {#1}
- { \clist_put_right:Nn \l_@@_phrase_numbers_clist {#1} }
+ \seq_if_in:NnF \l_@@_phrase_numbers_seq {#1}
+ { \seq_push:Nn \l_@@_phrase_numbers_seq {#1} }
\peek_meaning_ignore_spaces:NTF [
{
\@@_chuphrase_parse_plural:nw {#1}
@@ -7156,7 +7270,7 @@ and the derived file cooking-units.sty.
{
\@@_int_if_equal_one:nTF {#1}
{
- \@@_translate_one_to_and_check_existance:Nx \l_@@_translation_tmpa_tl {#2}
+ \@@_translate_one_and_check_existance:Nx \l_@@_translation_tmpa_tl {#2}
\bool_if:NTF \l_@@_cutext_uppercase_word_bool
{
\exp_args:Nx \tl_upper_case:n { \tl_head:V \l_@@_translation_tmpa_tl }
diff --git a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
index 7e53a0129f6..e22bc6dd37d 100644
--- a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
+++ b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
@@ -30,10 +30,10 @@
{ \RequirePackage {expl3} }
\ProvidesExplPackage
{cooking-units}
- {2018/04/20}
- {1.30}
+ {2018/06/05}
+ {1.40}
{Ein Paket fuer Kocheinheiten}
-\@ifpackagelater { expl3 } { 2018/02/21 }
+\@ifpackagelater { expl3 } { 2018/06/01 }
{ }
{
\PackageError { cooking-units } { Support~package~expl3~too~old }
@@ -73,8 +73,8 @@
use-numerals .code:n = { \msg_error:nnn { cooking-units } { load-time-option } { fmtcount } } ,
}
\cs_generate_variant:Nn \tl_replace_all:Nnn { NVn }
-\cs_generate_variant:Nn \tl_replace_once:Nnn { NnV, NVn }
-\cs_generate_variant:Nn \tl_if_in:nnTF { nV , xn }
+\cs_generate_variant:Nn \tl_replace_once:Nnn { NVn }
+\cs_generate_variant:Nn \tl_if_in:nnTF { nV }
\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF }
\cs_generate_variant:Nn \tl_if_in:NnT { NVT }
\cs_generate_variant:Nn \fp_compare:nNnT { vNnT }
@@ -82,6 +82,7 @@
\cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV }
\cs_generate_variant:Nn \msg_error:nnnn { nnnV }
\cs_generate_variant:Nn \msg_error:nnn { nnV }
+\cs_generate_variant:Nn \msg_warning:nnn { nnV }
\cs_new:Npn \__cooking_units_dim_horizontal:N #1 { \tex_kern:D #1 }
\cs_new_eq:NN \__cooking_units_frac:nn \sfrac
\cs_new_eq:NN \__cooking_units_set_amount:Nn \tl_set:Nn
@@ -174,8 +175,8 @@
\int_new:N \l__cooking_units_phrase_number_tl
\seq_new:N \l__cooking_units_list_of_defined_keys_seq
\seq_new:N \g__cooking_units_list_of_defined_units_seq
-\clist_new:N \g__cooking_units_allowed_special_keys_clist
-\clist_new:N \l__cooking_units_phrase_numbers_clist
+\seq_new:N \g__cooking_units_allowed_special_keys_seq
+\seq_new:N \l__cooking_units_phrase_numbers_seq
\seq_new:N \l__cooking_units_temperatures_to_check_seq
\seq_new:N \l__cooking_units_curef_do_not_change_seq
\prop_new:N \l__cooking_units_phrase_prop
@@ -198,7 +199,7 @@
\bool_new:N \l__cooking_units_lokal_persons_bool
\bool_new:N \l__cooking_units_cutext_to_cunum_bool
\bool_new:N \l__cooking_units_cutext_old_bool
-\bool_new:N \l__cooking_units_cutext_change_unit_bool
+\bool_new:N \l__cooking_units_cutext_keep_unit_bool
\bool_new:N \l__cooking_units_round_commercial_bool
\bool_new:N \l__cooking_units_use_phrases_bool
\bool_new:N \l__cooking_units_lokal_phrase_bool
@@ -206,18 +207,19 @@
\bool_new:N \l__cooking_units_lokal_numeral_bool
\bool_new:N \l__cooking_units_round_precision_positive_bool
\bool_new:N \l__cooking_units_fourty_two_bool
+\bool_new:N \l__cooking_units_phrase_negative_bool
\bool_new:N \l__cooking_units_range_in_input_bool
\bool_new:N \l__cooking_units_lokal_fraction_bool
\bool_new:N \l__cooking_units_print_fraction_bool
\bool_new:N \l__cooking_units_lokal_mixed_fraction_bool
-\bool_new:N \l__cooking_units_decimal_in_input_bool
-\bool_set_true:N \l__cooking_units_cutext_change_unit_bool
+\bool_new:N \l__cooking_units_check_decimal_bool
+\bool_set_false:N \l__cooking_units_cutext_keep_unit_bool
\bool_set_eq:NN \l__cooking_units_print_numeral_bool \g__cooking_units_opt_numeral_bool
\quark_new:N \q__cooking_units_range
\quark_new:N \q__cooking_units_no_translation
\quark_new:N \q__cooking_units_decimal
-\quark_new:N \q__cooking_units_frac
-\quark_new:N \q__cooking_units_mixed_frac
+\quark_new:N \q__cooking_units_fraction
+\quark_new:N \q__cooking_units_mixed_fraction
\fp_new:N \l__cooking_units_tmpa_fp
\clist_new:N \l__cooking_units_tmpa_clist
\prop_new:N \l__cooking_units_tmpa_prop
@@ -268,8 +270,9 @@
cutext-to-cunum .bool_set:N = \l__cooking_units_cutext_to_cunum_bool ,
cutext-to-cunum .default:n = { false } ,
cutext-to-cunum .groups:n = { change-command } ,
- cutext-change-unit .bool_set:N = \l__cooking_units_cutext_change_unit_bool ,
+ cutext-change-unit .bool_set_inverse:N = \l__cooking_units_cutext_keep_unit_bool ,
cutext-change-unit .default:n = { true } ,
+ cutext-change-unit .groups:n = { change-unit } ,
cuam-version .choices:nn =
{ new , old }
{
@@ -340,7 +343,7 @@
\msg_redirect_name:nnn { cooking-units } { amount-not-known }
{ \l_keys_choice_tl }
} ,
- set-unknown-message .default:n = { set-cutext-translation-message } ,
+ set-unknown-message .default:n = { warning } ,
set-cutext-translation-message .choices:nn =
{ error , warning , none }
{
@@ -404,20 +407,11 @@
recalculate-amount .default:n = { false } ,
set-number-of-persons .int_set:N = \l__cooking_units_wanted_number_of_persons_int ,
set-number-of-persons .default:n = { 4 } ,
- label .code:n =
- {
- \__cooking_units_label_and_persons:n {#1}
- } ,
+ label .code:n = \__cooking_units_label_and_persons:n {#1} ,
label .value_required:n = { true } ,
- get-label .code:n =
- {
- \__cooking_units_curef:n {#1}
- } ,
+ get-label .code:n = \__cooking_units_curef:n {#1} ,
label .value_required:n = { true } ,
- ref .code:n =
- {
- \__cooking_units_reference_label_and_persons:n {#1}
- } ,
+ ref .code:n = \__cooking_units_reference_label_and_persons:n {#1} ,
ref .value_required:n = { true } ,
check-temperature .bool_set:N = \l__cooking_units_check_temperature_bool ,
check-temperature .default:n = { true } ,
@@ -427,7 +421,7 @@
\__cooking_units_temperature_to_check_print_error:n
\__cooking_units_temperatures_to_check_define:nn
{#1}
- },
+ } ,
temperature-to-check .value_required:n = { true } ,
convert-to-eV .bool_set:N = \l__cooking_units_convert_to_eV_bool ,
convert-to-eV .default:n = { true } ,
@@ -457,6 +451,11 @@
cutext-add-hook .code:n = { \tl_put_right:Nn \l__cooking_units_cutext_hook_tl {#1} } ,
Cutext-add-hook .code:n = { \tl_put_right:Nn \l__cooking_units_Cutext_hook_tl {#1} } ,
cuam-add-hook .code:n = { \tl_put_right:Nn \l__cooking_units_cuam_hook_tl {#1} } ,
+ curef-do-not-change .code:n =
+ {
+ \seq_if_in:NnF \l__cooking_units_curef_do_not_change_seq {#1}
+ {\seq_put_right:Nn \l__cooking_units_curef_do_not_change_seq {#1} }
+ } ,
}
\msg_new:nnnn { cooking-units } { fraction-not-allowed-with-range }
{
@@ -584,7 +583,7 @@
}
\msg_new:nnnn { cooking-units } { amount-not-known }
{
- The \ amount \ of \ #1 \ is \ not \ known \ at \ line \
+ The \ amount \ '#1' \ is \ not \ known \ at \ line \
\msg_line_number: .
}
{
@@ -670,7 +669,7 @@
}
\msg_new:nnnn { cooking-units } { label-not-defined }
{
- The \ label \ is \ not \ defined. \ Please \ note \ that \ a \ label
+ The \ label \ '#1' \ is \ not \ defined. \ Please \ note \ that \ a \ label
\ has \ to \ defined \ before \ it \ is \ referenced.
}{
Define \ the \ label \ before \ using \ it.
@@ -798,26 +797,26 @@
}
\cs_new:Npn \__cooking_units_define_unit_group:nn #1#2
{
- \clist_new:c { l__cooking_units_group_ #1 _clist }
- \clist_set:cn { l__cooking_units_group_ #1 _clist } {#2}
+ \seq_new:c { l__cooking_units_group_ #1 _seq }
+ \seq_set_from_clist:cn { l__cooking_units_group_ #1 _seq } {#2}
\keys_define:nn { cooking-units }
{
#1 .code:n = { \__cooking_units_unit_group_convert_units:nn {#1} {##1} } ,
- #1 .groups:n = { change-unit }
+ #1 .groups:n = { change-unit } ,
}
}
\cs_new:Npn \__cooking_units_error_if_group_not_defined:n #1
{
- \clist_if_exist:cF { l__cooking_units_group_ #1 _clist }
+ \seq_if_exist:cF { l__cooking_units_group_ #1 _seq }
{ \msg_error:nn { cooking-units} { group-key-unknown } }
}
\cs_new:Npn \__cooking_units_unit_group_convert_units:nn #1#2
{
\__cooking_units_error_if_group_not_defined:n {#1}
\__cooking_units_error_if_unit_not_defined:n {#2}
- \clist_if_in:cnTF { l__cooking_units_group_ #1 _clist } {#2}
+ \seq_if_in:cnTF { l__cooking_units_group_ #1 _seq } {#2}
{
- \clist_map_inline:cn { l__cooking_units_group_ #1 _clist }
+ \seq_map_inline:cn { l__cooking_units_group_ #1 _seq }
{ \__cooking_units_keys_set:nnn { cooking-units } {##1} {#2} }
}{
\msg_error:nnxxx
@@ -825,7 +824,7 @@
{ group-choice-not-allowed }
{#1}
{#2}
- { \clist_use:cnnn { l__cooking_units_group_ #1 _clist } { ',~ ' } { ',~ ' } { ' ~ and ~ ' } }
+ { \seq_use:cnnn { l__cooking_units_group_ #1 _seq } { ',~ ' } { ',~ ' } { ' ~ and ~ ' } }
}
}
\__cooking_units_define_unit_group:nn { weight } { kg , dag, g, oz, lb, stick }
@@ -844,13 +843,13 @@
\clist_map_inline:nn {#2}
{
\__cooking_units_error_if_unit_not_defined:n {##1}
- \clist_if_in:cnF { l__cooking_units_group_ #1 _clist } {##1}
- { \clist_put_right:cn { l__cooking_units_group_ #1 _clist } {##1} }
+ \seq_if_in:cnF { l__cooking_units_group_ #1 _seq } {##1}
+ { \seq_put_right:cn { l__cooking_units_group_ #1 _seq } {##1} }
}
}
\seq_new:N \g__cooking_units_natural_units_seq
\prop_new:N \g__cooking_units_convert_to_eV_remember_prop
-\seq_set_split:Nnn \g__cooking_units_natural_units_seq { , }
+\seq_set_from_clist:Nn \g__cooking_units_natural_units_seq
{
eV ,
eVc-2 ,
@@ -1060,7 +1059,7 @@
{
\SaveTranslationFor {#2} {#1} { #3 #4 }
}
-\cs_generate_variant:Nn \__cooking_units_translate:nn { xx }
+\cs_generate_variant:Nn \__cooking_units_translate:nn { xx , VV }
\cs_generate_variant:Nn \__cooking_units_translate_let:Nnn { Nxx }
\cs_generate_variant:Nn \__cooking_units_translate_let:nNnn { VNxx, nNxx }
\prg_new_conditional:Npnn \__cooking_units_unitname_get:Nn #1#2 { F }
@@ -1071,7 +1070,7 @@
{ \prg_return_true: }
}
\cs_generate_variant:Nn \__cooking_units_unitname_get:NnF { Nx }
-\cs_new:Npn \__cooking_units_translate_one_to_and_check_existance:Nx #1#2
+\cs_new:Npn \__cooking_units_translate_one_and_check_existance:Nn #1#2
{
\__cooking_units_translate_let:Nxx #1 {#2} \c__cooking_units_postfix_gender_tl
\__cooking_units_unitname_get:NxF #1 { one (#1) }
@@ -1080,7 +1079,8 @@
\msg_error:nnn { cooking-units } { Translation-not-available } { one (#1) }
}
}
-\clist_gset:Nn \g__cooking_units_allowed_special_keys_clist
+\cs_generate_variant:Nn \__cooking_units_translate_one_and_check_existance:Nn { Nx }
+\seq_gset_from_clist:Nn \g__cooking_units_allowed_special_keys_seq
{
decimal-mark ,
one (m) ,
@@ -1102,6 +1102,10 @@
\__cooking_units_newtranslation_to:nnVn { German } { one (m) } \c__cooking_units_postfix_unitname_tl { ein }
\__cooking_units_newtranslation_to:nnVn { German } { one (f) } \c__cooking_units_postfix_unitname_tl { eine }
\__cooking_units_newtranslation_to:nnVn { German } { one (n) } \c__cooking_units_postfix_unitname_tl { ein }
+\__cooking_units_newtranslation_base:nVn { range-sign } \c__cooking_units_postfix_unitname_tl { -- }
+\__cooking_units_newtranslation_base:nVn { range-sign } \c__cooking_units_postfix_unitname_pl_tl { \q__cooking_units_no_translation }
+\__cooking_units_newtranslation_to:nnVn { German } { range-sign } \c__cooking_units_postfix_unitname_tl { ~bis~ }
+\__cooking_units_newtranslation_to:nnVn { English } { range-sign } \c__cooking_units_postfix_unitname_tl { ~to~ }
\cs_new_protected:Npn \__cooking_units_initialise_default:n #1
{
\__cooking_units_set_unit:Nn \l__cooking_units_given_unit_tl {#1}
@@ -1115,14 +1119,11 @@
\cs_new_protected:Npn \__cooking_units_initialise_unit_change:n #1
{
\tl_if_empty:nF {#1}
- {
- \keys_set_groups:nnn { cooking-units } { change-unit } {#1}
- }
- \bool_if:NT \l__cooking_units_convert_to_eV_bool { \__cooking_units_convert_to_eV: }
+ { \keys_set_groups:nnn { cooking-units } { change-unit } {#1} }
+ \bool_if:NT \l__cooking_units_convert_to_eV_bool
+ { \__cooking_units_convert_to_eV: }
\prop_get:NVNF \l__cooking_units_change_unit_prop \l__cooking_units_given_unit_tl \l__cooking_units_option_unit_tl
- {
- \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_given_unit_tl
- }
+ { \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_given_unit_tl }
}
\cs_new_protected:Npn \__cooking_units_initialise_after_unit_change:nn #1#2
{
@@ -1193,12 +1194,39 @@
}
\__cooking_units_frac:nn {#2} {#3}
}
+\cs_new:Npn \__cooking_units_print_ranges:NN #1#2
+ {
+ \__cooking_units_print_input:N #1
+ \bool_if:NTF \l__cooking_units_using_cutext_bool
+ {
+ \tl_use:N \l__cooking_units_cutext_range_sign_tl
+ \bool_set_false:N \l__cooking_units_cutext_uppercase_word_bool
+ }
+ { \tl_use:N \l__cooking_units_cunum_range_sign_tl }
+ \__cooking_units_print_input:N #2
+ }
+\cs_new:Npn \__cooking_units_create_error:n #1
+ {
+ \bool_set_true:N \l__cooking_units_error_bool
+ \msg_error:nnV { cooking-units } {#1} \l__cooking_units_given_amount_tl
+ }
+\cs_new:Npn \__cooking_units_create_error_and_stop:n #1
+ {
+ \bool_set_true:N \l__cooking_units_error_bool
+ \msg_error:nnV { cooking-units } {#1} \l__cooking_units_given_amount_tl
+ \use_none_delimit_by_q_nil:w
+ }
+\cs_new:Npn \__cooking_units_create_error:nn #1#2
+ {
+ \bool_set_true:N \l__cooking_units_error_bool
+ \msg_error:nnnV { cooking-units } {#1} {#2} \l__cooking_units_given_amount_tl
+ }
\cs_new:Npn \__cooking_units_parse_input:n #1
{
\bool_if:NTF \l__cooking_units_fourty_two_bool
{ \tl_clear:N \l__cooking_units_given_amount_tl }
{ \__cooking_units_set_amount:Nn \l__cooking_units_given_amount_tl {#1} }
- \tl_set_rescan:NnV \l__cooking_units_tmpa_tl
+ \tl_set_rescan:NnV \l__cooking_units_given_amount_tl
{
\char_set_catcode_letter:N \_ %
\char_set_catcode_ignore:N \ %
@@ -1206,55 +1234,116 @@
} \l__cooking_units_given_amount_tl
\bool_lazy_or:nnTF
{ \l__cooking_units_draft_bool }
- { \tl_if_empty_p:N \l__cooking_units_tmpa_tl }
+ { \tl_if_empty_p:N \l__cooking_units_given_amount_tl }
{
\bool_if:NTF \l__cooking_units_fourty_two_bool
{ 42 }
- { \l__cooking_units_tmpa_tl }
+ { \l__cooking_units_given_amount_tl }
}{
- \tl_if_in:NVT \l__cooking_units_tmpa_tl \l__cooking_units_input_range_sign_tl
- {
- \tl_replace_once:NVn \l__cooking_units_tmpa_tl \l__cooking_units_input_range_sign_tl { \q__cooking_units_range }
- \bool_set_true:N \l__cooking_units_range_in_input_bool
- }
- \__cooking_units_parsing_amount_input:V \l__cooking_units_tmpa_tl
- \__cooking_units_split_input:
+ \tl_set_eq:NN \l__cooking_units_tmpa_tl \l__cooking_units_given_amount_tl
+ \__cooking_units_split_input:N \l__cooking_units_tmpa_tl
+ \__cooking_units_process_and_print_input:
}
}
-\cs_new:Npn \__cooking_units_parsing_amount_input:n #1
+\cs_new:Npn \__cooking_units_split_input:N #1
{
- \cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_start_loop:N
- \tl_map_function:nN {#1} \__cooking_units_parse:N
+ \tl_if_in:NVT #1 \l__cooking_units_input_range_sign_tl
+ {
+ \tl_replace_once:NVn #1 \l__cooking_units_input_range_sign_tl { \q__cooking_units_range }
+ \bool_set_true:N \l__cooking_units_range_in_input_bool
+ }
+ \tl_if_in:NnT #1 { / }
+ {
+ \bool_set_true:N \l__cooking_units_lokal_fraction_bool
+ \bool_if:NT \l__cooking_units_range_in_input_bool
+ { \__cooking_units_create_error_and_stop:n { fraction-not-allowed-with-range } }
+ }
+ \tl_if_in:NnT #1 { _ }
+ {
+ \bool_set_true:N \l__cooking_units_lokal_mixed_fraction_bool
+ \bool_if:NF \l__cooking_units_lokal_fraction_bool
+ { \__cooking_units_create_error_and_stop:n { missing-slash } }
+ }
+ \__cooking_units_split:N #1
+ \use_none_delimit_by_q_nil:w \q_nil
+ }
+\cs_new:Npn \__cooking_units_process_tmp: { }
+\cs_new:Npn \__cooking_units_process_and_print_input:
+ {
+ \bool_if:NTF \l__cooking_units_error_bool
+ { \l__cooking_units_given_amount_tl }
+ { \__cooking_units_process_tmp: }
}
-\cs_generate_variant:Nn \__cooking_units_parsing_amount_input:n { V }
-\cs_new:Npn \__cooking_units_split_input:
+\cs_new:Npn \__cooking_units_split:N #1
{
\bool_if:NTF \l__cooking_units_lokal_fraction_bool
+ { \__cooking_units_split_fraction:V }
{
- \tl_set_eq:NN \l__cooking_units_number_tmpb_tl \l__cooking_units_tmpa_tl
- \bool_lazy_or:nnT
- { \l__cooking_units_lokal_persons_bool }{ \l__cooking_units_eval_fractions_bool }
- { \bool_set_false:N \l__cooking_units_lokal_fraction_bool }
- \bool_if:NTF \l__cooking_units_lokal_mixed_fraction_bool
- { \__cooking_units_parse_mixed_fraction_in_input: }
- { \__cooking_units_parse_fraction_in_input: }
- }{
- \bool_if:NT \l__cooking_units_lokal_mixed_fraction_bool
- { \msg_error:nnV { cooking-units } { missing-slash } \l__cooking_units_given_amount_tl }
\bool_if:NTF \l__cooking_units_range_in_input_bool
- {
- \tl_set_eq:NN \l__cooking_units_number_tmpb_tl \l__cooking_units_tmpa_tl
- \__cooking_units_parse_range_in_input:
- }{
- \tl_set_eq:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_tmpa_tl
- \__cooking_units_parse_number_in_input:
- }
+ { \__cooking_units_split_range:V }
+ { \__cooking_units_split_number:V }
}
+ #1
}
-\cs_new:Npn \__cooking_units_start_loop:N #1
+\cs_new:Npn \__cooking_units_split_number:n #1
+ {
+ \cs_set_eq:NN \__cooking_units_process_tmp: \__cooking_units_process_number_in_input:
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_number_tmpa_tl
+ }
+\cs_new:Npn \__cooking_units_split_range:n #1
+ {
+ \cs_set_eq:NN \__cooking_units_process_tmp: \__cooking_units_process_range_in_input:
+ \__cooking_units_split_range_aux:ww #1 \q_stop
+ }
+\cs_new:Npn \__cooking_units_split_range_aux:ww #1 \q__cooking_units_range #2 \q_stop
+ {
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_number_tmpa_tl
+ \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_number_tmpb_tl
+ }
+\cs_new:Npn \__cooking_units_split_fraction:n #1
+ {
+ \bool_if:NTF \l__cooking_units_lokal_mixed_fraction_bool
+ {
+ \cs_set_eq:NN \__cooking_units_process_tmp: \__cooking_units_process_mixed_fraction_in_input:
+ \__cooking_units_split_fraction_mixed:ww
+ }{
+ \cs_set_eq:NN \__cooking_units_process_tmp: \__cooking_units_process_fraction_in_input:
+ \__cooking_units_split_fraction_frac:ww
+ }
+ #1 \q_stop / \q_recursion_tail \q_stop
+ \q_recursion_stop
+ \bool_lazy_or:nnT
+ { \l__cooking_units_lokal_persons_bool }{ \l__cooking_units_eval_fractions_bool }
+ { \bool_set_false:N \l__cooking_units_lokal_fraction_bool }
+ }
+\cs_new:Npn \__cooking_units_split_fraction_frac:ww #1 / #2 \q_stop
+ {
+ \quark_if_recursion_tail_stop_do:nn {#2}
+ { \__cooking_units_create_error:n { fraction-wrong-order } }
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_number_tmpa_tl
+ \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_number_tmpb_tl
+ \use_none_delimit_by_q_recursion_stop:w
+ }
+\cs_new:Npn \__cooking_units_split_fraction_mixed:ww #1 _ #2 \q_stop
+ {
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_mixed_fraction_tl
+ \__cooking_units_split_fraction_frac:ww #2 \q_stop
+ }
+\cs_generate_variant:Nn \__cooking_units_split_number:n { V }
+\cs_generate_variant:Nn \__cooking_units_split_range:n { V }
+\cs_generate_variant:Nn \__cooking_units_split_fraction:n { V }
+\cs_new:Npn \__cooking_units_parse_input_and_safe_in:nN #1 #2
{
\tl_clear:N \l__cooking_units_tmpa_tl
- \bool_set_false:N \l__cooking_units_decimal_in_input_bool
+ \bool_set_false:N \l__cooking_units_check_decimal_bool
+ \cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_start_loop:N
+ \tl_map_function:nN {#1} \__cooking_units_parse:N
+ \bool_if:NTF \l__cooking_units_error_bool
+ { \use_none_delimit_by_q_nil:w }
+ { \tl_set_eq:NN #2 \l__cooking_units_tmpa_tl }
+ }
+\cs_new:Npn \__cooking_units_start_loop:N #1
+ {
\cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_parse_input_loop_aux:N
\tl_if_in:NnTF \l__cooking_units_input_value_signs_tl {#1}
{ \tl_put_right:Nn \l__cooking_units_tmpa_tl {#1} }
@@ -1269,9 +1358,7 @@
{
\tl_if_in:NnTF \l__cooking_units_input_decimal_mark_tl {#1}
{
- \__cooking_units_check_repitition:NN
- \q__cooking_units_decimal
- \l__cooking_units_decimal_in_input_bool
+ \__cooking_units_check_repitition:N \l__cooking_units_check_decimal_bool
\tl_put_right:Nn \l__cooking_units_tmpa_tl { . }
}{
\tl_if_in:NnTF \l__cooking_units_input_allowed_special_signs_tl {#1}
@@ -1279,71 +1366,29 @@
\bool_set_true:N \l__cooking_units_special_sign_bool
\tl_put_right:Nn \l__cooking_units_tmpa_tl {#1}
}{
- \bool_if:NTF \l__cooking_units_range_in_input_bool
- {
- \tl_if_eq:nnTF \q__cooking_units_range {#1}
- {
- \tl_set_eq:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_tmpa_tl
- \cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_start_loop:N
- }{
- \tl_if_in:xnTF
- {
- \exp_not:V \l__cooking_units_input_fraction_sign_tl
- \exp_not:V \l__cooking_units_input_mixed_fraction_sign_tl
- } {#1}
- { \msg_error:nnV { cooking-units } { fraction-not-allowed-with-range } \l__cooking_units_given_amount_tl }
- { \msg_error:nnnV { cooking-units } { Token-not-allowed } {#1} \l__cooking_units_given_amount_tl }
- \bool_set_true:N \l__cooking_units_error_bool
- \tl_map_break:
- }
- }{
- \tl_if_in:NnTF \l__cooking_units_input_fraction_sign_tl {#1}
- {
- \__cooking_units_check_repitition:NN
- \q__cooking_units_frac
- \l__cooking_units_lokal_fraction_bool
- \tl_set_eq:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_tmpa_tl
- \cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_start_loop:N
- }{
- \tl_if_in:NnTF \l__cooking_units_input_mixed_fraction_sign_tl {#1}
- {
- \__cooking_units_check_repitition:NN
- \q__cooking_units_mixed_frac
- \l__cooking_units_lokal_mixed_fraction_bool
- \bool_if:NT \l__cooking_units_lokal_fraction_bool
- { \msg_error:nnV { cooking-units } { fraction-wrong-order } \l__cooking_units_given_amount_tl }
- \tl_set_eq:NN \l__cooking_units_mixed_fraction_tl \l__cooking_units_tmpa_tl
- \cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_start_loop:N
- }{
- \msg_error:nnnV { cooking-units } { Token-not-allowed } {#1} \l__cooking_units_given_amount_tl
- \bool_set_true:N \l__cooking_units_error_bool
- \tl_map_break:
- }
- }
- }
+ \bool_set_true:N \l__cooking_units_error_bool
+ \__cooking_units_check_error:n {#1}
}
}
}
}
-\cs_new:Npn \__cooking_units_check_repitition:NN #1#2
+\cs_new:Npn \__cooking_units_check_error:n #1
{
- \bool_if:NTF #2
+ \tl_if_in:NnTF \l__cooking_units_input_fraction_sign_tl {#1}
+ { \__cooking_units_create_error:n { Second-fraction-sign-not-allowed } }
{
- \tl_case:NnTF #1
- {
- \q__cooking_units_decimal
- { \msg_error:nnV { cooking-units } { Second-decimal-sign-not-allowed } \l__cooking_units_given_amount_tl }
- \q__cooking_units_frac
- { \msg_error:nnV { cooking-units } { Second-fraction-sign-not-allowed } \l__cooking_units_given_amount_tl }
- \q__cooking_units_mixed_frac
- { \msg_error:nnV { cooking-units } { Second-mixed-fraction-sign-not-allowed } \l__cooking_units_given_amount_tl }
- }
- { \bool_set_true:N \l__cooking_units_error_bool }
- { \msg_error:nn { cooking-units } { internal-error } }
+ \tl_if_in:NnTF \l__cooking_units_input_mixed_fraction_sign_tl {#1}
+ { \__cooking_units_create_error:n { Second-mixed-fraction-sign-not-allowed } }
+ { \__cooking_units_create_error:nn { Token-not-allowed } {#1} }
}
- { \bool_set_true:N #2 }
}
-\cs_new:Npn \__cooking_units_parse_number_in_input:
+\cs_new:Npn \__cooking_units_check_repitition:N #1
+ {
+ \bool_if:NTF #1
+ { \__cooking_units_create_error:n { Second-decimal-sign-not-allowed } }
+ { \bool_set_true:N #1 }
+ }
+\cs_new:Npn \__cooking_units_process_number_in_input:
{
\__cooking_units_process_and_print_number_in_input:N \l__cooking_units_number_tmpa_tl
}
@@ -1354,19 +1399,15 @@
\__cooking_units_post_process_input:NN #1 \q_no_value
\__cooking_units_print_input:N #1
}
-\cs_new:Npn \__cooking_units_parse_range_in_input:
+\cs_new:Npn \__cooking_units_process_range_in_input:
{
\__cooking_units_pre_process_input:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_number_tmpb_tl
\__cooking_units_calculate_and_store_in:N \l__cooking_units_number_tmpa_tl
\__cooking_units_calculate_and_store_in:N \l__cooking_units_number_tmpb_tl
\__cooking_units_post_process_input:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_number_tmpb_tl
- \__cooking_units_print_input:N \l__cooking_units_number_tmpa_tl
- \bool_if:NTF \l__cooking_units_using_cutext_bool
- { \tl_use:N \l__cooking_units_cutext_range_sign_tl }
- { \tl_use:N \l__cooking_units_cunum_range_sign_tl }
- \__cooking_units_print_input:N \l__cooking_units_number_tmpb_tl
+ \__cooking_units_print_ranges:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_number_tmpb_tl
}
-\cs_new:Npn \__cooking_units_parse_fraction_in_input:
+\cs_new:Npn \__cooking_units_process_fraction_in_input:
{
\bool_lazy_or:nnTF
{ \l__cooking_units_lokal_fraction_bool }
@@ -1386,7 +1427,7 @@
\__cooking_units_process_and_print_number_in_input:N \l__cooking_units_number_tmpa_tl
}
}
-\cs_new:Npn \__cooking_units_parse_mixed_fraction_in_input:
+\cs_new:Npn \__cooking_units_process_mixed_fraction_in_input:
{
\__cooking_units_tl_if_in_remove_and_set_bool:NnN \l__cooking_units_mixed_fraction_tl { - } \l__cooking_units_minus_bool
\__cooking_units_tl_if_in_remove_and_reverse_bool:NnN \l__cooking_units_number_tmpa_tl { - } \l__cooking_units_minus_bool
@@ -1414,54 +1455,57 @@
}
\cs_new:Npn \__cooking_units_calculate_and_store_in:N #1
{
- \bool_if:NF \l__cooking_units_error_bool
+ \bool_if:NTF \l__cooking_units_special_sign_bool
{
- \bool_if:NTF \l__cooking_units_special_sign_bool
- {
- \tl_set_eq:NN \l__cooking_units_tmpa_tl #1
- \msg_warning:nnx { cooking-units } { amount-not-known } \l__cooking_units_tmpa_tl
- }{
- \bool_lazy_and:nnTF
- { \l__cooking_units_using_cutext_bool } { ! \l__cooking_units_cutext_change_unit_bool }
- { \tl_set_eq:NN \l__cooking_units_tmpa_tl #1 }
- { \__cooking_units_calculate_input_and_store_in:nN {#1} \l__cooking_units_tmpa_tl }
- \bool_if:NT \l__cooking_units_lokal_persons_bool
- {
- \__cooking_units_calc_for_number_of_persons_and_store_in:NN
- \l__cooking_units_tmpa_tl \l__cooking_units_tmpa_tl
- }
- \__cooking_units_round_calculated_input:NV \l__cooking_units_tmpa_tl \l__cooking_units_tmpa_tl
- \__cooking_units_check_temperature_limit:N \l__cooking_units_tmpa_tl
- }
+ \msg_warning:nnV { cooking-units } { amount-not-known } #1
+ }{
+ \bool_lazy_and:nnTF
+ { \l__cooking_units_using_cutext_bool } { \l__cooking_units_cutext_keep_unit_bool }
+ { \tl_set_eq:NN \l__cooking_units_tmpa_tl #1 }
+ { \__cooking_units_calculate_input_and_store_in:nN {#1} \l__cooking_units_tmpa_tl }
+ \__cooking_units_calc_references:NN \l__cooking_units_tmpa_tl \l__cooking_units_tmpa_tl
+ \__cooking_units_round_calculated_input:NV \l__cooking_units_tmpa_tl \l__cooking_units_tmpa_tl
+ \__cooking_units_check_temperature_limit:N \l__cooking_units_tmpa_tl
\tl_set_eq:NN #1 \l__cooking_units_tmpa_tl
}
}
\cs_new:Npn \__cooking_units_calculate_input_and_store_in:nN #1#2
{
\fp_set:Nn \l__cooking_units_tmpa_fp {#1}
- \tl_if_in:cnTF { l__cooking_units_tmpa_ \l__cooking_units_given_unit_tl _ tl } { \l__cooking_units_tmpa_fp }
+ \tl_if_in:cnTF { l__cooking_units_unit_change_ \l__cooking_units_given_unit_tl _tl } { \l__cooking_units_tmpa_fp }
{
- \__cooking_units_tl_eval:Nv #2 { l__cooking_units_tmpa_ \l__cooking_units_given_unit_tl _ tl }
+ \__cooking_units_tl_eval:Nv #2 { l__cooking_units_unit_change_ \l__cooking_units_given_unit_tl _tl }
}{
\__cooking_units_tl_eval:Nn #2
- { \l__cooking_units_tmpa_fp * \tl_use:c { l__cooking_units_tmpa_ \l__cooking_units_given_unit_tl _ tl } }
+ { \l__cooking_units_tmpa_fp * \tl_use:c { l__cooking_units_unit_change_ \l__cooking_units_given_unit_tl _tl } }
}
}
-\cs_new:Npn \__cooking_units_calc_for_number_of_persons_and_store_in:NN #1#2
+\cs_new:Npn \__cooking_units_calc_references:NN #1#2
{
- \int_compare:nNnF
- { \l__cooking_units_wanted_number_of_persons_int }
- =
- { \l__cooking_units_local_number_of_persons_int }
+ \bool_if:NT \l__cooking_units_lokal_persons_bool
{
- \__cooking_units_tl_eval:Nn #1
+ \int_compare:nNnF
+ { \l__cooking_units_wanted_number_of_persons_int }
+ =
+ { \l__cooking_units_local_number_of_persons_int }
{
- \l__cooking_units_wanted_number_of_persons_int /
- \l__cooking_units_local_number_of_persons_int *
- #2
+ \__cooking_units_change_unit:TF
+ { \tl_set_eq:NN \l__cooking_units_tmpb_tl \l__cooking_units_option_unit_tl }
+ { \tl_set_eq:NN \l__cooking_units_tmpb_tl \l__cooking_units_given_unit_tl }
+ \seq_if_in:NVF \l__cooking_units_curef_do_not_change_seq \l__cooking_units_tmpb_tl
+ { \__cooking_units_calc_references_aux:NN #1 #2 }
}
}
}
+\cs_new:Npn \__cooking_units_calc_references_aux:NN #1#2
+ {
+ \__cooking_units_tl_eval:Nn #1
+ {
+ #2 *
+ \l__cooking_units_wanted_number_of_persons_int /
+ \l__cooking_units_local_number_of_persons_int
+ }
+ }
\cs_new:Npn \__cooking_units_check_number_for_rounding:n #1
{
\bool_set_false:N \l__cooking_units_round_number_bool
@@ -1490,12 +1534,9 @@
\cs_new:Npn \__cooking_units_round_calculated_input:Nn #1#2
{
\__cooking_units_check_number_for_rounding:n {#2}
- \tl_set:Nf #1
- {
- \bool_if:NTF \l__cooking_units_round_number_bool
- { \fp_eval:n { round ( \__cooking_units_rounding_function:n {#2} ) } }
- {#2}
- }
+ \bool_if:NTF \l__cooking_units_round_number_bool
+ { \__cooking_units_tl_eval:Nn #1 { round ( \__cooking_units_rounding_function:n {#2} ) } }
+ { \tl_set:Nn #1 {#2} }
}
\cs_generate_variant:Nn \__cooking_units_round_calculated_input:Nn { NV }
\cs_new:Npn \__cooking_units_check_temperature_limit:N #1
@@ -1610,8 +1651,8 @@
\bool_set_true:N \l__cooking_units_using_cutext_bool
\__cooking_units_set_process_and_print_for_cutext:
\__cooking_units_initialise_default:n {#3}
- \bool_if:NTF \l__cooking_units_cutext_change_unit_bool
- { \__cooking_units_initialise_unit_change:n {#2} }
+ \__cooking_units_initialise_unit_change:n {#2}
+ \bool_if:NT \l__cooking_units_cutext_keep_unit_bool
{ \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_given_unit_tl }
\__cooking_units_initialise_after_unit_change:nn {#1} {#2}
\bool_if:NT \l__cooking_units_fourty_two_bool
@@ -1634,7 +1675,7 @@
{
\__cooking_units_int_if_equal_one:nTF {#1}
{
- \__cooking_units_translate_one_to_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl {#2}
+ \__cooking_units_translate_one_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl {#2}
\bool_if:NTF \l__cooking_units_cutext_uppercase_word_bool
{
\exp_args:Nx \tl_upper_case:n { \tl_head:V \l__cooking_units_translation_tmpa_tl }
@@ -1691,7 +1732,6 @@
}
\cs_new:Npn \__cooking_units_cutext_post_process_input_aux:NN #1#2
{
- \__cooking_units_bool_set_if_integers:NNN \l__cooking_units_tmpa_bool #1 #2
\bool_if:NTF \l__cooking_units_range_in_input_bool
{ \tl_set_eq:NN \l__cooking_units_cutext_last_value_tl #2 }
{ \tl_set_eq:NN \l__cooking_units_cutext_last_value_tl #1 }
@@ -1700,6 +1740,7 @@
}
\cs_new:Npn \__cooking_units_cutext_post_process_input_numerals:NN #1#2
{
+ \__cooking_units_bool_set_if_integers:NNN \l__cooking_units_tmpa_bool #1 #2
\bool_if:NTF \l__cooking_units_tmpa_bool
{
\bool_if:NTF \l__cooking_units_range_in_input_bool
@@ -1716,8 +1757,8 @@
{ \bool_set_false:N \l__cooking_units_lokal_numeral_bool }
}
\tl_const:Nn \c__cooking_units_cuam_marker_tl { __cooking_units_cunum }
-\tl_new:c { l__cooking_units_tmpa_ \c__cooking_units_cuam_marker_tl _ tl }
-\tl_set:cn { l__cooking_units_tmpa_ \c__cooking_units_cuam_marker_tl _ tl } { 1.0 }
+\tl_new:c { l__cooking_units_unit_change_ \c__cooking_units_cuam_marker_tl _tl }
+\tl_set:cn { l__cooking_units_unit_change_ \c__cooking_units_cuam_marker_tl _tl } { 1.0 }
\clist_new:c { l__cooking_units_predefined_option_ \c__cooking_units_cuam_marker_tl _clist }
\NewDocumentCommand \cuam { d<> O{} m }
{
@@ -1725,20 +1766,20 @@
{ \cuam }
{
\group_begin:
- \__cooking_units_cuam_initialise:nn {#1} {#2}
- \l__cooking_units_cuam_hook_tl
- \__cooking_units_cuam:n {#3}
+ \__cooking_units_cuam:nnn {#1} {#2} {#3}
\group_end:
}
}
-\cs_new:Npn \__cooking_units_cuam:n #1
+\cs_new:Npn \__cooking_units_cuam:nnn #1#2#3
{
+ \__cooking_units_cuam_initialise:nn {#1} {#2}
+ \l__cooking_units_cuam_hook_tl
\bool_if:NTF \l__cooking_units_cuam_old_bool
- { \__cooking_units_cuam_old:n {#1} }
- {
- \__cooking_units_parse_input:n {#1}
- \__cooking_units_print_correct_unit:
- }
+ { \__cooking_units_cuam_old:n {#3} }
+ {
+ \__cooking_units_parse_input:n {#3}
+ \__cooking_units_print_correct_unit:
+ }
}
\cs_new_protected:Npn \__cooking_units_cuam_initialise:nn #1#2
{
@@ -1758,19 +1799,15 @@
\__cooking_units_bool_set_if_integers:NNN \l__cooking_units_tmpa_bool #1 #2
\bool_lazy_and:nnT
{ \l__cooking_units_use_phrases_bool } { \l__cooking_units_tmpa_bool }
- {
- \__cooking_units_cuam_post_process_input_phrases:NN #1#2
- }
+ { \__cooking_units_cuam_post_process_input_phrases:NN #1#2 }
\bool_if:NT \l__cooking_units_lokal_numeral_bool
- {
- \__cooking_units_cuam_post_process_input_numerals:NN #1#2
- }
+ { \__cooking_units_cuam_post_process_input_numerals:NN #1#2 }
}
\cs_new:Npn \__cooking_units_cuam_post_process_input_phrases:NN #1#2
{
\__cooking_units_get_phrase_for_current_langauge:NNT
\l__cooking_units_phrase_prop
- \l__cooking_units_phrase_numbers_clist
+ \l__cooking_units_phrase_numbers_seq
{
\__cooking_units_cuam_post_process_input_phrases_aux:NNN
#1 \l__cooking_units_tmpa_int \l__cooking_units_phrase_number_tl
@@ -1778,18 +1815,17 @@
{
\bool_if:NTF \l__cooking_units_range_in_input_bool
{
- \__cooking_units_cuam_post_process_input_phrases_aux:NNN
- #2 \l__cooking_units_tmpb_int \l__cooking_units_tmpb_tl
- \bool_lazy_and:nnF
- { \l__cooking_units_lokal_phrase_bool }
- { \tl_if_eq_p:NN \l__cooking_units_phrase_number_tl \l__cooking_units_tmpb_tl }
- { \bool_set_false:N \l__cooking_units_lokal_phrase_bool }
- \bool_if:NT \l__cooking_units_lokal_phrase_bool
+ \bool_if:NF \l__cooking_units_phrase_negative_bool
{
- \tl_set:NV #1 \l__cooking_units_tmpa_int
- \tl_set:NV #2 \l__cooking_units_tmpb_int
- \__cooking_units_cuam_get_phrase_name:NVN
- \l__cooking_units_phrase_phrase_tl \l__cooking_units_phrase_number_tl \l__cooking_units_tmpb_int
+ \__cooking_units_cuam_post_process_input_phrases_range:NN
+ #2 \l__cooking_units_tmpb_int
+ \bool_if:NT \l__cooking_units_lokal_phrase_bool
+ {
+ \tl_set:NV #1 \l__cooking_units_tmpa_int
+ \tl_set:NV #2 \l__cooking_units_tmpb_int
+ \__cooking_units_cuam_get_phrase_name:NVN
+ \l__cooking_units_phrase_phrase_tl \l__cooking_units_phrase_number_tl \l__cooking_units_tmpb_int
+ }
}
}{
\tl_set:NV #1 \l__cooking_units_tmpa_int
@@ -1802,23 +1838,37 @@
\cs_new:Npn \__cooking_units_cuam_post_process_input_phrases_aux:NNN #1#2#3
{
\bool_set_false:N \l__cooking_units_lokal_phrase_bool
- \clist_map_inline:Nn \l__cooking_units_phrase_numbers_clist
+ \seq_map_inline:Nn \l__cooking_units_phrase_numbers_seq
{
\int_compare:nNnF { \int_abs:n {##1} } > {#1}
{
\int_compare:nNnTF {##1} < { 0 }
- { \int_set:Nn \l_tmpa_int { 1 } }
+ {
+ \bool_set_true:N \l__cooking_units_phrase_negative_bool
+ \int_set:Nn \l_tmpa_int { 1 }
+ }
{ \int_set:Nn \l_tmpa_int { \int_div_truncate:nn {#1} {##1} } }
\int_compare:nNnT { \int_abs:n {##1} * \l_tmpa_int } = {#1}
{
\int_set_eq:NN #2 \l_tmpa_int
\tl_set:Nn #3 {##1}
\bool_set_true:N \l__cooking_units_lokal_phrase_bool
- \clist_map_break:
+ \seq_map_break:
}
}
}
}
+\cs_new:Npn \__cooking_units_cuam_post_process_input_phrases_range:NN #1#2
+ {
+ \int_set:Nn \l_tmpa_int { \int_div_truncate:nn {#1} { \l__cooking_units_phrase_number_tl } }
+ \int_compare:nNnTF { \l__cooking_units_phrase_number_tl * \l_tmpa_int } = {#1}
+ {
+ \int_set_eq:NN #2 \l_tmpa_int
+ \bool_set_true:N \l__cooking_units_lokal_phrase_bool
+ }{
+ \bool_set_false:N \l__cooking_units_lokal_phrase_bool
+ }
+ }
\cs_new:Npn \__cooking_units_cuam_get_phrase_name:NnN #1#2#3
{
\__cooking_units_int_if_equal_one:nTF {#3}
@@ -1851,7 +1901,8 @@
{
\__cooking_units_int_if_equal_one:nTF {#1}
{
- \__cooking_units_translate_one_to_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl
+ \__cooking_units_translate_one_and_check_existance:Nx
+ \l__cooking_units_translation_tmpa_tl
{ \l__cooking_units_phrase_number_tl -phrase-gender }
\l__cooking_units_translation_tmpa_tl
}
@@ -1923,7 +1974,7 @@
\seq_map_inline:Nn \l__cooking_units_tmpa_seq
{
\prop_set_eq:cN { l__cooking_units_cukeys_ ##1 _prop } \l__cooking_units_tmpb_prop
- \tl_set:cn { l__cooking_units_tmpa_ ##1 _tl } { 1.0 }
+ \tl_set:cn { l__cooking_units_unit_change_ ##1 _tl } { 1.0 }
\seq_map_inline:Nn \l__cooking_units_tmpa_seq
{
\prop_put:cnx { l__cooking_units_cukeys_ ##1 _prop }
@@ -1972,7 +2023,7 @@
\prop_get:cVc
{ l__cooking_units_cukeys_#1_prop }
\l_keys_choice_tl
- { l__cooking_units_tmpa_ #1_tl }
+ { l__cooking_units_unit_change_ #1_tl }
\prop_put:NnV \l__cooking_units_change_unit_prop {#1} \l_keys_choice_tl
}
\cs_new:Npn \__cooking_units_cukeys_parse_and_create_single_key:nn #1#2
@@ -2007,7 +2058,7 @@
}
\cs_new:Npn \__cooking_units_cusinglekeys_create_key_prop:n #1
{
- \tl_set:cn { l__cooking_units_tmpa_ #1 _tl } { 1.0 }
+ \tl_set:cn { l__cooking_units_unit_change_ #1 _tl } { 1.0 }
\prop_set_eq:cN { l__cooking_units_cukeys_ #1 _prop } \l__cooking_units_tmpa_prop
\prop_put:cnn { l__cooking_units_cukeys_ #1 _prop } { Erstes Ding } {#1}
\prop_put:cnV { l__cooking_units_cukeys_ #1 _prop } { Liste } \l__cooking_units_tmpa_seq
@@ -2016,7 +2067,7 @@
\cs_new:Npn \__cooking_units_cukeys_define_singlekey:nn #1#2
{
\seq_if_in:NnF \l__cooking_units_list_of_defined_keys_seq {#1}
- { \seq_put_right:Nn \l__cooking_units_list_of_defined_keys_seq {#1} }
+ { \seq_put_right:Nn \l__cooking_units_list_of_defined_keys_seq {#1} }
\keys_define:nn { cooking-units }
{
#1 .choices:Vn =
@@ -2042,23 +2093,18 @@
\NewDocumentCommand \cuaddkeys { m m }
{
\bool_set_false:N \l__cooking_units_single_key_bool
- \tl_set:Nn \l__cooking_units_tmpa_tl {#1}
- \tl_set:Nn \l__cooking_units_tmpb_tl {#2}
- \__cooking_units_cukeys_add_keys_or_single_keys:VV \l__cooking_units_tmpa_tl \l__cooking_units_tmpb_tl
+ \__cooking_units_cukeys_add_keys_or_single_keys:nn {#1} {#2}
}
\NewDocumentCommand \cuaddsinglekeys { m m }
{
\bool_set_true:N \l__cooking_units_single_key_bool
- \tl_set:Nn \l__cooking_units_tmpa_tl {#1}
- \tl_set:Nn \l__cooking_units_tmpb_tl {#2}
- \__cooking_units_cukeys_add_keys_or_single_keys:VV \l__cooking_units_tmpa_tl \l__cooking_units_tmpb_tl
+ \__cooking_units_cukeys_add_keys_or_single_keys:nn {#1} {#2}
}
\NewDocumentCommand \cuaddtokeys { m m m }
{
\bool_set_false:N \l__cooking_units_single_key_bool
- \tl_set:Nn \l__cooking_units_tmpa_tl {#1}
\tl_set:Nn \l__cooking_units_tmpb_tl { {#2} { \fp_eval:n { 1.0 / (#3) } } }
- \__cooking_units_cukeys_add_keys_or_single_keys:VV \l__cooking_units_tmpa_tl \l__cooking_units_tmpb_tl
+ \__cooking_units_cukeys_add_keys_or_single_keys:nV {#1} \l__cooking_units_tmpb_tl
}
\cs_new:Npn \__cooking_units_cukeys_add_keys_or_single_keys:nn #1#2
{
@@ -2073,7 +2119,7 @@
{ \__cooking_units_cukeys_parse_and_create_keys:nn {#1} {#2} }
}
}
-\cs_generate_variant:Nn \__cooking_units_cukeys_add_keys_or_single_keys:nn { VV }
+\cs_generate_variant:Nn \__cooking_units_cukeys_add_keys_or_single_keys:nn { nV }
\cs_new:Npn \__cooking_units_cukeys_add_keys_and_single_key_aux:n #1
{
\prop_get:cnN { l__cooking_units_cukeys_ #1 _prop } { Liste } \l__cooking_units_tmpa_seq
@@ -2112,8 +2158,8 @@
{ \msg_error:nnn { cooking-units } { character-not-allowed } {#2} }
}
\seq_put_right:Nn \g__cooking_units_list_of_defined_units_seq {#2}
- \tl_new:c { l__cooking_units_tmpa_ #2 _tl }
- \tl_set:cn { l__cooking_units_tmpa_ #2 _tl } { 1.0 }
+ \tl_new:c { l__cooking_units_unit_change_ #2 _tl }
+ \tl_set:cn { l__cooking_units_unit_change_ #2 _tl } { 1.0 }
\clist_new:c { l__cooking_units_predefined_option_#2_clist }
\keys_define:nn { cooking-units }
{
@@ -2214,7 +2260,7 @@
{
\__cooking_units_cuname_parse_unit_symbol:nw {#1}
}{
- \clist_if_in:NnTF \g__cooking_units_allowed_special_keys_clist {#1}
+ \seq_if_in:NnTF \g__cooking_units_allowed_special_keys_seq {#1}
{ \__cooking_units_cuname_parse_input_aux:nn {#1} }
{ \__cooking_units_cuname_parse_unit_symbol:nw {#1} [ \q_no_value ] }
}
@@ -2243,7 +2289,7 @@
\quark_if_recursion_tail_stop:n {#1}
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
- \clist_if_in:NnF \g__cooking_units_allowed_special_keys_clist {#1}
+ \seq_if_in:NnF \g__cooking_units_allowed_special_keys_seq {#1}
{ \__cooking_units_error_if_unit_not_defined:n {#1} }
\__cooking_units_deftranslation_to:Vxxn
\l__cooking_units_language_tl {#1}
@@ -2254,7 +2300,7 @@
}
\cs_new:Npn \__cooking_units_cuname_parse_bracket:nw #1 [#2]
{
- \clist_if_in:NnF \g__cooking_units_allowed_special_keys_clist {#1}
+ \seq_if_in:NnF \g__cooking_units_allowed_special_keys_seq {#1}
{
\__cooking_units_deftranslation_to:Vxxn \l__cooking_units_language_tl {#1}
\c__cooking_units_postfix_unitname_pl_tl {#2}
@@ -2282,7 +2328,7 @@
\quark_if_recursion_tail_stop:n {#1}
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
- \clist_if_in:NnTF \g__cooking_units_allowed_special_keys_clist {#1}
+ \seq_if_in:NnTF \g__cooking_units_allowed_special_keys_seq {#1}
{
\__cooking_units_deftranslation_to:Vxxn \l__cooking_units_language_tl {#1}
\c__cooking_units_postfix_unitname_tl {#2}
@@ -2321,17 +2367,17 @@
\tl_set:Nn \l__cooking_units_language_tl {#1}
\__cooking_units_phrase_list_get_for:NNTF \l__cooking_units_phrase_prop \l__cooking_units_language_tl
{
- \__cooking_units_translate_let:VNxx \l__cooking_units_language_tl \l__cooking_units_phrase_numbers_clist
+ \__cooking_units_translate_let:VNxx \l__cooking_units_language_tl \l__cooking_units_phrase_numbers_seq
{ phrase-clist } \c__cooking_units_postfix_phrase_tl
}{
\prop_clear:N \l__cooking_units_phrase_prop
- \clist_clear:N \l__cooking_units_phrase_numbers_clist
+ \seq_clear:N \l__cooking_units_phrase_numbers_seq
}
\__cooking_units_sanitize_arrows:n {#2}
\exp_last_unbraced:NV
\__cooking_units_cuphrase_parse:n \l__cooking_units_sanitise_tl
\q_recursion_tail \q_recursion_tail \q_recursion_stop
- \clist_sort:Nn \l__cooking_units_phrase_numbers_clist
+ \seq_sort:Nn \l__cooking_units_phrase_numbers_seq
{
\int_compare:nNnTF { \int_abs:n {##1} } < { \int_abs:n {##2} }
{ \sort_return_swapped: }
@@ -2350,7 +2396,7 @@
\l__cooking_units_phrase_prop
\__cooking_units_deftranslation_to:VxxV
\l__cooking_units_language_tl { phrase-clist }
- \c__cooking_units_postfix_phrase_tl \l__cooking_units_phrase_numbers_clist
+ \c__cooking_units_postfix_phrase_tl \l__cooking_units_phrase_numbers_seq
}
\cs_new:Npn \__cooking_units_cuphrase_parse:n #1
{
@@ -2371,8 +2417,8 @@
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
\prop_put:Nnn \l__cooking_units_phrase_prop {#1} {#2}
- \clist_if_in:NnF \l__cooking_units_phrase_numbers_clist {#1}
- { \clist_put_right:Nn \l__cooking_units_phrase_numbers_clist {#1} }
+ \seq_if_in:NnF \l__cooking_units_phrase_numbers_seq {#1}
+ { \seq_push:Nn \l__cooking_units_phrase_numbers_seq {#1} }
\peek_meaning_ignore_spaces:NTF [
{
\__cooking_units_chuphrase_parse_plural:nw {#1}
@@ -2426,7 +2472,7 @@
{
\__cooking_units_int_if_equal_one:nTF {#1}
{
- \__cooking_units_translate_one_to_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl {#2}
+ \__cooking_units_translate_one_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl {#2}
\bool_if:NTF \l__cooking_units_cutext_uppercase_word_bool
{
\exp_args:Nx \tl_upper_case:n { \tl_head:V \l__cooking_units_translation_tmpa_tl }