| 1 | #! /bin/sh
|
|---|
| 2 | # Test for false matches in grep 2.19..2.26 in multibyte, non-UTF8 locales
|
|---|
| 3 | #
|
|---|
| 4 | # Copyright (C) 2016-2021 Free Software Foundation, Inc.
|
|---|
| 5 | #
|
|---|
| 6 | # Copying and distribution of this file, with or without modification,
|
|---|
| 7 | # are permitted in any medium without royalty provided the copyright
|
|---|
| 8 | # notice and this notice are preserved.
|
|---|
| 9 |
|
|---|
| 10 | . "${srcdir=.}/init.sh"; path_prepend_ ../src
|
|---|
| 11 |
|
|---|
| 12 | # Add "." to PATH for the use of get-mb-cur-max.
|
|---|
| 13 | path_prepend_ .
|
|---|
| 14 |
|
|---|
| 15 | fail=0
|
|---|
| 16 |
|
|---|
| 17 | loc=zh_CN.gb18030
|
|---|
| 18 | test "$(get-mb-cur-max $loc)" = 4 || skip_ "no support for the $loc locale"
|
|---|
| 19 |
|
|---|
| 20 | # This must not match: the input is a single character, \uC9 followed
|
|---|
| 21 | # by a newline. But it just so happens that that character is made up
|
|---|
| 22 | # of four bytes, the last of which is the digit, 7, and grep's DFA
|
|---|
| 23 | # matcher would mistakenly report that ".*7" matches that input line.
|
|---|
| 24 | printf '\2010\2077\n' > in || framework_failure_
|
|---|
| 25 | returns_ 1 env LC_ALL=$loc grep -E '.*7' in || fail=1
|
|---|
| 26 |
|
|---|
| 27 | returns_ 1 env LC_ALL=$loc grep -E '.{0,1}7' in || fail=1
|
|---|
| 28 |
|
|---|
| 29 | returns_ 1 env LC_ALL=$loc grep -E '.?7' in || fail=1
|
|---|
| 30 |
|
|---|
| 31 | # Similar for the \ue9 code point, which ends in an "m" byte.
|
|---|
| 32 | loc=zh_HK.big5hkscs
|
|---|
| 33 | test "$(get-mb-cur-max $loc)" = 2 || skip_ "no support for the $loc locale"
|
|---|
| 34 |
|
|---|
| 35 | printf '\210m\n' > in || framework_failure_
|
|---|
| 36 | returns_ 1 env LC_ALL=$loc grep '.*m' in || fail=1
|
|---|
| 37 |
|
|---|
| 38 | Exit $fail
|
|---|