env: prefer xpalloc to x2nrealloc
[coreutils.git] / tests / printf / printf-mb.sh
blob1e8802ff03f84b74ccf0724cfda4a07436858379
1 #!/bin/sh
2 # tests for printing multi-byte values of characters
4 # Copyright (C) 2022-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ printf
22 prog='env printf'
24 unset LC_ALL
25 if test "$LOCALE_FR_UTF8" != "none"; then
26 f=$LOCALE_FR_UTF8
28 #valid multi-byte
29 LC_ALL=$f $prog '%04x\n' '"á' >>out 2>>err
30 #invalid multi-byte
31 LC_ALL=$f $prog '%04x\n' "'$($prog '\xe1')" >>out 2>>err
32 #uni-byte
33 LC_ALL=C $prog '%04x\n' "'$($prog '\xe1')" >>out 2>>err
34 #valid multi-byte, with trailing
35 LC_ALL=$f $prog '%04x\n' '"á=' >>out 2>>err
36 #invalid multi-byte, with trailing
37 LC_ALL=$f $prog '%04x\n' "'$($prog '\xe1')=" >>out 2>>err
39 cat <<\EOF > exp || framework_failure_
40 00e1
41 00e1
42 00e1
43 00e1
44 00e1
45 EOF
46 compare exp out || fail=1
48 # Disparate LC_CTYPE and LC_MESSAGES problematic on macos,
49 # so just look for character in warning message,
50 # and normalize to LC_MESSAGES=C
51 C_WARNING='printf: '\
52 'warning: =: character(s) following character constant have been ignored'
54 sed "s/printf:.*=.*/$C_WARNING/" < err > c_err || framework_failure_
56 cat <<EOF > exp_err
57 $C_WARNING
58 $C_WARNING
59 EOF
60 compare exp_err c_err || fail=1
63 Exit $fail