Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 May 2023 15:58:03 GMT
From:      =?utf-8?Q?Stefan=20E=C3=9Fer?= <se@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 76238846ad3e - main - contrib/bc: upgrade to version 6.6.0
Message-ID:  <202305251558.34PFw36A011488@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by se:

URL: https://cgit.FreeBSD.org/src/commit/?id=76238846ad3e9e271a3d1f792f72beab727fd153

commit 76238846ad3e9e271a3d1f792f72beab727fd153
Author:     Stefan Eßer <se@FreeBSD.org>
AuthorDate: 2023-05-25 15:55:31 +0000
Commit:     Stefan Eßer <se@FreeBSD.org>
CommitDate: 2023-05-25 15:55:31 +0000

    contrib/bc: upgrade to version 6.6.0
    
    This update removes printing of a leading zero in scientific or
    engineering output modes (which are an extended feature of this
    implementation).
    
    (cherry-picked from commit 8b83ef067441f6d3a4a55e92d1738724954a057c)
    
    MFC after:      2 weeks
---
 contrib/bc/LICENSE.md                       |   2 +-
 contrib/bc/Makefile.in                      |   2 +-
 contrib/bc/NEWS.md                          |  12 ++
 contrib/bc/README.md                        |  18 +-
 contrib/bc/configure.sh                     |  32 +++-
 contrib/bc/include/num.h                    |   8 +
 contrib/bc/include/status.h                 |   7 +
 contrib/bc/include/version.h                |   2 +-
 contrib/bc/src/num.c                        |  83 ++++++--
 contrib/bc/src/program.c                    |  15 +-
 contrib/bc/src/rand.c                       |   5 +-
 contrib/bc/tests/bc/all.txt                 |   1 +
 contrib/bc/tests/bc/rand_limits.txt         | 284 ++++++++++++++++++++++++++++
 contrib/bc/tests/bc/rand_limits_results.txt | 222 ++++++++++++++++++++++
 contrib/bc/tests/extra_required.txt         |   1 +
 contrib/bc/tests/script.sh                  |  14 +-
 16 files changed, 674 insertions(+), 34 deletions(-)

diff --git a/contrib/bc/LICENSE.md b/contrib/bc/LICENSE.md
index b65095edc26c..74441065df35 100644
--- a/contrib/bc/LICENSE.md
+++ b/contrib/bc/LICENSE.md
@@ -59,7 +59,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 The files `src/rand.c` and `include/rand.h` are under the following copyrights
 and license:
 
-Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
+Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors<br>
 Copyright (c) 2018-2023 Gavin D. Howard <gavin@gavinhoward.com>
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of
diff --git a/contrib/bc/Makefile.in b/contrib/bc/Makefile.in
index f936fc2c6de6..55e2e4a6270a 100644
--- a/contrib/bc/Makefile.in
+++ b/contrib/bc/Makefile.in
@@ -205,7 +205,7 @@ DC_DEFS = $(DC_DEFS1) $(DC_DEFS2) $(DC_DEFS3) $(DC_DEFS4) $(DC_DEFS5)
 CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
 CPPFLAGS2 = $(CPPFLAGS1) -I$(INCDIR)/ -DBUILD_TYPE=$(BC_BUILD_TYPE) %%LONG_BIT_DEFINE%%
 CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC)
-CPPFLAGS4 = $(CPPFLAGS3) %%BSD%%
+CPPFLAGS4 = $(CPPFLAGS3) %%BSD%% %%APPLE%%
 CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
 CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS)
 CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md
index 44b17b060f5c..de3b35026fea 100644
--- a/contrib/bc/NEWS.md
+++ b/contrib/bc/NEWS.md
@@ -1,5 +1,17 @@
 # News
 
+## 6.6.0
+
+This is a production release with two bug fixes and one change.
+
+The first bug fix is to fix the build on Mac OSX.
+
+The second bug was to remove printing a leading zero in scientific or
+engineering output modes.
+
+The change was that the implementation of `irand()` was improved to call the
+PRNG less.
+
 ## 6.5.0
 
 This is a production release that fixes an infinite loop bug in `root()` and
diff --git a/contrib/bc/README.md b/contrib/bc/README.md
index 9d395f747185..943ca89eee2c 100644
--- a/contrib/bc/README.md
+++ b/contrib/bc/README.md
@@ -422,13 +422,23 @@ Other projects based on this bc are:
 
 * [busybox `bc`][8]. The busybox maintainers have made their own changes, so any
   bugs in the busybox `bc` should be reported to them.
-
 * [toybox `bc`][9]. The maintainer has also made his own changes, so bugs in the
   toybox `bc` should be reported there.
-
 * [FreeBSD `bc`][23]. While the `bc` in FreeBSD is kept up-to-date, it is better
   to [report bugs there][24], as well as [submit patches][25], and the
   maintainers of the package will contact me if necessary.
+* [Mac OSX `bc`][35]. Any bugs in that `bc` should be reported to me, but do
+  expect bugs because the version is old.
+* [Android Open Source `bc`][32]. Any bugs in that `bc` can be reported here.
+
+This is a non-comprehensive list of Linux distros that use this `bc` as the
+system `bc`:
+
+* [Gentoo][33]; it is a first-class alternative to GNU `bc`, but not exclusive.
+* [Linux from Scratch][34].
+
+Other Linux distros package it as a second-class alternative, usually as `bc-gh`
+or `howard-bc`.
 
 ## Language
 
@@ -500,3 +510,7 @@ Folders:
 [29]: https://github.com/gavinhoward/bc
 [30]: ./manuals/bc/A.1.md#extended-library
 [31]: ./manuals/build.md#settings
+[32]: https://android.googlesource.com/platform/external/bc/
+[33]: https://github.com/gentoo/gentoo/blob/master/app-alternatives/bc/bc-0.ebuild#L8
+[34]: https://www.linuxfromscratch.org/lfs/view/stable/chapter08/bc.html
+[35]: https://github.com/apple-oss-distributions/bc/tree/main/bc
diff --git a/contrib/bc/configure.sh b/contrib/bc/configure.sh
index 021d30807ffb..4ba957131d52 100755
--- a/contrib/bc/configure.sh
+++ b/contrib/bc/configure.sh
@@ -772,7 +772,7 @@ predefined_build() {
 			dc_default_digit_clamp=0;;
 
 		GDH)
-			CFLAGS="-flto -Weverything -Wno-padded -Werror -pedantic -std=c11"
+			CFLAGS="-flto -Weverything -Wno-padded -Wno-unsafe-buffer-usage -Werror -pedantic -std=c11"
 			bc_only=0
 			dc_only=0
 			coverage=0
@@ -806,7 +806,7 @@ predefined_build() {
 			dc_default_digit_clamp=1;;
 
 		DBG)
-			CFLAGS="-Weverything -Wno-padded -Werror -pedantic -std=c11"
+			CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Werror -pedantic -std=c11"
 			bc_only=0
 			dc_only=0
 			coverage=0
@@ -1653,12 +1653,12 @@ else
 	# We are also setting the CFLAGS and LDFLAGS here.
 	if [ "$editline" -ne 0 ]; then
 		LDFLAGS="$LDFLAGS -ledit"
-		CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=1 -DBC_ENABLE_READLINE=0"
+		CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=1 -DBC_ENABLE_READLINE=0"
 	elif [ "$readline" -ne 0 ]; then
 		LDFLAGS="$LDFLAGS -lreadline"
-		CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=1"
+		CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=1"
 	else
-		CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0"
+		CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0"
 	fi
 
 fi
@@ -1682,6 +1682,24 @@ else
 	CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
 fi
 
+# Test Mac OSX. This is not in an if statement because regardless of whatever
+# the user says, we need to know if we are on Mac OSX. If we are, we have to set
+# _DARWIN_C_SOURCE.
+printf 'Testing for Mac OSX...\n'
+
+flags="-DBC_TEST_APPLE -DBC_ENABLE_AFL=0"
+"$CC" $CPPFLAGS $CFLAGS $flags "-I$scriptdir/include" -E "$scriptdir/src/vm.c" > /dev/null 2>&1
+
+err="$?"
+
+if [ "$err" -ne 0 ]; then
+	printf 'On Mac OSX. Using _DARWIN_C_SOURCE.\n\n'
+	apple="-D_DARWIN_C_SOURCE"
+else
+	printf 'Not on Mac OSX.\n\n'
+	apple=""
+fi
+
 # Test OpenBSD. This is not in an if statement because regardless of whatever
 # the user says, we need to know if we are on OpenBSD to activate _BSD_SOURCE.
 # No, I cannot `#define _BSD_SOURCE` in a header because OpenBSD's patched GCC
@@ -1690,7 +1708,6 @@ fi
 # we have to set it because we also set _POSIX_C_SOURCE, which OpenBSD headers
 # detect, and when they detect it, they turn off _BSD_SOURCE unless it is
 # specifically requested.
-set +e
 printf 'Testing for OpenBSD...\n'
 
 flags="-DBC_TEST_OPENBSD -DBC_ENABLE_AFL=0"
@@ -1713,6 +1730,8 @@ else
 	bsd=""
 fi
 
+set -e
+
 if [ "$library" -eq 1 ]; then
 	bc_lib=""
 fi
@@ -2072,6 +2091,7 @@ contents=$(replace "$contents" "CLEAN_PREREQS" "$CLEAN_PREREQS")
 contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU")
 
 contents=$(replace "$contents" "BSD" "$bsd")
+contents=$(replace "$contents" "APPLE" "$apple")
 
 contents=$(replace "$contents" "BC_DEFAULT_BANNER" "$bc_default_banner")
 contents=$(replace "$contents" "BC_DEFAULT_SIGINT_RESET" "$bc_default_sigint_reset")
diff --git a/contrib/bc/include/num.h b/contrib/bc/include/num.h
index 8078809250f8..d24c206cbe51 100644
--- a/contrib/bc/include/num.h
+++ b/contrib/bc/include/num.h
@@ -71,6 +71,10 @@ typedef BclBigDig BcBigDig;
 /// An alias for portability.
 #define BC_NUM_BIGDIG_C UINT64_C
 
+/// The max number + 1 that two limbs can hold. This is used for generating
+/// numbers because the PRNG can generate a number that will fill two limbs.
+#define BC_BASE_RAND_POW (BC_NUM_BIGDIG_C(1000000000000000000))
+
 /// The actual limb type.
 typedef int_least32_t BcDig;
 
@@ -88,6 +92,10 @@ typedef int_least32_t BcDig;
 /// An alias for portability.
 #define BC_NUM_BIGDIG_C UINT32_C
 
+/// The max number + 1 that two limbs can hold. This is used for generating
+/// numbers because the PRNG can generate a number that will fill two limbs.
+#define BC_BASE_RAND_POW (UINT64_C(100000000))
+
 /// The actual limb type.
 typedef int_least16_t BcDig;
 
diff --git a/contrib/bc/include/status.h b/contrib/bc/include/status.h
index 198cf5704a57..242514edb476 100644
--- a/contrib/bc/include/status.h
+++ b/contrib/bc/include/status.h
@@ -60,6 +60,13 @@
 #endif // __FreeBSD__
 #endif // BC_TEST_FREEBSD
 
+// This is used by configure.sh to test for Mac OSX.
+#ifdef BC_TEST_APPLE
+#ifdef __APPLE__
+#error On Mac OSX without _DARWIN_C_SOURCE
+#endif // __APPLE__
+#endif // BC_TEST_APPLE
+
 // Windows has deprecated isatty() and the rest of these. Or doesn't have them.
 // So these are just fixes for Windows.
 #ifdef _WIN32
diff --git a/contrib/bc/include/version.h b/contrib/bc/include/version.h
index daa1977c3cb6..a4df383e284a 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 6.5.0
+#define VERSION 6.6.0
 
 #endif // BC_VERSION_H
diff --git a/contrib/bc/src/num.c b/contrib/bc/src/num.c
index 8f70c6a409d1..0a59707268df 100644
--- a/contrib/bc/src/num.c
+++ b/contrib/bc/src/num.c
@@ -3515,8 +3515,9 @@ bc_num_print(BcNum* restrict n, BcBigDig base, bool newline)
 		// Print the sign.
 		if (BC_NUM_NEG(n)) bc_num_putchar('-', true);
 
-		// Print the leading zero if necessary.
-		if (BC_Z && BC_NUM_RDX_VAL(n) == n->len)
+		// Print the leading zero if necessary. We don't print when using
+		// scientific or engineering modes.
+		if (BC_Z && BC_NUM_RDX_VAL(n) == n->len && base != 0 && base != 1)
 		{
 			bc_num_printHex(0, 1, false, !newline);
 		}
@@ -3815,7 +3816,7 @@ void
 bc_num_irand(BcNum* restrict a, BcNum* restrict b, BcRNG* restrict rng)
 {
 	BcNum atemp;
-	size_t i, len;
+	size_t i;
 
 	assert(a != b);
 
@@ -3835,24 +3836,76 @@ bc_num_irand(BcNum* restrict a, BcNum* restrict b, BcRNG* restrict rng)
 	assert(atemp.num != NULL);
 	assert(atemp.len);
 
-	len = atemp.len - 1;
+	if (atemp.len > 2)
+	{
+		size_t len;
+
+		len = atemp.len - 2;
 
-	// Just generate a random number for each limb.
-	for (i = 0; i < len; ++i)
+		// Just generate a random number for each limb.
+		for (i = 0; i < len; i += 2)
+		{
+			BcRand dig;
+
+			dig = bc_rand_bounded(rng, BC_BASE_RAND_POW);
+
+			b->num[i] = (BcDig) (dig % BC_BASE_POW);
+			b->num[i + 1] = (BcDig) (dig / BC_BASE_POW);
+		}
+	}
+	else
 	{
-		b->num[i] = (BcDig) bc_rand_bounded(rng, BC_BASE_POW);
+		// We need this set.
+		i = 0;
 	}
 
-	// Do the last digit explicitly because the bound must be right. But only
-	// do it if the limb does not equal 1. If it does, we have already hit the
-	// limit.
-	if (atemp.num[i] != 1)
+	// This will be true if there's one full limb after the two limb groups.
+	if (i == atemp.len - 2)
 	{
-		b->num[i] = (BcDig) bc_rand_bounded(rng, (BcRand) atemp.num[i]);
-		b->len = atemp.len;
+		// Increment this for easy use.
+		i += 1;
+
+		// If the last digit is not one, we need to set a bound for it
+		// explicitly. Since there's still an empty limb, we need to fill that.
+		if (atemp.num[i] != 1)
+		{
+			BcRand dig;
+			BcRand bound;
+
+			// Set the bound to the bound of the last limb times the amount
+			// needed to fill the second-to-last limb as well.
+			bound = ((BcRand) atemp.num[i]) * BC_BASE_POW;
+
+			dig = bc_rand_bounded(rng, bound);
+
+			// Fill the last two.
+			b->num[i - 1] = (BcDig) (dig % BC_BASE_POW);
+			b->num[i] = (BcDig) (dig / BC_BASE_POW);
+
+			// Ensure that the length will be correct. If the last limb is zero,
+			// then the length needs to be one less than the bound.
+			b->len = atemp.len - (b->num[i] == 0);
+		}
+		// Here the last limb *is* one, which means the last limb does *not*
+		// need to be filled. Also, the length needs to be one less because the
+		// last limb is 0.
+		else
+		{
+			b->num[i - 1] = (BcDig) bc_rand_bounded(rng, BC_BASE_POW);
+			b->len = atemp.len - 1;
+		}
+	}
+	// Here, there is only one limb to fill.
+	else
+	{
+		// See above for how this works.
+		if (atemp.num[i] != 1)
+		{
+			b->num[i] = (BcDig) bc_rand_bounded(rng, (BcRand) atemp.num[i]);
+			b->len = atemp.len - (b->num[i] == 0);
+		}
+		else b->len = atemp.len - 1;
 	}
-	// We want 1 less len in the case where we skip the last limb.
-	else b->len = len;
 
 	bc_num_clean(b);
 
diff --git a/contrib/bc/src/program.c b/contrib/bc/src/program.c
index 243f827fe98c..2f26589166e3 100644
--- a/contrib/bc/src/program.c
+++ b/contrib/bc/src/program.c
@@ -2703,12 +2703,21 @@ bc_program_globalSetting(BcProgram* p, uchar inst)
 	assert(inst >= BC_INST_LINE_LENGTH && inst <= BC_INST_LEADING_ZERO);
 #endif // DC_ENABLED
 
-	if (inst == BC_INST_LINE_LENGTH) val = (BcBigDig) vm->line_len;
+	if (inst == BC_INST_LINE_LENGTH)
+	{
+		val = (BcBigDig) vm->line_len;
+	}
 #if BC_ENABLED
-	else if (inst == BC_INST_GLOBAL_STACKS) val = (BC_G != 0);
+	else if (inst == BC_INST_GLOBAL_STACKS)
+	{
+		val = (BC_G != 0);
+	}
 #endif // BC_ENABLED
 #if DC_ENABLED
-	else if (inst == BC_INST_EXTENDED_REGISTERS) val = (DC_X != 0);
+	else if (inst == BC_INST_EXTENDED_REGISTERS)
+	{
+		val = (DC_X != 0);
+	}
 #endif // DC_ENABLED
 	else val = (BC_Z != 0);
 
diff --git a/contrib/bc/src/rand.c b/contrib/bc/src/rand.c
index 11c22cd507c3..560e494214ad 100644
--- a/contrib/bc/src/rand.c
+++ b/contrib/bc/src/rand.c
@@ -517,8 +517,11 @@ bc_rand_int(BcRNG* r)
 BcRand
 bc_rand_bounded(BcRNG* r, BcRand bound)
 {
+	BcRand rand;
+	BcRand threshold;
+
 	// Calculate the threshold below which we have to try again.
-	BcRand rand, threshold = (0 - bound) % bound;
+	threshold = (0 - bound) % bound;
 
 	do
 	{
diff --git a/contrib/bc/tests/bc/all.txt b/contrib/bc/tests/bc/all.txt
index 3d0ea05ba7c0..c710534aac1b 100644
--- a/contrib/bc/tests/bc/all.txt
+++ b/contrib/bc/tests/bc/all.txt
@@ -47,6 +47,7 @@ misc7
 misc8
 void
 rand
+rand_limits
 recursive_arrays
 divmod
 modexp
diff --git a/contrib/bc/tests/bc/rand_limits.txt b/contrib/bc/tests/bc/rand_limits.txt
new file mode 100644
index 000000000000..9f6848739e3b
--- /dev/null
+++ b/contrib/bc/tests/bc/rand_limits.txt
@@ -0,0 +1,284 @@
+seed = 12183415694832323910165063565742029266.78201143488173352403523006\
+	   17939450703787369504276248076613097826033345478457018711188931947\
+	   5643844725709641352295875549316406250
+
+if (maxrand() >= 2^64 - 1) {
+
+	for (i = 1; i <= 37; ++i)
+	{
+		irand(10^i)
+	}
+
+	1
+	77
+	914
+	8200
+	44887
+	866441
+	2358358
+	13559535
+	416767986
+	9276295152
+	89383616490
+	954770306600
+	8117340260822
+	90441255304792
+	123091484400148
+	673234816385761
+	33144762500773628
+	741775860680476044
+	4715856253932519349
+	44722685516799788803
+	691627564627043533689
+	3601367765145373281202
+	27535154823004408648947
+	51478009115008961612866
+	4031778740698066425486191
+	95653217339584215257144674
+	426302455455598639876532628
+	1216686741117783240797844143
+	17705719185928989853748208134
+	784851648926334033332776172502
+	3120413811981279690501349408357
+	38214388551463331616358091659583
+	720453131307667144268209805308554
+	8939221360785849706894139937864130
+	10262211588802126422696984407808741
+	267283013443362846268603285132432016
+	2034014520976339794036584994364919660
+}
+else {
+
+	5
+	15
+	701
+	8215
+	98794
+	602366
+	2027255
+	74687524
+	830825144
+	6081336208
+	24314055735
+	838559932276
+	6866719060925
+	36806875401211
+	406827598340727
+	5356006452532004
+	38220052834497507
+	337361587138720056
+	1181974760686154481
+	16008532535003488966
+	951908092544652236970
+	90730737551380302703
+	46492092840194767743061
+	188697840939074129889664
+	3963332393372745718515074
+	78044317381361304314479194
+	257814131633376797403093774
+	5383100889234097635148206308
+	39812361752905775691804497289
+	222434065196674291290714932718
+	4942298796724199168854529657788
+	30804146383811856719866376789543
+	817977187096950760817419359822004
+	922359768927341898905002631901715
+	84002847212517205019842390182209654
+	423700247670879534125867432896848815
+	982360002329187383971171836321012954
+
+	for (i = 1; i <= 37; ++i)
+	{
+		irand(10^i)
+	}
+}
+
+seed = 12183415694832323910165063565742029266.82951754507405817776622978\
+       09630984098584076072986006731059784797092101840727292180396879039\
+       9608224106486886739730834960937500000
+
+if (maxrand() >= 2^64 - 1) {
+
+	for (i = 1; i <= 37; ++i)
+	{
+		irand(10^i)
+	}
+
+	9
+	84
+	802
+	9765
+	80115
+	246589
+	4463508
+	85992729
+	977135
+	4189279533
+	68755431294
+	107950335674
+	9675253977558
+	87867459318681
+	801765066192715
+	2162649050595056
+	2892195376814570
+	134060417012729962
+	7176764836888537721
+	5273685153052366176
+	461774434438273613889
+	152344588818260411506
+	11709967193759556155964
+	533206453770793013516792
+	2511508581949736433569969
+	1573162243991468106989339
+	215826582488545888127004159
+	1480805837640270183994742134
+	61049958584446767740466194227
+	145231395106326027295263107581
+	7023255505921253691380349839502
+	48606431941187693512006850149822
+	87214859605659588002413450479944
+	7949773868584392220935704452065706
+	4544031206641768922348422844031232
+	37285268346623956247142903563298469
+	696722030777467416877847444483018982
+}
+else {
+
+	9
+	73
+	468
+	1781
+	79556
+	166610
+	9336284
+	96403025
+	23318279
+	1074901232
+	30659049590
+	125915951725
+	3123436435684
+	52610031172756
+	445020218860038
+	87520306151384
+	47213087211849485
+	154045322058555704
+	9488624282418036451
+	12849313140308039019
+	828063328914872193931
+	2956454855398834052902
+	87417046449320418408586
+	165187095179884370295407
+	3602892678245454556711806
+	88079064510429999588220544
+	376741359503002189591164726
+	56633499559885161310029862
+	11172900796387700171428233596
+	473873806840427957175182603343
+	824290276873152640168308384248
+	36092351141101218267245025967581
+	39973475177812910298579659860850
+	7364670182480566996610562443888661
+	51592684301602944329896812066058114
+	951444349069518195584787848316744461
+	3234933598293500107173129970384252570
+
+	for (i = 1; i <= 37; ++i)
+	{
+		irand(10^i)
+	}
+}
+
+seed = 149423560533592712773538909996244073918.2952752612544959208642520\
+       06505634103779572918483064082477106507620297186161725006312917321\
+       53815843275879160501062870025634765625
+
+if (maxrand() >= 2^64 - 1) {
+
+	for (i = 1; i <= 37; ++i)
+	{
+		irand(10^i)
+	}
+
+	0
+	94
+	825
+	907
+	62512
+	633399
+	3539412
+	65712557
+	329618801
+	9052319971
+	50117657456
+	719515050973
+	396081658001
+	98762199564287
+	537857673363391
+	5701380917944903
+	16144997029797264
+	918603142053856533
+	4437053492025674148
+	76125560050255946142
+	262504846798815931770
+	688599520356200914010
+	77509440962809216890090
+	889672321539369676198789
+	5795540531885308263478299
+	88374255397211092706329509
+	118231692173643319720953958
+	6218036129497143746927154520
+	3236727278542723274070894570
+	72098882691751515204435662053
+	8305331942254135876823981226459
+	33980292322856768815329277766669
+	154632353482145519952015208333866
+	192400848794451940507964192401413
+	69666401739718540927805290639731997
+	545814355378177567662640611917018958
+	4986776343571879972263664198494529846
+}
+else {
+
+	6
+	47
+	709
+	350
+	45155
+	117711
+	6147313
+	26359748
+	56878412
+	930721373
+	47052494689
+	84216331603
+	1874946867051
+	30417072907659
+	157776263741438
+	3325742508233965
+	39500653878059614
+	278676289794009775
+	3342139004245631096
+	63313724143310202591
+	647891168358497623537
+	5925769871143510986759
+	3051401096746445704645
+	761857520743586046415633
+	9077595326394996332524977
+	2159936754163773508122732
+	426809670586105698135317225
+	3294516277260755029991322796
+	14749983115477586453985047494
+	692100641365100970093726483540
+	9502478720578852594268790479747
+	9062487417784678956874793130476
+	352159971921852073191742323073689
+	2270803770328639487517517910897872
+	35166631277333300065883628523569361
+	596441689792333324819903835359197616
+	6933582360405829608479430394981956723
+
+	for (i = 1; i <= 37; ++i)
+	{
+		irand(10^i)
+	}
+}
diff --git a/contrib/bc/tests/bc/rand_limits_results.txt b/contrib/bc/tests/bc/rand_limits_results.txt
new file mode 100644
index 000000000000..7950429c5e67
--- /dev/null
+++ b/contrib/bc/tests/bc/rand_limits_results.txt
@@ -0,0 +1,222 @@
+5
+15
+701
+8215
+98794
+602366
+2027255
+74687524
+830825144
+6081336208
+24314055735
+838559932276
+6866719060925
+36806875401211
+406827598340727
+5356006452532004
+38220052834497507
+337361587138720056
+1181974760686154481
+16008532535003488966
+951908092544652236970
+90730737551380302703
+46492092840194767743061
+188697840939074129889664
+3963332393372745718515074
+78044317381361304314479194
+257814131633376797403093774
+5383100889234097635148206308
+39812361752905775691804497289
+222434065196674291290714932718
+4942298796724199168854529657788
+30804146383811856719866376789543
+817977187096950760817419359822004
+922359768927341898905002631901715
+84002847212517205019842390182209654
+423700247670879534125867432896848815
+982360002329187383971171836321012954
+1
+77
+914
+8200
+44887
+866441
+2358358
+13559535
+416767986
+9276295152
+89383616490
+954770306600
+8117340260822
+90441255304792
+123091484400148
+673234816385761
+33144762500773628
+741775860680476044
+4715856253932519349
+44722685516799788803
+691627564627043533689
+3601367765145373281202
+27535154823004408648947
+51478009115008961612866
+4031778740698066425486191
+95653217339584215257144674
+426302455455598639876532628
+1216686741117783240797844143
+17705719185928989853748208134
+784851648926334033332776172502
+3120413811981279690501349408357
+38214388551463331616358091659583
+720453131307667144268209805308554
+8939221360785849706894139937864130
+10262211588802126422696984407808741
+267283013443362846268603285132432016
+2034014520976339794036584994364919660
+9
+73
+468
+1781
+79556
+166610
+9336284
+96403025
+23318279
+1074901232
+30659049590
+125915951725
+3123436435684
+52610031172756
+445020218860038
+87520306151384
+47213087211849485
+154045322058555704
+9488624282418036451
+12849313140308039019
+828063328914872193931
+2956454855398834052902
+87417046449320418408586
+165187095179884370295407
+3602892678245454556711806
+88079064510429999588220544
+376741359503002189591164726
+56633499559885161310029862
+11172900796387700171428233596
+473873806840427957175182603343
+824290276873152640168308384248
+36092351141101218267245025967581
+39973475177812910298579659860850
+7364670182480566996610562443888661
+51592684301602944329896812066058114
+951444349069518195584787848316744461
+3234933598293500107173129970384252570
+9
+84
+802
+9765
+80115
+246589
+4463508
+85992729
+977135
+4189279533
+68755431294
+107950335674
+9675253977558
+87867459318681
+801765066192715
+2162649050595056
+2892195376814570
+134060417012729962
+7176764836888537721
+5273685153052366176
+461774434438273613889
+152344588818260411506
+11709967193759556155964
+533206453770793013516792
+2511508581949736433569969
+1573162243991468106989339
+215826582488545888127004159
+1480805837640270183994742134
+61049958584446767740466194227
+145231395106326027295263107581
+7023255505921253691380349839502
+48606431941187693512006850149822
+87214859605659588002413450479944
+7949773868584392220935704452065706
+4544031206641768922348422844031232
+37285268346623956247142903563298469
+696722030777467416877847444483018982
+6
+47
+709
+350
+45155
+117711
+6147313
+26359748
+56878412
+930721373
+47052494689
+84216331603
+1874946867051
+30417072907659
+157776263741438
+3325742508233965
+39500653878059614
+278676289794009775
+3342139004245631096
+63313724143310202591
+647891168358497623537
+5925769871143510986759
+3051401096746445704645
+761857520743586046415633
+9077595326394996332524977
+2159936754163773508122732
+426809670586105698135317225
+3294516277260755029991322796
+14749983115477586453985047494
+692100641365100970093726483540
+9502478720578852594268790479747
+9062487417784678956874793130476
+352159971921852073191742323073689
+2270803770328639487517517910897872
+35166631277333300065883628523569361
+596441689792333324819903835359197616
+6933582360405829608479430394981956723
+0
+94
+825
+907
+62512
+633399
+3539412
+65712557
+329618801
+9052319971
+50117657456
+719515050973
+396081658001
+98762199564287
+537857673363391
+5701380917944903
+16144997029797264
+918603142053856533
+4437053492025674148
+76125560050255946142
+262504846798815931770
+688599520356200914010
+77509440962809216890090
+889672321539369676198789
+5795540531885308263478299
+88374255397211092706329509
+118231692173643319720953958
+6218036129497143746927154520
+3236727278542723274070894570
+72098882691751515204435662053
+8305331942254135876823981226459
+33980292322856768815329277766669
+154632353482145519952015208333866
+192400848794451940507964192401413
+69666401739718540927805290639731997
+545814355378177567662640611917018958
+4986776343571879972263664198494529846
diff --git a/contrib/bc/tests/extra_required.txt b/contrib/bc/tests/extra_required.txt
index c498802ffaea..038e6775d644 100644
--- a/contrib/bc/tests/extra_required.txt
+++ b/contrib/bc/tests/extra_required.txt
@@ -3,6 +3,7 @@ lib2
 fib
 places
 rand
+rand_limits
 scientific
 shift
 trunc
diff --git a/contrib/bc/tests/script.sh b/contrib/bc/tests/script.sh
index fef0c5290615..c38cbabe9adc 100755
--- a/contrib/bc/tests/script.sh
+++ b/contrib/bc/tests/script.sh
@@ -190,11 +190,17 @@ else
 		exit 0
 	fi
 
-	# This sed, and the script, are to remove an incompatibility with GNU bc,
-	# where GNU bc is wrong. See the development manual
-	# (manuals/development.md#script-tests) for more information.
 	printf 'Generating %s results...' "$f"
-	printf '%s\n' "$halt" 2> /dev/null | "$d" "$s" | sed -n -f "$testdir/script.sed" > "$results"
+
+	# This particular test needs to be generated straight.
+	if [ "$d" = "dc" ] && [ "$f" = "stream.dc" ]; then
+		printf '%s\n' "$halt" 2> /dev/null | "$d" "$s" > "$results"
*** 9 LINES SKIPPED ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202305251558.34PFw36A011488>