aboutsummaryrefslogtreecommitdiff
path: root/contrib/bc/tests/fuzzing/bc_inputs1/array.bc
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2021-01-31 19:56:48 +0000
committerStefan Eßer <se@FreeBSD.org>2021-02-05 21:01:25 +0000
commit106efdb060ae523a88caf5ddc3516500cf5b1d64 (patch)
treee34ca4e157299d283098b5f309feb1da323e73b9 /contrib/bc/tests/fuzzing/bc_inputs1/array.bc
parentbf77fadc22c4c73f5e300309551e07c48bbe3a86 (diff)
downloadsrc-106efdb060ae523a88caf5ddc3516500cf5b1d64.tar.gz
src-106efdb060ae523a88caf5ddc3516500cf5b1d64.zip
Vendor import of Gavin Howard's bc version 3.2.6
(cherry picked from commit 47a52dc4d48f259ab7d9f9ba6b65f4f2331a22dc) Second attempt after revert of a previous commit that affected files with similar names in unrelated directories. Thanks go to Martin Birgmaier for reporting the issue and identifying the cause of git getting confused: files from the root of the vendor files were associated with files in the FreeBSD base root directory. Martin Birgmaier points out that to make this cherry-pick succeed, the option -Xsubtree=contrib/bc has to be passed to prevent files outside that path to be considered.
Diffstat (limited to 'contrib/bc/tests/fuzzing/bc_inputs1/array.bc')
-rwxr-xr-xcontrib/bc/tests/fuzzing/bc_inputs1/array.bc60
1 files changed, 60 insertions, 0 deletions
diff --git a/contrib/bc/tests/fuzzing/bc_inputs1/array.bc b/contrib/bc/tests/fuzzing/bc_inputs1/array.bc
new file mode 100755
index 000000000000..dac232804914
--- /dev/null
+++ b/contrib/bc/tests/fuzzing/bc_inputs1/array.bc
@@ -0,0 +1,60 @@
+#! /usr/bin/bc -q
+
+define z(a[]) {
+ for (i = 0; i < l; ++i) {
+ a[i]
+ }
+}
+
+define x(a[]) {
+
+ # Test for separate vars and arrays.
+ auto a
+
+ for (a = 0; a < l; ++a) {
+ a[a] = -a
+ }
+
+ z(a[])
+}
+
+define g(x[], y[]) {
+ return x[0] - y[0]
+}
+
+define h(y[], x[]) {
+ return g(x[], y[])
+}
+
+define m(*x[], *y[]) {
+ return x[0] / y[0]
+}
+
+define n(*y[], *x[]) {
+ return m(x[], y[])
+}
+
+for (i = 0; i < 101; ++i) {
+ a[i] = i
+}
+
+a[104] = 204
+
+l = length(a[])
+
+for (i = 0; i <= l; ++i) {
+ a[i]
+}
+
+z(a[])
+x(a[])
+z(a[])
+l
+
+x[0] = 5
+y[0] = 4
+
+h(x[], y[])
+n(x[], y[])
+
+halt