source: vendor/grep/2.12/tests/repetition-overflow

Last change on this file was 2595, checked in by bird, 13 years ago

gnu grep version 2.12 (grep-2.12.tar.xz, md5sum=8d2f0346d08b13c18afb81f0e8aa1e2f)

File size: 622 bytes
Line 
1#!/bin/sh
2# These would fail (i.e., match erroneously) prior to grep-2.11.
3. "${srcdir=.}/init.sh"; path_prepend_ ../src
4
5xp1=4294967297 # 2^32+1
6xp2=4294967298 # 2^32+2
7
8fail=0
9
10# Before grep-2.11, when DFA-matching, a repetition count exceeding the
11# range of "unsigned int" would silently wrap around. Hence, 2^32+1
12# would be treated just like "1", and both of these would mistakenly match.
13
14echo abc | grep -E "b{$xp1}" > out 2> /dev/null; test $? = 2 || fail=1
15compare /dev/null out || fail=1
16echo abbc | grep -E "b{1,$xp2}" > out 2> /dev/null; test $? = 2 || fail=1
17compare /dev/null out || fail=1
18
19Exit $fail
Note: See TracBrowser for help on using the repository browser.