]>
Commit | Line | Data |
---|---|---|
5c1ebcca NTND |
1 | #!/bin/sh |
2 | ||
3 | test_description='grep icase on non-English locales' | |
4 | ||
a20b0dc7 | 5 | TEST_PASSES_SANITIZE_LEAK=true |
5c1ebcca NTND |
6 | . ./lib-gettext.sh |
7 | ||
c36c27e7 RS |
8 | doalarm () { |
9 | perl -e 'alarm shift; exec @ARGV' -- "$@" | |
10 | } | |
11 | ||
5c1ebcca NTND |
12 | test_expect_success GETTEXT_LOCALE 'setup' ' |
13 | test_write_lines "TILRAUN: Halló Heimur!" >file && | |
14 | git add file && | |
15 | LC_ALL="$is_IS_locale" && | |
16 | export LC_ALL | |
17 | ' | |
18 | ||
72aae6d6 ÆAB |
19 | test_expect_success GETTEXT_LOCALE 'setup REGEX_LOCALE prerequisite' ' |
20 | # This "test-tool" invocation is identical... | |
21 | if test-tool regex "HALLÓ" "Halló" ICASE | |
22 | then | |
23 | test_set_prereq REGEX_LOCALE | |
24 | else | |
25 | ||
26 | # ... to this one, but this way "test_must_fail" will | |
27 | # tell a segfault or abort() from the regexec() test | |
28 | # itself | |
29 | test_must_fail test-tool regex "HALLÓ" "Halló" ICASE | |
30 | fi | |
31 | ' | |
5c1ebcca NTND |
32 | |
33 | test_expect_success REGEX_LOCALE 'grep literal string, no -F' ' | |
34 | git grep -i "TILRAUN: Halló Heimur!" && | |
35 | git grep -i "TILRAUN: HALLÓ HEIMUR!" | |
36 | ' | |
37 | ||
3eb585c1 | 38 | test_expect_success GETTEXT_LOCALE,PCRE 'grep pcre utf-8 icase' ' |
18547aac NTND |
39 | git grep --perl-regexp "TILRAUN: H.lló Heimur!" && |
40 | git grep --perl-regexp -i "TILRAUN: H.lló Heimur!" && | |
41 | git grep --perl-regexp -i "TILRAUN: H.LLÓ HEIMUR!" | |
42 | ' | |
43 | ||
3eb585c1 | 44 | test_expect_success GETTEXT_LOCALE,PCRE 'grep pcre utf-8 string with "+"' ' |
18547aac NTND |
45 | test_write_lines "TILRAUN: Hallóó Heimur!" >file2 && |
46 | git add file2 && | |
47 | git grep -l --perl-regexp "TILRAUN: H.lló+ Heimur!" >actual && | |
48 | echo file >expected && | |
49 | echo file2 >>expected && | |
50 | test_cmp expected actual | |
51 | ' | |
52 | ||
793dc676 | 53 | test_expect_success REGEX_LOCALE 'grep literal string, with -F' ' |
e01b4dab ÆAB |
54 | git grep -i -F "TILRAUN: Halló Heimur!" && |
55 | git grep -i -F "TILRAUN: HALLÓ HEIMUR!" | |
793dc676 NTND |
56 | ' |
57 | ||
58 | test_expect_success REGEX_LOCALE 'grep string with regex, with -F' ' | |
e01b4dab ÆAB |
59 | test_write_lines "TILRAUN: Halló Heimur [abc]!" >file3 && |
60 | git add file3 && | |
61 | git grep -i -F "TILRAUN: Halló Heimur [abc]!" file3 | |
793dc676 NTND |
62 | ' |
63 | ||
b51a9c14 NTND |
64 | test_expect_success REGEX_LOCALE 'pickaxe -i on non-ascii' ' |
65 | git commit -m first && | |
66 | git log --format=%f -i -S"TILRAUN: HALLÓ HEIMUR!" >actual && | |
67 | echo first >expected && | |
68 | test_cmp expected actual | |
69 | ' | |
70 | ||
8a599983 ÆAB |
71 | test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: setup invalid UTF-8 data' ' |
72 | printf "\\200\\n" >invalid-0x80 && | |
73 | echo "ævar" >expected && | |
74 | cat expected >>invalid-0x80 && | |
95ca1f98 ÆAB |
75 | git add invalid-0x80 && |
76 | ||
77 | # Test for PCRE2_MATCH_INVALID_UTF bug | |
78 | # https://bugs.exim.org/show_bug.cgi?id=2642 | |
79 | printf "\\345Aæ\\n" >invalid-0xe5 && | |
80 | git add invalid-0xe5 | |
8a599983 ÆAB |
81 | ' |
82 | ||
83 | test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UTF-8 data' ' | |
84 | git grep -h "var" invalid-0x80 >actual && | |
85 | test_cmp expected actual && | |
86 | git grep -h "(*NO_JIT)var" invalid-0x80 >actual && | |
87 | test_cmp expected actual | |
88 | ' | |
89 | ||
95ca1f98 ÆAB |
90 | test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UTF-8 data (PCRE2 bug #2642)' ' |
91 | git grep -h "Aæ" invalid-0xe5 >actual && | |
92 | test_cmp invalid-0xe5 actual && | |
93 | git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual && | |
94 | test_cmp invalid-0xe5 actual | |
95 | ' | |
96 | ||
8a599983 | 97 | test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data' ' |
870eea81 | 98 | git grep -h "æ" invalid-0x80 >actual && |
8a599983 | 99 | test_cmp expected actual && |
c74b3cbb | 100 | git grep -h "(*NO_JIT)æ" invalid-0x80 >actual && |
8a599983 ÆAB |
101 | test_cmp expected actual |
102 | ' | |
103 | ||
95ca1f98 ÆAB |
104 | test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data (PCRE2 bug #2642)' ' |
105 | git grep -h "Aæ" invalid-0xe5 >actual && | |
106 | test_cmp invalid-0xe5 actual && | |
107 | git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual && | |
108 | test_cmp invalid-0xe5 actual | |
109 | ' | |
110 | ||
111 | test_lazy_prereq PCRE2_MATCH_INVALID_UTF ' | |
112 | test-tool pcre2-config has-PCRE2_MATCH_INVALID_UTF | |
113 | ' | |
114 | ||
8a599983 ÆAB |
115 | test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' ' |
116 | test_might_fail git grep -hi "Æ" invalid-0x80 >actual && | |
a4fea08b | 117 | test_might_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual |
8a599983 ÆAB |
118 | ' |
119 | ||
95ca1f98 ÆAB |
120 | test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' ' |
121 | git grep -hi "Æ" invalid-0x80 >actual && | |
122 | test_cmp expected actual && | |
123 | git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual && | |
124 | test_cmp expected actual | |
125 | ' | |
126 | ||
127 | test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i (PCRE2 bug #2642)' ' | |
128 | git grep -hi "Æ" invalid-0xe5 >actual && | |
129 | test_cmp invalid-0xe5 actual && | |
130 | git grep -hi "(*NO_JIT)Æ" invalid-0xe5 >actual && | |
131 | test_cmp invalid-0xe5 actual && | |
132 | ||
133 | # Only the case of grepping the ASCII part in a way that | |
134 | # relies on -i fails | |
135 | git grep -hi "aÆ" invalid-0xe5 >actual && | |
136 | test_cmp invalid-0xe5 actual && | |
137 | git grep -hi "(*NO_JIT)aÆ" invalid-0xe5 >actual && | |
138 | test_cmp invalid-0xe5 actual | |
139 | ' | |
140 | ||
dc2c44fb RS |
141 | test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-literal ASCII from UTF-8' ' |
142 | git grep --perl-regexp -h -o -e ll. file >actual && | |
143 | echo "lló" >expected && | |
144 | test_cmp expected actual | |
145 | ' | |
146 | ||
c36c27e7 RS |
147 | test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep avoid endless loop bug' ' |
148 | echo " Halló" >leading-whitespace && | |
149 | git add leading-whitespace && | |
150 | doalarm 1 git grep --perl-regexp "^\s" leading-whitespace | |
151 | ' | |
152 | ||
5c1ebcca | 153 | test_done |