summaryrefslogtreecommitdiff
path: root/tests/euc-mb
blob: c0af220afb3869a53e87332efc92edc66765b815 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# test that matches starting in the middle of a multibyte char aren't rejected
# too greedily.
# Derived from https://savannah.gnu.org/bugs/?23814
. "${srcdir=.}/init.sh"; path_prepend_ ../src

# Add "." to PATH for the use of get-mb-cur-max.
path_prepend_ .

require_compiled_in_MB_support

locale=ja_JP.EUC-JP

make_input () {
  echo "$1" | tr AB '\244\263'
}

euc_grep () {
  pat=$(make_input "$1")
  LC_ALL=$locale grep "$pat"
}

case $(get-mb-cur-max $locale) in
  2|3) ;;
  *) skip_ 'EUC-JP locale not found' ;;
esac

fail=0

# Does EUC-JP work at all?
make_input BABA |euc_grep AB && fail=1

# Whole line rejected after matching in the middle of a multibyte char?
make_input BABAAB |euc_grep AB || fail=1

Exit $fail