VirtualBox

source: kBuild/vendor/sed/current/testsuite/mb-bad-delim.sh@ 3611

Last change on this file since 3611 was 3611, checked in by bird, 7 months ago

vendor/sed/current: GNU sed 4.9 (sed-4.9.tar.xz sha256:6e226b732e1cd739464ad6862bd1a1aba42d7982922da7a53519631d24975181)

  • Property svn:executable set to *
File size: 2.8 KB
Line 
1#!/bin/sh
2# Test 's' and 'y' non-slash delimiters in multibyte locales
3
4# Copyright (C) 2016-2022 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. "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed
19print_ver_ sed
20
21require_en_utf8_locale_
22
23# These tests use the following unicode character in various ways:
24# GREEK CAPITAL LETTER PHI (U+03A6)
25# UTF-8: hex: 0xCE 0xA6
26# oct: 0316 0246
27# bin: 11001110 10100110
28#
29# Octal encoding is used due to printf not supporting hex on older systems.
30# Using the first octet alone (\316) causes various multibyte related functions
31# to return '-2' (incomplete multibyte sequence).
32# using the second octet alone (\246) causess same functions to return '-1'
33# (ivalid multibyte sequence).
34
35
36# Reject a valid multibyte delimiter (instead of slash).
37printf 's\316\246a\316\246b\316\246' > prog1 || framework_failure_
38
39cat <<\EOF > exp-err1 || framework_failure_
40sed: file prog1 line 1: delimiter character is not a single-byte character
41EOF
42
43returns_ 1 env LC_ALL=en_US.UTF-8 sed -f prog1 < /dev/null 2>err1 || fail=1
44compare_ exp-err1 err1 || fail=1
45
46
47# Reject an incomplete multibyte delimiter (instead of slash).
48# This is an implmentation-specific behavior:
49# error is triggered upon first octet, before entire multibyte character
50# is scanned.
51printf 's\316a\316b\316' > prog2 || framework_failure_
52
53cat <<\EOF > exp-err2 || framework_failure_
54sed: file prog2 line 1: delimiter character is not a single-byte character
55EOF
56
57returns_ 1 env LC_ALL=en_US.UTF-8 sed -f prog2 </dev/null 2>err2 || fail=1
58compare_ exp-err2 err2 || fail=1
59
60# ... but accept octet \316 as delimiter in C locale
61echo a > in2 || framework_failure_
62echo b > exp2 || framework_failure_
63LC_ALL=C sed -f prog2 <in2 >out2 || fail=1
64compare_ exp2 out2 || fail=1
65
66
67
68# An invalid multibyte sequence is treated as a valid single byte,
69# thus accepted as a delimter (instead of slash).
70# This is an implmentation-specific behavior.
71printf 's\246a\246b\246' > prog3 || framework_failure_
72echo a > in3 || framework_failure_
73echo b > exp3 || framework_failure_
74
75LC_ALL=en_US.UTF-8 sed -f prog3 <in3 >out3 || fail=1
76compare_ exp3 out3 || fail=1
77
78# Expect identical result in C locale
79LC_ALL=C sed -f prog3 <in3 >out4 || fail=1
80compare_ exp3 out4 || fail=1
81
82
83Exit $fail
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette