aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2020-07-10 11:00:40 +0000
committerStefan Eßer <se@FreeBSD.org>2020-07-10 11:00:40 +0000
commitee177a09be9c81bf1c3e00326e1d38e6edb8e2a4 (patch)
treeaf0a59f24a08cefcc253c012ce216f16651e30aa
parent3960d8924a1a0ba2f0f5e8510e73a10ee20d726b (diff)
downloadsrc-ee177a09be9c81bf1c3e00326e1d38e6edb8e2a4.tar.gz
src-ee177a09be9c81bf1c3e00326e1d38e6edb8e2a4.zip
Upgrade to version 3.1.3vendor/bc/3.1.3
This version fixes an incompatibility with GNU bc.
Notes
Notes: svn path=/vendor/bc/dist/; revision=363074 svn path=/vendor/bc/3.1.3/; revision=363075; tag=vendor/bc/3.1.3
-rw-r--r--Makefile.in4
-rw-r--r--NEWS.md20
-rwxr-xr-xconfigure.sh23
-rw-r--r--include/vm.h8
-rwxr-xr-xlocale_install.sh42
-rwxr-xr-xlocale_uninstall.sh1
-rw-r--r--manuals/build.md18
-rw-r--r--src/vm.c17
-rw-r--r--tests/bc/stdin.txt1
-rw-r--r--tests/bc/stdin_results.txt1
-rwxr-xr-xtests/stdin.sh10
11 files changed, 114 insertions, 31 deletions
diff --git a/Makefile.in b/Makefile.in
index 38a3d5ea964d..2c67e92d13de 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -29,7 +29,7 @@
#
.POSIX:
-VERSION = 3.1.1
+VERSION = 3.1.3
SRC = %%SRC%%
OBJ = %%OBJ%%
@@ -335,7 +335,7 @@ clean_tests: clean clean_config clean_coverage
@$(RM) -f bc.old
install_locales:
- $(LOCALE_INSTALL) $(NLSPATH) $(MAIN_EXEC) $(DESTDIR)
+ %%INSTALL_LOCALES%%
install_bc_manpage:
$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BC_MANPAGE) $(DESTDIR)$(MAN1DIR)/$(BC_MANPAGE_NAME)
diff --git a/NEWS.md b/NEWS.md
index ef106b0460f0..64e8deb9853d 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,25 @@
# News
+## 3.1.3
+
+This is a production release that fixes one minor bug: if `bc` was invoked like
+the following, it would error:
+
+```
+echo "if (1 < 3) 1" | bc
+```
+
+Unless users run into this bug, they do not need to upgrade, but it is suggested
+that they do.
+
+## 3.1.2
+
+This is a production release that adds a way to install *all* locales. Users do
+***NOT*** need to upgrade.
+
+For package maintainers wishing to make use of the change, just pass `-l` to
+`configure.sh`.
+
## 3.1.1
This is a production release that adds two Spanish locales. Users do ***NOT***
diff --git a/configure.sh b/configure.sh
index 431af61583a7..9490787ffa21 100755
--- a/configure.sh
+++ b/configure.sh
@@ -47,12 +47,12 @@ usage() {
printf 'usage: %s -h\n' "$script"
printf ' %s --help\n' "$script"
- printf ' %s [-bD|-dB|-c] [-EfgGHMNPT] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\n' "$script"
+ printf ' %s [-bD|-dB|-c] [-EfgGHlMNPT] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\n' "$script"
printf ' %s \\\n' "$script"
printf ' [--bc-only --disable-dc|--dc-only --disable-bc|--coverage] \\\n'
printf ' [--debug --disable-extra-math --disable-generated-tests] \\\n'
printf ' [--disable-history --disable-man-pages --disable-nls] \\\n'
- printf ' [--disable-prompt --disable-strip] \\\n'
+ printf ' [--disable-prompt --disable-strip] [--install-all-locales] \\\n'
printf ' [--opt=OPT_LEVEL] [--karatsuba-len=KARATSUBA_LEN] \\\n'
printf ' [--prefix=PREFIX] [--bindir=BINDIR] [--datarootdir=DATAROOTDIR] \\\n'
printf ' [--datadir=DATADIR] [--mandir=MANDIR] [--man1dir=MAN1DIR] \\\n'
@@ -98,6 +98,10 @@ usage() {
printf ' -k KARATSUBA_LEN, --karatsuba-len KARATSUBA_LEN\n'
printf ' Set the karatsuba length to KARATSUBA_LEN (default is 64).\n'
printf ' It is an error if KARATSUBA_LEN is not a number or is less than 16.\n'
+ printf ' -l, --install-all-locales\n'
+ printf ' Installs all locales, regardless of how many are on the system. This\n'
+ printf ' option is useful for package maintainers who want to make sure that\n'
+ printf ' a package contains all of the locales that end users might need.\n'
printf ' -M, --disable-man-pages\n'
printf ' Disable installing manpages.\n'
printf ' -N, --disable-nls\n'
@@ -319,8 +323,9 @@ nls=1
prompt=1
force=0
strip_bin=1
+all_locales=0
-while getopts "bBcdDEfgGhHk:MNO:PST-" opt; do
+while getopts "bBcdDEfgGhHk:lMNO:PST-" opt; do
case "$opt" in
b) bc_only=1 ;;
@@ -335,6 +340,7 @@ while getopts "bBcdDEfgGhHk:MNO:PST-" opt; do
h) usage ;;
H) hist=0 ;;
k) karatsuba_len="$OPTARG" ;;
+ l) all_locales=1 ;;
M) install_manpages=0 ;;
N) nls=0 ;;
O) optimization="$OPTARG" ;;
@@ -423,6 +429,7 @@ while getopts "bBcdDEfgGhHk:MNO:PST-" opt; do
disable-nls) nls=0 ;;
disable-prompt) prompt=0 ;;
disable-strip) strip_bin=0 ;;
+ install-all-locales) all_locales=1 ;;
help* | bc-only* | dc-only* | coverage* | debug*)
usage "No arg allowed for --$arg option" ;;
disable-bc* | disable-dc* | disable-extra-math*)
@@ -431,6 +438,8 @@ while getopts "bBcdDEfgGhHk:MNO:PST-" opt; do
usage "No arg allowed for --$arg option" ;;
disable-man-pages* | disable-nls* | disable-strip*)
usage "No arg allowed for --$arg option" ;;
+ install-all-locales*)
+ usage "No arg allowed for --$arg option" ;;
'') break ;; # "--" terminates argument processing
* ) usage "Invalid option $LONG_OPTARG" ;;
esac
@@ -751,6 +760,13 @@ if [ "$nls" -ne 0 ]; then
else
install_locales_prereqs=""
uninstall_locales_prereqs=""
+ all_locales=0
+fi
+
+if [ "$nls" -ne 0 ] && [ "$all_locales" -ne 0 ]; then
+ install_locales="\$(LOCALE_INSTALL) -l \$(NLSPATH) \$(MAIN_EXEC) \$(DESTDIR)"
+else
+ install_locales="\$(LOCALE_INSTALL) \$(NLSPATH) \$(MAIN_EXEC) \$(DESTDIR)"
fi
if [ "$hist" -eq 1 ]; then
@@ -911,6 +927,7 @@ contents=$(replace "$contents" "HOSTCC" "$HOSTCC")
contents=$(replace "$contents" "COVERAGE_OUTPUT" "$COVERAGE_OUTPUT")
contents=$(replace "$contents" "COVERAGE_PREREQS" "$COVERAGE_PREREQS")
contents=$(replace "$contents" "INSTALL_PREREQS" "$install_prereqs")
+contents=$(replace "$contents" "INSTALL_LOCALES" "$install_locales")
contents=$(replace "$contents" "INSTALL_LOCALES_PREREQS" "$install_locales_prereqs")
contents=$(replace "$contents" "UNINSTALL_MAN_PREREQS" "$uninstall_man_prereqs")
contents=$(replace "$contents" "UNINSTALL_PREREQS" "$uninstall_prereqs")
diff --git a/include/vm.h b/include/vm.h
index 7f4359c640d3..cdadfc8bed13 100644
--- a/include/vm.h
+++ b/include/vm.h
@@ -112,10 +112,10 @@
#if BC_ENABLED
-#define BC_S (BC_ENABLED && (vm.flags & BC_FLAG_S))
-#define BC_W (BC_ENABLED && (vm.flags & BC_FLAG_W))
-#define BC_L (BC_ENABLED && (vm.flags & BC_FLAG_L))
-#define BC_G (BC_ENABLED && (vm.flags & BC_FLAG_G))
+#define BC_S (vm.flags & BC_FLAG_S)
+#define BC_W (vm.flags & BC_FLAG_W)
+#define BC_L (vm.flags & BC_FLAG_L)
+#define BC_G (vm.flags & BC_FLAG_G)
#endif // BC_ENABLED
diff --git a/locale_install.sh b/locale_install.sh
index cdd41ef37ff8..38863d2b2969 100755
--- a/locale_install.sh
+++ b/locale_install.sh
@@ -28,6 +28,9 @@
#
usage() {
+ if [ $# -eq 1 ]; then
+ printf '%s\n' "$1"
+ fi
printf "usage: %s NLSPATH main_exec [DESTDIR]\n" "$0" 1>&2
exit 1
}
@@ -150,6 +153,17 @@ scriptdir=$(dirname "$script")
. "$scriptdir/functions.sh"
+all_locales=0
+
+while getopts "l" opt; do
+
+ case "$opt" in
+ l) all_locales=1 ; shift ;;
+ ?) usage "Invalid option $opt" ;;
+ esac
+
+done
+
test "$#" -ge 2 || usage
nlspath="$1"
@@ -180,19 +194,23 @@ fi
for file in $locales_dir/*.msg; do
locale=$(basename "$file" ".msg")
- loc=$(gen_nlspath "$destdir/$nlspath" "$locale" "$main_exec")
- localeexists "$locales" "$locale" "$destdir"
- err="$?"
+ if [ "$all_locales" -eq 0 ]; then
- if [ "$err" -eq 0 ]; then
- continue
+ localeexists "$locales" "$locale" "$destdir"
+ err="$?"
+
+ if [ "$err" -eq 0 ]; then
+ continue
+ fi
fi
if [ -L "$file" ]; then
continue
fi
+ loc=$(gen_nlspath "$destdir/$nlspath" "$locale" "$main_exec")
+
gencatfile "$loc" "$file"
done
@@ -200,15 +218,19 @@ done
for file in $locales_dir/*.msg; do
locale=$(basename "$file" ".msg")
- loc=$(gen_nlspath "$destdir/$nlspath" "$locale" "$main_exec")
- localeexists "$locales" "$locale" "$destdir"
- err="$?"
+ if [ "$all_locales" -eq 0 ]; then
- if [ "$err" -eq 0 ]; then
- continue
+ localeexists "$locales" "$locale" "$destdir"
+ err="$?"
+
+ if [ "$err" -eq 0 ]; then
+ continue
+ fi
fi
+ loc=$(gen_nlspath "$destdir/$nlspath" "$locale" "$main_exec")
+
mkdir -p $(dirname "$loc")
if [ -L "$file" ]; then
diff --git a/locale_uninstall.sh b/locale_uninstall.sh
index 43facb33cd90..d38a5470e791 100755
--- a/locale_uninstall.sh
+++ b/locale_uninstall.sh
@@ -59,6 +59,7 @@ fi
# This way, we can delete catalogs for locales that we had to install
# because they are symlinks.
locales=$(gen_nlspath "$destdir/$nlspath" "*" "$main_exec")
+locales=$(ls $locales 2> /dev/null)
for l in $locales; do
rm -f "$l"
diff --git a/manuals/build.md b/manuals/build.md
index 3d0c0132fb85..906551cc73ac 100644
--- a/manuals/build.md
+++ b/manuals/build.md
@@ -366,18 +366,18 @@ can be disabled permanently in the build by passing the `-P` flag or the
Both commands are equivalent.
-### Long Options
+### Locales
-By default, `bc` and `dc` support long options like `--mathlib` and
-`--interactive`. However, support for these options requires `getopt_long()`
-which is not in the POSIX standard. For those platforms that do *not* have
-`getopt_long()` it will be disabled automatically, or if you wish to disable
-them regardless, you can pass the `-L` flag or the `--disable-long-options`
-option to `configure.sh`, as follows:
+By default, `bc` and `dc` do not install all locales, but only the enabled
+locales. If `DESTDIR` exists and is not empty, then they will install all of
+the locales that exist on the system. The `-l` flag or `--install-all-locales`
+option skips all of that and just installs all of the locales that `bc` and `dc`
+have, regardless. To enable that behavior, you can pass the `-l` flag or the
+`--install-all-locales` option to `configure.sh`, as follows:
```
-./configure.sh -L
-./configure.sh --disable-long-options
+./configure.sh -l
+./configure.sh --install-all-locales
```
Both commands are equivalent.
diff --git a/src/vm.c b/src/vm.c
index b3dee16b2e28..905613563e8d 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -602,8 +602,21 @@ restart:
else if (BC_ERR(string))
bc_parse_err(&vm.prs, BC_ERROR_PARSE_STRING);
#if BC_ENABLED
- else if (BC_IS_BC && BC_ERR(BC_PARSE_NO_EXEC(&vm.prs)))
- bc_parse_err(&vm.prs, BC_ERROR_PARSE_BLOCK);
+ else if (BC_IS_BC && BC_ERR(BC_PARSE_NO_EXEC(&vm.prs))) {
+
+ size_t i;
+ bool good = true;
+
+ for (i = 0; good && i < vm.prs.flags.len; ++i) {
+ uint16_t flag = *((uint16_t*) bc_vec_item(&vm.prs.flags, i));
+ good = ((flag & BC_PARSE_FLAG_BRACE) != BC_PARSE_FLAG_BRACE);
+ }
+
+ if (good) {
+ while (BC_PARSE_IF_END(&vm.prs)) bc_vm_process("else {}", true);
+ }
+ else bc_parse_err(&vm.prs, BC_ERROR_PARSE_BLOCK);
+ }
#endif // BC_ENABLED
}
diff --git a/tests/bc/stdin.txt b/tests/bc/stdin.txt
index 7ddb905dca47..c9d12a6e4839 100644
--- a/tests/bc/stdin.txt
+++ b/tests/bc/stdin.txt
@@ -13,3 +13,4 @@
i = 4
read()
i *= 5
+if (1 < 3) 1
diff --git a/tests/bc/stdin_results.txt b/tests/bc/stdin_results.txt
index 89dba6613b67..298fdddff604 100644
--- a/tests/bc/stdin_results.txt
+++ b/tests/bc/stdin_results.txt
@@ -4,3 +4,4 @@ String /* with partial commentString /* with full comment */3
7
String with a # hash comment3
20
+1
diff --git a/tests/stdin.sh b/tests/stdin.sh
index 7b821d749ba9..f66019d5ae65 100755
--- a/tests/stdin.sh
+++ b/tests/stdin.sh
@@ -65,9 +65,17 @@ rm -f "$out"
printf 'Running %s stdin tests...' "$d"
cat "$testdir/$d/stdin.txt" | "$exe" "$@" "$options" > "$out" 2> /dev/null
-
diff "$testdir/$d/stdin_results.txt" "$out"
+if [ "$d" = "bc" ]; then
+
+ cat "$testdir/$d/stdin1.txt" | "$exe" "$@" "$options" > "$out" 2> /dev/null
+ diff "$testdir/$d/stdin1_results.txt" "$out"
+
+ cat "$testdir/$d/stdin2.txt" | "$exe" "$@" "$options" > "$out" 2> /dev/null
+ diff "$testdir/$d/stdin2_results.txt" "$out"
+fi
+
rm -f "$out1"
printf 'pass\n'