[3611] | 1 | #!/bin/sh
|
---|
| 2 | # Test compilation less-common cases
|
---|
| 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
|
---|
| 19 | print_ver_ sed
|
---|
| 20 |
|
---|
| 21 | #
|
---|
| 22 | # Special file names, with gnu extensions and without (if the host
|
---|
| 23 | # supports /dev/std{out,err} )
|
---|
| 24 | #
|
---|
| 25 | echo a > a || framework_failure_
|
---|
| 26 |
|
---|
| 27 | # With gnu extension enabled, /dev/stderr is emulated internally
|
---|
| 28 | # regardless of the operating system.
|
---|
| 29 | sed 'w/dev/stderr' a >out 2>err|| fail=1
|
---|
| 30 | compare_ a out || fail=1
|
---|
| 31 | compare_ a err || fail=1
|
---|
| 32 |
|
---|
| 33 | # In posix mode /dev/std* are not emulated internally. Skip if they
|
---|
| 34 | # don't exist. 'env' is used to avoid built-in 'test' which
|
---|
| 35 | # simulates /dev/stderr, e.g. bash on AIX.
|
---|
| 36 | if env test -w /dev/stderr ; then
|
---|
| 37 | sed --posix 'w/dev/stderr' a >out-psx 2>err-psx || fail=1
|
---|
| 38 | compare_ a out-psx || fail=1
|
---|
| 39 | compare_ a err-psx || fail=1
|
---|
| 40 | fi
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 | #
|
---|
| 44 | # labels followed by various characters
|
---|
| 45 | # (read_label)
|
---|
| 46 | echo a > lbl-in-exp || framework_failure_
|
---|
| 47 | cat << \EOF > lbl-prog || framework_failure_
|
---|
| 48 | bZ
|
---|
| 49 | :Z
|
---|
| 50 | bY;
|
---|
| 51 | :Y
|
---|
| 52 | {bX}
|
---|
| 53 | :X ;
|
---|
| 54 | b W
|
---|
| 55 | : W
|
---|
| 56 | EOF
|
---|
| 57 | sed -f lbl-prog lbl-in-exp > lbl-out || fail=1
|
---|
| 58 | compare_ lbl-in-exp lbl-out
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | #
|
---|
| 63 | # character classes (compile.c:snarf_char_class)
|
---|
| 64 | #
|
---|
| 65 |
|
---|
| 66 | # open brackets followed by EOF
|
---|
| 67 | cat <<\EOF >exp-err-op-bracket || framework_failure_
|
---|
| 68 | sed: -e expression #1, char 2: unterminated address regex
|
---|
| 69 | EOF
|
---|
| 70 | returns_ 1 sed '/[' </dev/null 2>err-op-bracket1 || fail=1
|
---|
| 71 | compare_ exp-err-op-bracket err-op-bracket1 || fail=1
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | # open brackets followed by \n
|
---|
| 75 | printf "/[\n" > op-bracket-prog || framework_failure_
|
---|
| 76 | cat <<\EOF >exp-err-op-bracket || framework_failure_
|
---|
| 77 | sed: file op-bracket-prog line 1: unterminated address regex
|
---|
| 78 | EOF
|
---|
| 79 | returns_ 1 sed -f op-bracket-prog </dev/null 2>err-op-bracket2 || fail=1
|
---|
| 80 | compare_ exp-err-op-bracket err-op-bracket2 || fail=1
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | # unterminated character class '[.'
|
---|
| 84 | # (snarf_char_class terminates on char 7, then returns)
|
---|
| 85 | cat <<\EOF >exp-chr-class || framework_failure_
|
---|
| 86 | sed: -e expression #1, char 7: unterminated `s' command
|
---|
| 87 | EOF
|
---|
| 88 | returns_ 1 sed 's/[[.//' </dev/null 2>err-chr-class || fail=1
|
---|
| 89 | compare_ exp-chr-class err-chr-class || fail=1
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | # closing bracket immediately after char-class opening
|
---|
| 93 | # sequence (e.g. '[:]' instead of '[:alpha:]' ).
|
---|
| 94 | cat<< \EOF >exp-chr-class2 || framework_failure_
|
---|
| 95 | sed: -e expression #1, char 9: unterminated `s' command
|
---|
| 96 | EOF
|
---|
| 97 | returns_ 1 sed 's/[[:]]//' </dev/null 2>err-chr-class2 || fail=1
|
---|
| 98 | compare_ exp-chr-class2 err-chr-class2 || fail=1
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 | # EOF after backslash in a regex (compile.c:match_slash())
|
---|
| 102 | cat<< \EOF >exp-backslash-eof || framework_failure_
|
---|
| 103 | sed: -e expression #1, char 2: unterminated address regex
|
---|
| 104 | EOF
|
---|
| 105 | returns_ 1 sed '/\' </dev/null 2>err-backslash-eof || fail=1
|
---|
| 106 | compare_ exp-backslash-eof err-backslash-eof || fail=1
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | # Valid version requirement
|
---|
| 110 | sed 'v4' < /dev/null || fail=1
|
---|
| 111 |
|
---|
| 112 | # Closing braces followed by another closing braces, and '#'
|
---|
| 113 | echo X > in-exp || framework_failure_
|
---|
| 114 | sed -n '{{p}}' in-exp > out-braces-1 || fail=1
|
---|
| 115 | compare_ in-exp out-braces-1 || fail=1
|
---|
| 116 |
|
---|
| 117 | sed -n '{p}#foo' in-exp > out-braces-2 || fail=1
|
---|
| 118 | compare_ in-exp out-braces-2 || fail=1
|
---|
| 119 |
|
---|
| 120 | # 'l' followed by closing braces, and '#'
|
---|
| 121 | printf 'X$\n' > exp-l || framework_failure_
|
---|
| 122 | sed -n '{l}' in-exp > out-l-braces || fail=1
|
---|
| 123 | compare_ exp-l out-l-braces || fail=1
|
---|
| 124 | sed -n 'l#foo' in-exp > out-l-hash || fail=1
|
---|
| 125 | compare_ exp-l out-l-hash || fail=1
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 | #
|
---|
| 129 | # unterminated a/c/i as last command
|
---|
| 130 | # (pending_text)
|
---|
| 131 | sed -e 'a\' in-exp > out-unterm-a1 || fail=1
|
---|
| 132 | compare_ in-exp out-unterm-a1 || fail=1
|
---|
| 133 |
|
---|
| 134 |
|
---|
| 135 | Exit $fail
|
---|