1#!/bin/sh 2# tests for printing multi-byte values of characters 3 4# Copyright (C) 2022-2023 Free Software Foundation, Inc. 5 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. 10 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. 15 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/>. 18 19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 20print_ver_ printf 21 22prog='env printf' 23 24unset LC_ALL 25f=$LOCALE_FR_UTF8 26: ${LOCALE_FR_UTF8=none} 27if test "$LOCALE_FR_UTF8" != "none"; then 28 ( 29 #valid multi-byte 30 LC_ALL=$f $prog '%04x\n' '"á' >>out 2>>err 31 #invalid multi-byte 32 LC_ALL=$f $prog '%04x\n' "'$($prog '\xe1')" >>out 2>>err 33 #uni-byte 34 LC_ALL=C $prog '%04x\n' "'$($prog '\xe1')" >>out 2>>err 35 #valid multi-byte, with trailing 36 LC_ALL=$f $prog '%04x\n' '"á=' >>out 2>>err 37 #invalid multi-byte, with trailing 38 LC_ALL=$f $prog '%04x\n' "'$($prog '\xe1')=" >>out 2>>err 39 ) 40 cat <<\EOF > exp || framework_failure_ 4100e1 4200e1 4300e1 4400e1 4500e1 46EOF 47 compare exp out || fail=1 48 49 # Disparate LC_CTYPE and LC_MESSAGES problematic on macos, 50 # so just look for character in warning message, 51 # and normalize to LC_MESSAGES=C 52 C_WARNING='printf: '\ 53'warning: =: character(s) following character constant have been ignored' 54 55 sed "s/printf:.*=.*/$C_WARNING/" < err > c_err || framework_failure_ 56 57 cat <<EOF > exp_err 58$C_WARNING 59$C_WARNING 60EOF 61 compare exp_err c_err || fail=1 62fi 63 64Exit $fail 65