| 1 | #! /bin/sh
|
|---|
| 2 | # Grep 2.21 would report "grep: internal PCRE error: -27"
|
|---|
| 3 | #
|
|---|
| 4 | # Copyright 2015-2021 Free Software Foundation, Inc.
|
|---|
| 5 | #
|
|---|
| 6 | # Copying and distribution of this file, with or without modification,
|
|---|
| 7 | # are permitted in any medium without royalty provided the copyright
|
|---|
| 8 | # notice and this notice are preserved.
|
|---|
| 9 |
|
|---|
| 10 | . "${srcdir=.}/init.sh"; path_prepend_ ../src
|
|---|
| 11 | require_pcre_
|
|---|
| 12 |
|
|---|
| 13 | for p in 'base64 -d' 'base64 -D' 'openssl base64 -d' \
|
|---|
| 14 | "perl -MMIME::Base64 -0777ne 'print decode_base64(\$_)'" FAIL; do
|
|---|
| 15 | test "$p" = FAIL && skip_ "your system lacks a base64 decoder"
|
|---|
| 16 | x=$(echo eA==| ( eval "$p" ) 2>/dev/null) && test "X$x" = Xx &&
|
|---|
| 17 | {
|
|---|
| 18 | eval "b64_decode() { $p; }"
|
|---|
| 19 | break
|
|---|
| 20 | }
|
|---|
| 21 | done
|
|---|
| 22 |
|
|---|
| 23 | foo=$( (echo foo | gzip | gzip -d) 2>/dev/null) && test "X$foo" = Xfoo \
|
|---|
| 24 | || skip_ "your system lacks the gzip program"
|
|---|
| 25 |
|
|---|
| 26 | fail=0
|
|---|
| 27 |
|
|---|
| 28 | b64_decode >pcrejit.txt.gz <<'EOF' || framework_failure_
|
|---|
| 29 | H4sIAAAAAAACA+2bUU4DMQxE/7mMz5T7XwKE+IBKVLue58yk0B9EtX6xJxN7t4VaH69a6+tHrW+/
|
|---|
| 30 | r4e3n75KARWShSOFTtiumE3FPVyo79ATIJ0Ry0No/yXe99UIUqTGKKUzYHFJHJoaCONQDCnDSCDS
|
|---|
| 31 | IPAvGCVeXNsZ7lpbWFfdaZtgPos5LeK2C1TBKzD09V3HFlCOsbFT/hNbz4HzJaRjnjdam9FXw/o6
|
|---|
| 32 | VyPozhMmiaRYAMeNSJR1iMjBEFLMtsH7lptartfxkzPQgFVofwRlxKsMYn2KNDnU9fsOQCkRIYVT
|
|---|
| 33 | G80ZRqBpSQjRYPX7s9gvtqknyNE2f8V09sxHM7YPmMMJgrmVna2AT717n5fUAIDkiBCqFgWUUgKD
|
|---|
| 34 | 8jOc0Rgj5JS6vZnQI14wkaTDAkD266p/iVHs8gjCrMFARVM0iEVgFAa9YRAQT4tkgsmloTJLmyCm
|
|---|
| 35 | uSHRnTkzIdZMmZ5kYX/iJFtTwu9cFvr3aDWcUx4pUW/cVQwPoQSlwguNd4M0vTpAauKodmLFXv1P
|
|---|
| 36 | dkcKkYUglER2Q4L4gnmOiNGzSBATwGQgwihs5/QffIhyfg4hJvM2r4Rp6L+1ibCCd4jYZ6jCiBlc
|
|---|
| 37 | 2+y4fl4yTGIwcWXNAUEeXmu8iCMV96DNTnmRNICDk2N5qaXGbsF91OX/0hlcYTjrMfy02p9Xv70D
|
|---|
| 38 | mv3RZCFOAAA=
|
|---|
| 39 | EOF
|
|---|
| 40 |
|
|---|
| 41 | gzip -d pcrejit.txt || framework_failure_
|
|---|
| 42 |
|
|---|
| 43 | LC_ALL=C grep -P -n '^([/](?!/)|[^/])*~/.*' pcrejit.txt
|
|---|
| 44 | if test $? != 1; then
|
|---|
| 45 | # The above often makes grep attempt to use an inordinate amount
|
|---|
| 46 | # of stack space. If grep fails with $? != 1, try again, but this
|
|---|
| 47 | # time with no soft limit:
|
|---|
| 48 |
|
|---|
| 49 | # Use ulimit to remove that limit, if possible.
|
|---|
| 50 | # If ulimit is not usable, just skip this test.
|
|---|
| 51 | (ulimit -s unlimited) || skip_ this shell lacks ulimit support
|
|---|
| 52 |
|
|---|
| 53 | # Rerun that same test, but now with no limit on stack size:
|
|---|
| 54 | (ulimit -s unlimited;
|
|---|
| 55 | returns_ 1 env LC_ALL=C grep -P -n '^([/](?!/)|[^/])*~/.*' pcrejit.txt 2> err) \
|
|---|
| 56 | || fail=1
|
|---|
| 57 |
|
|---|
| 58 | # If that failed due to stack overflow, don't cry foul.
|
|---|
| 59 | overflow_pat="stack overflow|exceeded PCRE's recursion limit"
|
|---|
| 60 | test $fail = 1 && { grep -Eq "$overflow_pat" err && fail=0 || cat err; }
|
|---|
| 61 | fi
|
|---|
| 62 |
|
|---|
| 63 | Exit $fail
|
|---|