[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tests: don't assume expr was built with GMP
From: |
Paul Eggert |
Subject: |
[PATCH] tests: don't assume expr was built with GMP |
Date: |
Sat, 18 May 2013 16:31:03 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 |
* tests/misc/cut-huge-range.sh (subtract_one): New string.
(CUT_MAX): Don't pass a too-large integer to 'expr'.
---
tests/misc/cut-huge-range.sh | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/tests/misc/cut-huge-range.sh b/tests/misc/cut-huge-range.sh
index e9190a2..7816577 100755
--- a/tests/misc/cut-huge-range.sh
+++ b/tests/misc/cut-huge-range.sh
@@ -21,10 +21,31 @@ print_ver_ cut
require_ulimit_v_
getlimits_
+# sed script to subtract one from the input.
+# Each input line should consist of a positive decimal number.
+# Each output line's number is one less than the input's.
+# There's no limit (other than line length) on the number's magnitude.
+subtract_one='
+ s/$/@/
+ : again
+ s/0@/@9/
+ s/1@/0/
+ s/2@/1/
+ s/3@/2/
+ s/4@/3/
+ s/5@/4/
+ s/6@/5/
+ s/7@/6/
+ s/8@/7/
+ s/9@/8/
+ t again
+'
+
# Ensure we can cut up to our sentinel value.
# This is currently SIZE_MAX, but could be raised to UINTMAX_MAX
# if we didn't allocate memory for each line as a unit.
-CUT_MAX=$(expr $SIZE_MAX - 1)
+# Don't use expr to subtract one, since SIZE_MAX may exceed its maximum value.
+CUT_MAX=$(echo $SIZE_MAX | sed "$subtract_one")
# From coreutils-8.10 through 8.20, this would make cut try to allocate
# a 256MiB bit vector. With a 20MB limit on VM, the following would fail.
--
1.7.11.7
- [PATCH] tests: don't assume expr was built with GMP,
Paul Eggert <=