VirtualBox

source: kBuild/vendor/sed/current/testsuite/subst-options.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)

File size: 2.8 KB
Line 
1#!/bin/sh
2# Test Substitute options (for code-coverage purposes as well)
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
21#
22# Simple modifiers to s//
23# (specific characters included as make_subst_opts's implementation
24# checks for them before returning control)
25printf "%s\n" a a a a a a > subst-in1 || framework_failure_
26printf "%s\n" x x x x x x > subst-exp1 || framework_failure_
27cat << \EOF >> subst-prog1 || framework_failure_
281s/A/x/i
292s/A/x/I
30
31# s// followed by '}'
323{s/./x/}
33# s// followed by '#'
344s/./x/#
35# s// followed by ';'
365s/./x/;
37# s// followed by '\n
386s/./x/
39EOF
40
41sed -f subst-prog1 subst-in1 > subst-out1 || fail=1
42compare_ subst-exp1 subst-out1 || fail=1
43
44
45#
46# Number modifiers to s//
47#
48
49cat << \EOF >subst-in2 || framework_failure_
50bbbbbbbbbb
51bbbbbbbbbb
52bbbbbbbbbb
53bbbbbbbbbb
54bbbbbbbbbb
55bbbbbbbbbb
56bbbbbbbbbb
57bbbbbbbbbb
58bbbbbbbbbb
59bbbbbbbbbb
60EOF
61
62cat << \EOF >subst-prog2 || framework_failure_
631s/./x/g
642s/./x/1
653s/./x/2
664s/./x/3
675s/./x/4
686s/./x/5
697s/./x/6
708s/./x/7
719s/./x/8
7210s/./x/9
73EOF
74
75cat << \EOF >subst-exp2
76xxxxxxxxxx
77xbbbbbbbbb
78bxbbbbbbbb
79bbxbbbbbbb
80bbbxbbbbbb
81bbbbxbbbbb
82bbbbbxbbbb
83bbbbbbxbbb
84bbbbbbbxbb
85bbbbbbbbxb
86EOF
87
88sed -f subst-prog2 subst-in2 > subst-out2 || fail=1
89compare_ subst-exp2 subst-out2 || fail=1
90
91#
92# Multiline modifier: s///m
93# ('N' will read and concatenate the second line
94# into the patten space, making it "foo\nbar".
95# s// will then operate on it as one string).
96printf "foo\nbar\n" > subst-in3 || fail=1
97printf "Xoo\nXar\n" > subst-exp3 || fail=1
98
99sed 'N;s/^./X/gm' subst-in3 > subst-out3-1 || fail=1
100compare_ subst-exp3 subst-out3-1 || fail=1
101sed 'N;s/^./X/gM' subst-in3 > subst-out3-2 || fail=1
102compare_ subst-exp3 subst-out3-2 || fail=1
103
104# sanity-check: without m, only the first line should match
105printf "Xoo\nbar\n" > subst-exp3-3 || fail=1
106sed 'N;s/^./X/g' subst-in3 > subst-out3-3 || fail=1
107compare_ subst-exp3-3 subst-out3-3 || fail=1
108
109
110#
111# s// followed by \r\n
112#
113
114printf "s/./X/\r\n" > subst-prog4 || framework_failure_
115echo a > subst-in4 || framework_failure_
116echo X > subst-exp4 || framework_failure_
117sed -f subst-prog4 subst-in4 > subst-out4 || fail=1
118compare_ subst-exp4 subst-out4 || fail=1
119
120
121
122
123Exit $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