source: trunk/src/sed/testsuite/normalize-text.sh

Last change on this file was 3613, checked in by bird, 14 months ago

src/sed: Merged in changes between 4.1.5 and 4.9 from the vendor branch. (svn merge /vendor/sed/4.1.5 /vendor/sed/current .)

File size: 2.2 KB
Line 
1#!/bin/sh
2# Text text escaping (compile.c:normalize_text()).
3# NOTE:
4# \dNNN \xNN \oNNN - tested in 'convert-number.sh'
5# character-classes in POSIX mode - tested in 'posix-char-class.sh'
6
7# Copyright (C) 2016-2022 Free Software Foundation, Inc.
8
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
21. "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed
22print_ver_ sed
23
24#
25# Common backslash combinations
26#
27printf "%s\n" a a a a a a >in1 || framework_failure_
28cat <<\EOF >prog1 || framework_failure_
291y/a/\a/
302y/a/\f/
313y/a/\n/
324y/a/\r/
335y/a/\t/
346y/a/\v/
35EOF
36printf "\a\n\f\n\n\n\r\n\t\n\v\n" > exp1 || framework_failure_
37
38sed -f prog1 in1 > out1 || fail=1
39compare_ exp1 out1 || fail=1
40
41#
42# test '\\\n' (backslash followed by ASCII 0x0A)
43# normalized to a simple '\n' .
44#
45echo a > in2 || framework_failure_
46printf "y/a/\\\n/" > prog2 || framework_failure_
47printf "\n\n" > exp2 || framework_failure_
48sed -f prog2 in2 > out2 || fail=1
49compare_ exp2 out2 || fail=1
50
51#
52# \cX combination
53#
54printf "%s\n" a a a a a a a a a a > in3 || framework_failure_
55cat <<\EOF >prog3 || framework_failure_
561y/a/\cA/
572y/a/\ca/
583y/a/\cZ/
594y/a/\cz/
605y/a/\c{/
616y/a/\c;/
627y/a/\c#/
638y/a/\c[/
649y/a/\c\\/
6510y/a/\c]/
66EOF
67
68printf "\1\n\1\n\32\n\32\n;\n{\nc\n\33\n\34\n\35\n" > exp3 || framework_failure_
69sed -f prog3 in3 > out3 || fail=1
70compare_ exp3 out3 || fail=1
71
72# \c at end of (valid) text - normalize_text() stops, returns control to caller.
73# TODO: is this a bug?
74# compare with 'y/a/\d/' and 'y/a/\x/'
75cat <<\EOF >exp-err-c || framework_failure_
76sed: -e expression #1, char 7: strings for `y' command are different lengths
77EOF
78returns_ 1 sed 'y/a/\c/' </dev/null 2>err-c || fail=1
79compare_ exp-err-c err-c || fail=1
80
81Exit $fail
Note: See TracBrowser for help on using the repository browser.