aboutsummaryrefslogtreecommitdiff
path: root/contrib/bc
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2021-09-19 12:41:20 +0000
committerStefan Eßer <se@FreeBSD.org>2021-10-04 07:37:19 +0000
commit662087dfd0668dee82ed20d00ced662aa3595059 (patch)
tree6e87364f759534a27d9e580311294d5f7e5d2528 /contrib/bc
parent248682a589159619aa5f2019e415a423e849e327 (diff)
downloadsrc-662087dfd0668dee82ed20d00ced662aa3595059.tar.gz
src-662087dfd0668dee82ed20d00ced662aa3595059.zip
vendor/bc: update to upstream version 5.0.2
(cherry picked from commit a60ef1802a36f2f2a5611564191440ea1c1e2f17)
Diffstat (limited to 'contrib/bc')
-rw-r--r--contrib/bc/NEWS.md30
-rw-r--r--contrib/bc/include/status.h4
-rw-r--r--contrib/bc/include/vector.h4
-rw-r--r--contrib/bc/include/version.h2
-rw-r--r--contrib/bc/src/vector.c2
-rwxr-xr-xcontrib/bc/tests/all.sh3
-rwxr-xr-xcontrib/bc/tests/bc/timeconst.sh6
-rw-r--r--contrib/bc/tests/dc/errors/33.txtbin329 -> 323 bytes
-rwxr-xr-xcontrib/bc/tests/errors.sh26
-rwxr-xr-xcontrib/bc/tests/history.py15
-rwxr-xr-xcontrib/bc/tests/other.sh14
-rwxr-xr-xcontrib/bc/tests/read.sh4
-rwxr-xr-xcontrib/bc/tests/script.sh4
-rwxr-xr-xcontrib/bc/tests/stdin.sh4
-rwxr-xr-xcontrib/bc/tests/test.sh4
15 files changed, 73 insertions, 49 deletions
diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md
index 3b1477cafb26..f35d593b807a 100644
--- a/contrib/bc/NEWS.md
+++ b/contrib/bc/NEWS.md
@@ -1,5 +1,35 @@
# News
+## 5.0.2
+
+This is a production release with one fix for a flaky test. If you have not
+experienced problems with the test suite, you do ***NOT*** need to upgrade.
+
+The test was one that tested whether `bc` fails gracefully when it can't
+allocate memory. Unfortunately, there are cases when Linux and FreeBSD lie and
+pretend to allocate the memory.
+
+The reason they do this is because a lot of programs don't use all of the memory
+they allocate, so those OS's usually get away with it.
+
+However, this `bc` uses all of the memory it allocates (at least at page
+granularity), so when it tries to use the memory, FreeBSD and Linux kill it.
+
+This only happens sometimes, however. Other times (on my machine), they do, in
+fact, refuse the request.
+
+So I changed the test to not test for that because I think the graceful failure
+code won't really change much.
+
+## 5.0.1
+
+This is a production release with two fixes:
+
+* Fix for the build on Mac OSX.
+* Fix for the build on Android.
+
+Users that do not use those platforms do ***NOT*** need to update.
+
## 5.0.0
This is a major production release with several changes:
diff --git a/contrib/bc/include/status.h b/contrib/bc/include/status.h
index 781248ad4020..662f2b89c04d 100644
--- a/contrib/bc/include/status.h
+++ b/contrib/bc/include/status.h
@@ -53,6 +53,10 @@
#define DC_ENABLED (1)
#endif // DC_ENABLED
+#ifndef BC_ENABLE_LIBRARY
+#define BC_ENABLE_LIBRARY (0)
+#endif // BC_ENABLE_LIBRARY
+
// This is error checking for fuzz builds.
#if BC_ENABLE_AFL
#ifndef __AFL_HAVE_MANUAL_CONTROL
diff --git a/contrib/bc/include/vector.h b/contrib/bc/include/vector.h
index 8f7cbbcc2b50..c35d22c9eff7 100644
--- a/contrib/bc/include/vector.h
+++ b/contrib/bc/include/vector.h
@@ -441,7 +441,7 @@ void bc_slabvec_print(BcVec *v, const char *func);
* contain @a s.
* @param s The source string.
*/
-#define strcpy(d, l, s) strcpy(d, s)
+#define bc_strcpy(d, l, s) strcpy(d, s)
#else // _WIN32
@@ -452,7 +452,7 @@ void bc_slabvec_print(BcVec *v, const char *func);
* contain @a s.
* @param s The source string.
*/
-#define strcpy(d, l, s) strcpy_s(d, l, s)
+#define bc_strcpy(d, l, s) strcpy_s(d, l, s)
#endif // _WIN32
diff --git a/contrib/bc/include/version.h b/contrib/bc/include/version.h
index 5127c28e2b4a..071b123cccf1 100644
--- a/contrib/bc/include/version.h
+++ b/contrib/bc/include/version.h
@@ -37,6 +37,6 @@
#define BC_VERSION_H
/// The current version.
-#define VERSION 5.0.0
+#define VERSION 5.0.2
#endif // BC_VERSION_H
diff --git a/contrib/bc/src/vector.c b/contrib/bc/src/vector.c
index 1cd90f729956..ebc2e76ca8c8 100644
--- a/contrib/bc/src/vector.c
+++ b/contrib/bc/src/vector.c
@@ -461,7 +461,7 @@ static char* bc_slab_add(BcSlab *s, const char *str, size_t len) {
ptr = (char*) (s->s + s->len);
- strcpy(ptr, len, str);
+ bc_strcpy(ptr, len, str);
s->len += len;
diff --git a/contrib/bc/tests/all.sh b/contrib/bc/tests/all.sh
index 04afdb391d0e..a4a9c8bc8936 100755
--- a/contrib/bc/tests/all.sh
+++ b/contrib/bc/tests/all.sh
@@ -129,6 +129,9 @@ sh "$testdir/errors.sh" "$d" "$exe" "$@"
# Other tests.
sh "$testdir/other.sh" "$d" "$extra" "$exe" "$@"
+# History tests.
+sh "$testdir/history.sh" "$d" -a
+
printf '\nAll %s tests passed.\n' "$d"
printf '\n%s\n' "$stars"
diff --git a/contrib/bc/tests/bc/timeconst.sh b/contrib/bc/tests/bc/timeconst.sh
index 5c5ec3806ab8..45e10c77bdf4 100755
--- a/contrib/bc/tests/bc/timeconst.sh
+++ b/contrib/bc/tests/bc/timeconst.sh
@@ -32,6 +32,8 @@
script="$0"
testdir=$(dirname "$script")
+outputdir=${BC_TEST_OUTPUT_DIR:-$testdir/..}
+
# Gets the timeconst script, which could be a command-line argument.
if [ "$#" -gt 0 ]; then
timeconst="$1"
@@ -49,8 +51,8 @@ else
fi
#
-out1="$testdir/bc_outputs/bc_timeconst.txt"
-out2="$testdir/bc_outputs/bc_timeconst_results.txt"
+out1="$outputdir/bc_outputs/bc_timeconst.txt"
+out2="$outputdir/bc_outputs/bc_timeconst_results.txt"
outdir=$(dirname "$out1")
diff --git a/contrib/bc/tests/dc/errors/33.txt b/contrib/bc/tests/dc/errors/33.txt
index 524b548e6f4d..7d01c535c665 100644
--- a/contrib/bc/tests/dc/errors/33.txt
+++ b/contrib/bc/tests/dc/errors/33.txt
Binary files differ
diff --git a/contrib/bc/tests/errors.sh b/contrib/bc/tests/errors.sh
index d6c120aab4e7..c8c82cfe356f 100755
--- a/contrib/bc/tests/errors.sh
+++ b/contrib/bc/tests/errors.sh
@@ -34,6 +34,8 @@ testdir=$(dirname "$script")
. "$testdir/../scripts/functions.sh"
+outputdir=${BC_TEST_OUTPUT_DIR:-$testdir}
+
# Command-line processing.
if [ "$#" -eq 0 ]; then
printf 'usage: %s dir [exec args...]\n' "$script"
@@ -56,7 +58,7 @@ unset BC_LINE_LENGTH
unset DC_ENV_ARGS
unset DC_LINE_LENGTH
-out="$testdir/${d}_outputs/errors_results.txt"
+out="$outputdir/${d}_outputs/errors_results.txt"
outdir=$(dirname "$out")
# Make sure the directory exists.
@@ -146,33 +148,11 @@ for testfile in $testdir/$d/*errors.txt; do
done
-# I need to skip a test here on FreeBSD.
-os=$(uname)
-
-# The list of files we need to skip.
-skip_files="
-33.txt
-"
-
# Test all the files in the errors directory. While the loop above does one test
# for every line, this does one test per file, but it runs the file through
# stdin and as a file on the command-line.
for testfile in $testdir/$d/errors/*.txt; do
- # If we are on FreeBSD...
- if [ "$os" = "FreeBSD" ] && [ "$d" = "dc" ]; then
-
- b=$(basename "$testfile")
-
- # If the file is one of the skip files...
- if [ -z "${skip_files##*$b*}" ]; then
-
- printf 'On FreeBSD; skipping %s...\n' "$testfile"
- continue
-
- fi
- fi
-
printf 'Running %s error file %s...' "$d" "$testfile"
printf '%s\n' "$halt" | "$exe" "$@" $opts "$testfile" 2> "$out" > /dev/null
diff --git a/contrib/bc/tests/history.py b/contrib/bc/tests/history.py
index ae25c7cf2854..fff531652b1b 100755
--- a/contrib/bc/tests/history.py
+++ b/contrib/bc/tests/history.py
@@ -41,6 +41,11 @@ except ImportError:
script = sys.argv[0]
testdir = os.path.dirname(script)
+if "BC_TEST_OUTPUT_DIR" in os.environ:
+ outputdir = os.environ["BC_TEST_OUTPUT_DIR"]
+else:
+ outputdir = testdir
+
prompt = ">>> "
# This array is for escaping characters that are necessary to escape when
@@ -67,16 +72,6 @@ utf8_stress_strs = [
]
-def spawn(exe, args, env, encoding=None, codec_errors='strict'):
- if do_test:
- f = open(testdir + "/" + exedir + "_outputs/history_test.txt", "wb")
- return pexpect.popen_spawn.PopenSpawn([ exe ] + args, env=env,
- encoding=encoding, codec_errors=codec_errors, stderr=f)
- else:
- return pexpect.spawn(exe, args, env=env, encoding=encoding,
- codec_errors=codec_errors)
-
-
# Check that the child output the expected line. If history is false, then
# the output should change.
def check_line(child, expected, prompt=">>> ", history=True):
diff --git a/contrib/bc/tests/other.sh b/contrib/bc/tests/other.sh
index 0a856f4a6e22..4a26582457e3 100755
--- a/contrib/bc/tests/other.sh
+++ b/contrib/bc/tests/other.sh
@@ -34,6 +34,8 @@ testdir=$(dirname "$script")
. "$testdir/../scripts/functions.sh"
+outputdir=${BC_TEST_OUTPUT_DIR:-$testdir}
+
# Command-line processing.
if [ "$#" -ge 2 ]; then
@@ -135,8 +137,8 @@ if [ "$d" = "bc" ]; then
unset BC_ENV_ARGS
- redefine_res="$testdir/bc_outputs/redefine.txt"
- redefine_out="$testdir/bc_outputs/redefine_results.txt"
+ redefine_res="$outputdir/bc_outputs/redefine.txt"
+ redefine_out="$outputdir/bc_outputs/redefine_results.txt"
outdir=$(dirname "$easter_out")
@@ -201,8 +203,8 @@ else
printf 'Running dc Easter script...'
- easter_res="$testdir/dc_outputs/easter.txt"
- easter_out="$testdir/dc_outputs/easter_results.txt"
+ easter_res="$outputdir/dc_outputs/easter.txt"
+ easter_out="$outputdir/dc_outputs/easter_results.txt"
outdir=$(dirname "$easter_out")
@@ -222,8 +224,8 @@ else
fi
-out1="$testdir/../.log_$d.txt"
-out2="$testdir/../.log_${d}_test.txt"
+out1="$outputdir/${d}_outputs/${d}_other.txt"
+out2="$outputdir/${d}_outputs/${d}_other_test.txt"
printf 'Running %s line length tests...' "$d"
diff --git a/contrib/bc/tests/read.sh b/contrib/bc/tests/read.sh
index 1186a19c99bd..a1915eb271ac 100755
--- a/contrib/bc/tests/read.sh
+++ b/contrib/bc/tests/read.sh
@@ -34,6 +34,8 @@ testdir=$(dirname "$script")
. "$testdir/../scripts/functions.sh"
+outputdir=${BC_TEST_OUTPUT_DIR:-$testdir}
+
# Command-line processing.
if [ "$#" -lt 1 ]; then
printf 'usage: %s dir [exe [args...]]\n' "$0"
@@ -58,7 +60,7 @@ name="$testdir/$d/read.txt"
results="$testdir/$d/read_results.txt"
errors="$testdir/$d/read_errors.txt"
-out="$testdir/${d}_outputs/read_results.txt"
+out="$outputdir/${d}_outputs/read_results.txt"
outdir=$(dirname "$out")
# Make sure the directory exists.
diff --git a/contrib/bc/tests/script.sh b/contrib/bc/tests/script.sh
index f8fdd67ee137..162437af8f22 100755
--- a/contrib/bc/tests/script.sh
+++ b/contrib/bc/tests/script.sh
@@ -35,6 +35,8 @@ testdir=$(dirname "${script}")
. "$testdir/../scripts/functions.sh"
+outputdir=${BC_TEST_OUTPUT_DIR:-$testdir}
+
# Command-line processing.
if [ "$#" -lt 2 ]; then
printf 'usage: %s dir script [run_extra_tests] [run_stack_tests] [generate_tests] [time_tests] [exec args...]\n' "$script"
@@ -126,7 +128,7 @@ if [ "$run_stack_tests" -eq 0 ]; then
fi
-out="$testdir/${d}_outputs/${name}_script_results.txt"
+out="$outputdir/${d}_outputs/${name}_script_results.txt"
outdir=$(dirname "$out")
# Make sure the directory exists.
diff --git a/contrib/bc/tests/stdin.sh b/contrib/bc/tests/stdin.sh
index 56bd1aae227b..c9e02253c30a 100755
--- a/contrib/bc/tests/stdin.sh
+++ b/contrib/bc/tests/stdin.sh
@@ -35,6 +35,8 @@ testdir=$(dirname "$script")
. "$testdir/../scripts/functions.sh"
+outputdir=${BC_TEST_OUTPUT_DIR:-$testdir}
+
# Command-line processing.
if [ "$#" -lt 1 ]; then
printf 'usage: %s dir [exe [args...]]\n' "$0"
@@ -55,7 +57,7 @@ else
exe="$testdir/../bin/$d"
fi
-out="$testdir/${d}_outputs/stdin_results.txt"
+out="$outputdir/${d}_outputs/stdin_results.txt"
outdir=$(dirname "$out")
# Make sure the directory exists.
diff --git a/contrib/bc/tests/test.sh b/contrib/bc/tests/test.sh
index ec7f6ba920c9..9d557a715dc0 100755
--- a/contrib/bc/tests/test.sh
+++ b/contrib/bc/tests/test.sh
@@ -35,6 +35,8 @@ testdir=$(dirname "$script")
. "$testdir/../scripts/functions.sh"
+outputdir=${BC_TEST_OUTPUT_DIR:-$testdir}
+
# Command-line processing.
if [ "$#" -lt 2 ]; then
printf 'usage: %s dir test [generate_tests] [time_tests] [exe [args...]]\n' "$0"
@@ -74,7 +76,7 @@ else
exe="$testdir/../bin/$d"
fi
-out="$testdir/${d}_outputs/${t}_results.txt"
+out="$outputdir/${d}_outputs/${t}_results.txt"
outdir=$(dirname "$out")
# Make sure the directory exists.