From: Sylvestre Ledru Date: Sun, 26 Jul 2026 14:59:29 +0000 (+0200) Subject: tests: expr: exercise the C.UTF-8 locale X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=5b51bb162c2e377b6e586742f7e4072bf2f4b0bf;p=thirdparty%2Fcoreutils.git tests: expr: exercise the C.UTF-8 locale * tests/expr/expr-multibyte.pl: Add 'cu' prefixed cases running in C.UTF-8, which names no language but has a UTF-8 codeset, ensuring length, index, substr and match still operate on characters there. Skip them where that locale is unavailable. Link: https://github.com/coreutils/coreutils/pull/323 --- diff --git a/tests/expr/expr-multibyte.pl b/tests/expr/expr-multibyte.pl index 199c337958..92644482dd 100755 --- a/tests/expr/expr-multibyte.pl +++ b/tests/expr/expr-multibyte.pl @@ -177,6 +177,18 @@ my @Tests = ['mb-m7', "match \xCE\xB1bc\xCE\xB4e '\\([\xCE\xB1]\\)'", {OUT=>"\xCE\xB1"}], ['st-m7', "match \xCE\xB1bc\xCE\xB4e '\\([\xCE\xB1]\\)'", {OUT=>"\xCE"}], + + ### C.UTF-8 locale ### + + # C.UTF-8 names no language, but its codeset is UTF-8, so expr must + # still operate on characters rather than on octets there. + # Tests starting with 'cu' repeat a subset of the 'mb' cases above and + # expect the same results. + ['cu-l1', "length abc\xCE\xB4ef", {OUT=>"6"}], + ['cu-i1', "index \xCE\xB1bc\xCE\xB4ef \xCE\xB4", {OUT=>"4"}], + ['cu-s1', "substr \xCE\xB1bc\xCE\xB4ef 3 2", {OUT=>"c\xCE\xB4"}], + ['cu-m1', "match \xCE\xB1bc\xCE\xB4ef .bc", {OUT=>"3"}], + ); @@ -219,6 +231,17 @@ if ($locale ne 'C') } +# Run the 'cu' tests in the C.UTF-8 locale, and drop them where it is +# unavailable. +my $c_utf8_avail = qx(LC_ALL=C.UTF-8 locale charmap 2>/dev/null) =~ /^UTF-8$/m; +@Tests = grep {$_->[0] !~ /^cu/} @Tests + if ! $c_utf8_avail; +foreach my $t (@Tests) + { + push @$t, {ENV => 'LC_ALL=C.UTF-8'} + if $t->[0] =~ /^cu/; + } + my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE};