1 | #!/bin/sh
|
---|
2 | # grep -i would misbehave for any matched line containing a character
|
---|
3 | # (like "I" in the tr_TR.utf8 locale) whose lower-case representation
|
---|
4 | # occupies more bytes (two in this case, for 0xc4b1, aka U+0131).
|
---|
5 |
|
---|
6 | # Copyright (C) 2011-2021 Free Software Foundation, Inc.
|
---|
7 |
|
---|
8 | # This program is free software: you can redistribute it and/or modify
|
---|
9 | # it under the terms of the GNU General Public License as published by
|
---|
10 | # the Free Software Foundation, either version 3 of the License, or
|
---|
11 | # (at your option) any later version.
|
---|
12 |
|
---|
13 | # This program is distributed in the hope that it will be useful,
|
---|
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | # GNU General Public License for more details.
|
---|
17 |
|
---|
18 | # You should have received a copy of the GNU General Public License
|
---|
19 | # along with this program. If not, see <https://www.gnu.org/licenses/>.
|
---|
20 |
|
---|
21 | . "${srcdir=.}/init.sh"; path_prepend_ ../src
|
---|
22 |
|
---|
23 | require_tr_utf8_locale_
|
---|
24 | require_compiled_in_MB_support
|
---|
25 |
|
---|
26 | # Before this change, grep could print a lot of uninitialized memory:
|
---|
27 | # $ printf "IIIIIII\n" > in
|
---|
28 | # $ for i in $(seq 10); do LC_ALL=tr_TR.utf8 src/grep -i . in|wc -c; done
|
---|
29 | # 760
|
---|
30 | # 754
|
---|
31 | # 585
|
---|
32 | # 298
|
---|
33 | # 273
|
---|
34 | # 458
|
---|
35 | # 660
|
---|
36 | # 552
|
---|
37 | # 936
|
---|
38 | # 678
|
---|
39 |
|
---|
40 | fail=0
|
---|
41 |
|
---|
42 | printf "IIIIIII\n" > in || framework_failure_
|
---|
43 | LC_ALL=tr_TR.utf8 grep -i .... in > out || fail=1
|
---|
44 | compare out in || fail=1
|
---|
45 |
|
---|
46 | # Also exercise the case in which the original string and the lower-case
|
---|
47 | # buffer have precisely the same length (22 bytes here), yet internal
|
---|
48 | # offsets do differ. Lengths are the same because while some bytes shrink
|
---|
49 | # when converted to lower case, others grow, and here they balance out.
|
---|
50 | i='I\304\260'
|
---|
51 | printf "$i$i$i$i$i$i$i\n" > in || framework_failure_
|
---|
52 | LC_ALL=tr_TR.utf8 grep -i .... in > out || fail=1
|
---|
53 | compare out in || fail=1
|
---|
54 |
|
---|
55 | Exit $fail
|
---|