VirtualBox

source: kBuild/trunk/src/grep/tests/euc-mb

Last change on this file was 3529, checked in by bird, 3 years ago

Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/bin/sh
2# test that matches starting in the middle of a multibyte char aren't rejected
3# too greedily.
4# Derived from https://savannah.gnu.org/bugs/?23814
5. "${srcdir=.}/init.sh"; path_prepend_ ../src
6
7# Add "." to PATH for the use of get-mb-cur-max.
8path_prepend_ .
9
10require_compiled_in_MB_support
11
12locale=ja_JP.EUC-JP
13
14make_input () {
15 echo "$1" | tr AB '\244\263'
16}
17
18euc_grep () {
19 pat=$(make_input "$1")
20 LC_ALL=$locale grep "$pat"
21}
22
23case $(get-mb-cur-max $locale) in
24 2|3) ;;
25 *) skip_ 'EUC-JP locale not found' ;;
26esac
27
28fail=0
29
30# Does EUC-JP work at all?
31make_input BABA |euc_grep AB && fail=1
32
33# Here are two cases in which a KWSet search matches in the middle
34# of a multibyte character. The first ensures that the DFA matcher
35# finds the real match at the end of line. The second ensures that
36# while the KWSet match found a false positive, the DFA matcher
37# determines there is no match after all.
38make_input BABAAB |euc_grep AB > out || fail=1
39make_input BABAAB > exp || framework_failure_
40compare exp out || fail=1
41make_input BABABA |returns_ 1 euc_grep AB || fail=1
42make_input BABABA |returns_ 1 euc_grep '^x\|AB' || fail=1
43
44# -P supports only unibyte and UTF-8 locales.
45returns_ 2 env LC_ALL=$locale grep -P x /dev/null || fail=1
46
47Exit $fail
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette