#!/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=.}
. "$srcdir/init.sh"; path_prepend_ ../src

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

euc_grep () {
  pat=`make_input "$1"`
  LC_ALL=ja_JP.EUC-JP grep "$pat"
}

if make_input BABA |euc_grep AB ; then
  skip_ 'EUC-JP locale seems not to work'
fi

make_input BABAAB |euc_grep AB || \
  fail_ 'whole line rejected after matching in the middle of a multibyte char'

Exit 0
