Skip to content

Commit

Permalink
Deprecate \str_foldcase:n in. favor of \str_casefold:n
Browse files Browse the repository at this point in the history
Naming is then aligned with e.g. Python and reflects the fact
that folding is not a case, but is rather removal of case.
  • Loading branch information
josephwright committed Oct 17, 2022
1 parent 7feb2c2 commit 4276860
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 30 deletions.
3 changes: 3 additions & 0 deletions l3experimental/CHANGELOG.md
Expand Up @@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.

## [Unreleased]

### Changed
- Track `expl3` core changes

## [2022-04-20]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion l3experimental/l3graphics/l3graphics.dtx
Expand Up @@ -532,7 +532,7 @@
\@@_include_auxi:e
{
\exp_args:Ne \str_tail:n
{ \str_foldcase:V \l_@@_ext_str }
{ \str_casefold:V \l_@@_ext_str }
}
}
{ \@@_include_auxi:e { \l_@@_type_str } }
Expand Down
2 changes: 2 additions & 0 deletions l3kernel/CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@ this project uses date-based 'snapshot' version identifiers.
- `\codepoint_to_bytes:n`
- `\codepoint_to_nfd:n`
- `\codepoint_str_generate:n`
- `\str_casefold:n`

### Changed
- Usage of `\exp_not:n`/`\exp_not:N` in `\peek_analysis_map_inline:n` output
Expand All @@ -24,6 +25,7 @@ this project uses date-based 'snapshot' version identifiers.
### Deprecated
- `\char_to_nfd:N`, `\char_to_nfd:n`
- `\char_to_utfviii_bytes:n`
- `\str_foldcase:n`

## [2022-09-28]

Expand Down
2 changes: 2 additions & 0 deletions l3kernel/doc/l3obsolete.txt
Expand Up @@ -36,6 +36,8 @@ Function Date deprecated
\str_declare_eight_bit_encoding:nnn 2020-08-20
\str_fold_case:n 2020-01-03
\str_fold_case:V 2020-01-03
\str_foldcase:N 2022-10-17
\str_foldcase:V 2022-10-17
\str_lower_case:f 2020-01-03
\str_lower_case:n 2020-01-03
\str_upper_case:f 2020-01-03
Expand Down
2 changes: 1 addition & 1 deletion l3kernel/l3color.dtx
Expand Up @@ -2146,7 +2146,7 @@
{
\exp_args:Nee \@@_model_new:nnn
{ \tl_to_str:n {#1} }
{ \str_foldcase:n {#2} } {#3}
{ \str_casefold:n {#2} } {#3}
}
\cs_new_protected:Npn \@@_model_new:nnn #1#2#3
{
Expand Down
18 changes: 14 additions & 4 deletions l3kernel/l3deprecation.dtx
Expand Up @@ -468,10 +468,20 @@
\cs_gset:Npn \str_upper_case:n { \str_uppercase:n }
\__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_uppercase:f }
\cs_gset:Npn \str_upper_case:f { \str_uppercase:f }
\__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_foldcase:n }
\cs_gset:Npn \str_fold_case:n { \str_foldcase:n }
\__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_foldcase:V }
\cs_gset:Npn \str_fold_case:V { \str_foldcase:V }
\__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_casefold:n }
\cs_gset:Npn \str_fold_case:n { \str_casefold:n }
\__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_casefold:V }
\cs_gset:Npn \str_fold_case:V { \str_casefold:V }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}[EXP]
% {\str_foldcase:n, \str_foldcase:V}
% \begin{macrocode}
\__kernel_patch_deprecation:nnNNpn { 2020-10-17 } { \str_casefold:n }
\cs_gset:Npn \str_foldcase:n { \str_casefold:n }
\__kernel_patch_deprecation:nnNNpn { 2022-10-17 } { \str_casefold:V }
\cs_gset:Npn \str_foldcase:V { \str_casefold:V }
% \end{macrocode}
% \end{macro}
%
Expand Down
2 changes: 1 addition & 1 deletion l3kernel/l3fp-parse.dtx
Expand Up @@ -1023,7 +1023,7 @@
\cs_if_exist_use:cF { @@_parse_word_#2:N }
{
\cs_if_exist_use:cF
{ @@_parse_caseless_ \str_foldcase:n {#2} :N }
{ @@_parse_caseless_ \str_casefold:n {#2} :N }
{
\msg_expandable_error:nnn
{ fp } { unknown-fp-word } {#2}
Expand Down
28 changes: 19 additions & 9 deletions l3kernel/l3str.dtx
Expand Up @@ -744,7 +744,7 @@
%
% These functions should \emph{not} be used for
% \begin{itemize}
% \item Caseless comparisons: use \cs{str_foldcase:n} for this
% \item Caseless comparisons: use \cs{str_casefold:n} for this
% situation (case folding is distinct from lower casing).
% \item Case changing text for typesetting: see the
% \cs[index=text_lowercase:n]{text_lowercase:n(n)},
Expand All @@ -755,18 +755,18 @@
% \end{itemize}
% \end{function}
%
% \begin{function}[EXP, added = 2019-11-26]
% {\str_foldcase:n, \str_foldcase:V}
% \begin{function}[EXP, added = 2022-10-16]
% {\str_casefold:n, \str_casefold:V}
% \begin{syntax}
% \cs{str_foldcase:n} \Arg{tokens}
% \cs{str_casefold:n} \Arg{tokens}
% \end{syntax}
% Converts the input \meta{tokens} to their string representation, as
% described for \cs{tl_to_str:n}, and then folds the case of the resulting
% \meta{string} to remove case information. The result of this process is
% left in the input stream.
%
% String folding is a process used for material such as identifiers rather
% than for \enquote{text}. The folding provided by \cs{str_foldcase:n}
% than for \enquote{text}. The folding provided by \cs{str_casefold:n}
% follows the mappings provided by the \href{http://www.unicode.org}^^A
% {Unicode Consortium}, who
% \href{http://www.unicode.org/faq/casemap_charprop.html#2}{state}:
Expand All @@ -779,7 +779,7 @@
% should be used solely for internal processing and generally should not be
% stored or displayed to the end user.
% \end{quote}
% The folding approach implemented by \cs{str_foldcase:n} follows the
% The folding approach implemented by \cs{str_casefold:n} follows the
% \enquote{full} scheme defined by the Unicode Consortium
% (\emph{e.g.}~\SS folds to \texttt{SS}). As case-folding is
% a language-insensitive process, there is no special treatment of
Expand Down Expand Up @@ -843,6 +843,16 @@
% code and so should only be used for short-term storage.
% \end{variable}
%
% \section{Deprecated functions}
%
% \begin{function}[EXP, added = 2019-11-26]
% {\str_foldcase:n, \str_foldcase:V}
% \begin{syntax}
% \cs{str_foldcase:n} \Arg{tokens}
% \end{syntax}
% A previous name for the functionally-identical \cs{str_casefold:n}.
% \end{function}
%
% \end{documentation}
%
% \begin{implementation}
Expand Down Expand Up @@ -1896,7 +1906,7 @@
%
% \begin{macro}[EXP]
% {
% \str_foldcase:n, \str_foldcase:V,
% \str_casefold:n, \str_casefold:V,
% \str_lowercase:n, \str_lowercase:f,
% \str_uppercase:n, \str_uppercase:f
% }
Expand All @@ -1920,10 +1930,10 @@
% with text-based case changing. Similarly, for $8$-bit engines the
% multi-byte information is shared.
% \begin{macrocode}
\cs_new:Npn \str_foldcase:n #1 { \@@_change_case:nn {#1} { casefold } }
\cs_new:Npn \str_casefold:n #1 { \@@_change_case:nn {#1} { casefold } }
\cs_new:Npn \str_lowercase:n #1 { \@@_change_case:nn {#1} { lowercase } }
\cs_new:Npn \str_uppercase:n #1 { \@@_change_case:nn {#1} { uppercase } }
\cs_generate_variant:Nn \str_foldcase:n { V }
\cs_generate_variant:Nn \str_casefold:n { V }
\cs_generate_variant:Nn \str_lowercase:n { f }
\cs_generate_variant:Nn \str_uppercase:n { f }
\cs_new:Npn \@@_change_case:nn #1
Expand Down
2 changes: 1 addition & 1 deletion l3kernel/l3text.dtx
Expand Up @@ -119,7 +119,7 @@
% Importantly, notice that these functions are intended for working with
% user \emph{text for typesetting}. For case changing programmatic data see
% the \pkg{l3str} module and discussion there of \cs{str_lowercase:n},
% \cs{str_uppercase:n} and \cs{str_foldcase:n}.
% \cs{str_uppercase:n} and \cs{str_casefold:n}.
%
% Case changing does not take place within math mode material so for example
% \begin{verbatim}
Expand Down
2 changes: 1 addition & 1 deletion l3kernel/testfiles-backend/m3color003.lvt
Expand Up @@ -160,7 +160,7 @@
\exp_args:Nnnx \color_model_new:nnn { BarTone #1 } { Separation }
{
name = BarTone~555~GN ,
alternative-model = \str_foldcase:n {#1} ,
alternative-model = \str_casefold:n {#1} ,
alternative-values = {#2}
}
\color_set:nnn { foo #1 } { BarTone #1 } { 0.5 }
Expand Down
24 changes: 12 additions & 12 deletions l3kernel/testfiles/m3str002.lvt
Expand Up @@ -13,46 +13,46 @@

\TESTEXP { Simple~Latin~case~folding }
{
" \str_foldcase:n { ABC ~ 123 ~ abc ~ !@ } "
" \str_casefold:n { ABC ~ 123 ~ abc ~ !@ } "
\NEWLINE
" \str_foldcase:n { ~ ABC ~ 123 ~ abc ~ !@ ~ } "
" \str_casefold:n { ~ ABC ~ 123 ~ abc ~ !@ ~ } "
\NEWLINE
" \str_foldcase:n { Some~$&#~odd~text~{~}~ } "
" \str_casefold:n { Some~$&#~odd~text~{~}~ } "
}

\TEST { Checking~category~codes }
{
\OMIT
\tl_set:Nn \l_tmpa_tl { abc~123 }
\TIMO
\tl_set:Nx \l_tmpb_tl{ \str_foldcase:n { ABC~123 } }
\tl_set:Nx \l_tmpb_tl{ \str_casefold:n { ABC~123 } }
\tl_if_eq:NNTF \l_tmpa_tl \l_tmpb_tl \ERROR \FALSE
\OMIT
\tl_set:Nx \l_tmpa_tl { \tl_to_str:n { abc~123 } }
\TIMO
\tl_set:Nx \l_tmpb_tl{ \str_foldcase:n { ABC~123 } }
\tl_set:Nx \l_tmpb_tl{ \str_casefold:n { ABC~123 } }
\tl_if_eq:NNTF \l_tmpa_tl \l_tmpb_tl \TRUE \ERROR
}
\sys_if_engine_ptex:T { \END }
\TESTEXP { Accented~characters,~etc. }
{
" \str_uppercase:n { Café } "
\NEWLINE
" \str_foldcase:n { ĆėƊṐṑ } "
" \str_casefold:n { ĆėƊṐṑ } "
\NEWLINE
" \str_foldcase:n { ᾪωΝ } "
" \str_casefold:n { ᾪωΝ } "
\NEWLINE
" \str_foldcase:n { ΰῢst } "
" \str_casefold:n { ΰῢst } "
\NEWLINE
" \str_foldcase:n { Ꚉ ꚇ} "
" \str_casefold:n { Ꚉ ꚇ} "
\NEWLINE
" \str_foldcase:n { ZꝎⓍ } "
" \str_casefold:n { ZꝎⓍ } "
}

\TEST { Characters~with~context-sensitive~Unicode~behaviour }
{
\tl_set:Nx \l_tmpa_tl { \str_foldcase:n { όσος } }
\tl_set:Nx \l_tmpb_tl { \str_foldcase:n { ΌΣΟΣ } }
\tl_set:Nx \l_tmpa_tl { \str_casefold:n { όσος } }
\tl_set:Nx \l_tmpb_tl { \str_casefold:n { ΌΣΟΣ } }
\tl_if_eq:NNTF \l_tmpa_tl \l_tmpb_tl \TRUE \FALSE
}

Expand Down

0 comments on commit 4276860

Please sign in to comment.