diff --git a/Makefile.in b/Makefile.in
index c3a41854fe9e..3d6780d6ac95 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -280,17 +280,25 @@ help:
@printf ' valgrind_dc runs the dc test suite, if dc has been built,\n'
@printf ' through valgrind\n'
-run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests history_all_tests
+run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests
+
+run_all_tests_np: bc_all_tests_np timeconst_all_tests dc_all_tests_np
bc_all_tests:
%%BC_ALL_TESTS%%
+bc_all_tests_np:
+ %%BC_ALL_TESTS_NP%%
+
timeconst_all_tests:
%%TIMECONST_ALL_TESTS%%
dc_all_tests:
%%DC_ALL_TESTS%%
+dc_all_tests_np:
+ %%DC_ALL_TESTS_NP%%
+
history_all_tests:
%%HISTORY_TESTS%%
@@ -311,7 +319,9 @@ test_bc_stdin:
test_bc_read:
@sh tests/read.sh bc %%BC_TEST_EXEC%%
-test_bc_errors:
+test_bc_errors: test_bc_error_lines%%BC_ERROR_TESTS%%
+
+test_bc_error_lines:
@sh tests/errors.sh bc %%BC_TEST_EXEC%%
test_bc_other:
@@ -333,7 +343,9 @@ test_dc_stdin:
test_dc_read:
@sh tests/read.sh dc %%DC_TEST_EXEC%%
-test_dc_errors:
+test_dc_errors: test_dc_error_lines%%DC_ERROR_TESTS%%
+
+test_dc_error_lines:
@sh tests/errors.sh dc %%DC_TEST_EXEC%%
test_dc_other:
diff --git a/NEWS.md b/NEWS.md
index f35d593b807a..98b52024b2e8 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,23 @@
# News
+## 5.1.0
+
+This is a production release with some fixes and new features.
+
+* Fixed a bug where an `if` statement without an `else` before defining a
+ function caused an error.
+* Fixed a bug with the `bc` banner and `-q`.
+* Fixed a bug on Windows where files were not read correctly.
+* Added a command-line flag (`-z`) to make `bc` and `dc` print leading zeroes on
+ numbers `-1 < x < 1`.
+* Added four functions to `lib2.bc` (`plz()`, `plznl()`, `pnlz()`, and
+ `pnlznl()`) to allow printing numbers with or without leading zeros, despite
+ the use of `-z` or not.
+* Added builtin functions to query global state like line length, global stacks,
+ and leading zeroes.
+* Added a command-line flag (`-L`) to disable wrapping when printing numbers.
+* Improved builds on Windows.
+
## 5.0.2
This is a production release with one fix for a flaky test. If you have not
diff --git a/bc.vcxproj b/bc.vcxproj
deleted file mode 100644
index 8d4f34a2a0e6..000000000000
--- a/bc.vcxproj
+++ /dev/null
@@ -1,278 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 16.0
- {D5086CFE-052C-4742-B005-E05DB983BBA2}
- Win32Proj
-
-
-
- Application
- true
- v142
-
-
- Application
- false
- v142
-
-
- Application
- true
- v142
-
-
- Application
- false
- v142
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Building strgen
- CL /Fo:$(Configuration)\$(Platform)\$(ProjectName)\ /Fe:$(Configuration)\$(Platform)\$(ProjectName)\strgen.exe gen\strgen.c
- gen\strgen.c
- $(Configuration)\$(Platform)\$(ProjectName)\strgen.exe
-
-
- Generating $(Configuration)\$(Platform)\$(ProjectName)/lib.c
- START $(Configuration)\$(Platform)\$(ProjectName)/strgen gen\lib.bc $(Configuration)\$(Platform)\$(ProjectName)/lib.c bc_lib bc_lib_name BC_ENABLED 1
- $(Configuration)\$(Platform)\$(ProjectName)\strgen.exe;gen\lib.bc
- $(Configuration)\$(Platform)\$(ProjectName)\lib.c
-
-
- Generating $(Configuration)\$(Platform)\$(ProjectName)/lib2.c
- START $(Configuration)\$(Platform)\$(ProjectName)/strgen gen\lib2.bc $(Configuration)\$(Platform)\$(ProjectName)/lib2.c bc_lib2 bc_lib2_name BC_ENABLED 1
- $(Configuration)\$(Platform)\$(ProjectName)\strgen.exe;gen\lib2.bc
- $(Configuration)\$(Platform)\$(ProjectName)\lib2.c
-
-
- Generating $(Configuration)\$(Platform)\$(ProjectName)/bc_help.c
- START $(Configuration)\$(Platform)\$(ProjectName)/strgen gen\bc_help.txt $(Configuration)\$(Platform)\$(ProjectName)\bc_help.c bc_help "" BC_ENABLED
- $(Configuration)\$(Platform)\$(ProjectName)\strgen.exe;gen\bc_help.txt
- $(Configuration)\$(Platform)\$(ProjectName)\bc_help.c
-
-
- Generating $(Configuration)\$(Platform)\$(ProjectName)/dc_help.c
- START $(Configuration)\$(Platform)\$(ProjectName)/strgen gen\dc_help.txt $(Configuration)\$(Platform)\$(ProjectName)\dc_help.c dc_help "" DC_ENABLED
- $(Configuration)\$(Platform)\$(ProjectName)\strgen.exe;gen\dc_help.txt
- $(Configuration)\$(Platform)\$(ProjectName)\dc_help.c
-
-
-
- ClCompile
-
-
-
- true
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
-
-
- false
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
-
-
- true
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
-
-
- false
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
-
-
-
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=1;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=N;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1
- $(SolutionDir)\include;%(AdditionalIncludeDirectories)
- MultiThreadedDebugDLL
- Level3
- ProgramDatabase
- Disabled
- false
- /W3 %(AdditionalOptions)
-
-
- MachineX86
- DebugFastLink
- Console
- kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies)
-
-
- copy /b "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\dc.exe"
-
-
- Copying bc to dc...
-
-
-
-
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=1;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=N;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1
- $(SolutionDir)\include;%(AdditionalIncludeDirectories)
- MultiThreadedDLL
- Level3
- ProgramDatabase
- MaxSpeed
- false
- /W3 %(AdditionalOptions)
-
-
- MachineX86
- false
- Console
- kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies)
- true
- true
-
-
- copy /b "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\dc.exe"
-
-
- Copying bc to dc...
-
-
-
-
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=1;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=N;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1
- $(SolutionDir)\include;%(AdditionalIncludeDirectories)
- MultiThreadedDebugDLL
- Level3
- ProgramDatabase
- Disabled
- false
- /W3 %(AdditionalOptions)
-
-
- MachineX64
- true
- Console
- kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies)
-
-
- copy /b "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\dc.exe"
-
-
- Copying bc to dc...
-
-
-
-
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=1;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=N;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1
- $(SolutionDir)\include;%(AdditionalIncludeDirectories)
- MultiThreadedDLL
- Level3
- ProgramDatabase
- MaxSpeed
- false
- /W3 %(AdditionalOptions)
- Default
-
-
- MachineX64
- DebugFastLink
- Console
- kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies)
-
-
- copy /b "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\dc.exe"
-
-
- Copying bc to dc...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/bc.vcxproj.filters b/bc.vcxproj.filters
deleted file mode 100644
index 141ecb808d08..000000000000
--- a/bc.vcxproj.filters
+++ /dev/null
@@ -1,182 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
-
-
- Source Files
-
-
-
-
-
-
-
-
-
-
-
-
- Resource Files
-
-
- Resource Files
-
-
-
-
- Resource Files
-
-
- Resource Files
-
-
-
\ No newline at end of file
diff --git a/bcl.sln b/bcl.sln
deleted file mode 100644
index 77009a439db3..000000000000
--- a/bcl.sln
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.31129.286
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bcl", "bcl.vcxproj", "{D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Debug|x64.ActiveCfg = Debug|x64
- {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Debug|x64.Build.0 = Debug|x64
- {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Debug|x86.ActiveCfg = Debug|Win32
- {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Debug|x86.Build.0 = Debug|Win32
- {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Release|x64.ActiveCfg = Release|x64
- {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Release|x64.Build.0 = Release|x64
- {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Release|x86.ActiveCfg = Release|Win32
- {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {591735E0-C314-4BFF-A595-E9999B49CB25}
- EndGlobalSection
-EndGlobal
diff --git a/bcl.vcxproj b/bcl.vcxproj
deleted file mode 100644
index c1031045e34a..000000000000
--- a/bcl.vcxproj
+++ /dev/null
@@ -1,161 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 16.0
- {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}
- Win32Proj
- 10.0
-
-
-
- StaticLibrary
- true
- v142
-
-
- StaticLibrary
- false
- v142
-
-
- StaticLibrary
- true
- v142
-
-
- StaticLibrary
- false
- v142
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
-
-
- true
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
-
-
- true
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
-
-
- true
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
- $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\
-
-
-
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1
- MultiThreadedDebugDLL
- Level3
- ProgramDatabase
- Disabled
- $(SolutionDir)\include
-
-
- MachineX86
- true
- Windows
-
-
-
-
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1
- MultiThreadedDLL
- Level3
- ProgramDatabase
- $(SolutionDir)\include
-
-
- MachineX86
- true
- Windows
- true
- true
-
-
-
-
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1
- $(SolutionDir)\include
-
-
-
-
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1
- $(SolutionDir)\include
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/bcl.vcxproj.filters b/bcl.vcxproj.filters
deleted file mode 100644
index f75e0331cc88..000000000000
--- a/bcl.vcxproj.filters
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
-
\ No newline at end of file
diff --git a/configure.sh b/configure.sh
index bcc8688e0ec1..de1339780073 100755
--- a/configure.sh
+++ b/configure.sh
@@ -446,35 +446,35 @@ gen_file_list() {
# @param extra_math An integer that, if non-zero, activates extra math tests.
# @param time_tests An integer that, if non-zero, tells the test suite to time
# the execution of each test.
-gen_tests() {
+gen_std_tests() {
- _gen_tests_name="$1"
+ _gen_std_tests_name="$1"
shift
- _gen_tests_extra_math="$1"
+ _gen_std_tests_extra_math="$1"
shift
- _gen_tests_time_tests="$1"
+ _gen_std_tests_time_tests="$1"
shift
- _gen_tests_extra_required=$(cat "$scriptdir/tests/extra_required.txt")
+ _gen_std_tests_extra_required=$(cat "$scriptdir/tests/extra_required.txt")
- for _gen_tests_t in $(cat "$scriptdir/tests/$_gen_tests_name/all.txt"); do
+ for _gen_std_tests_t in $(cat "$scriptdir/tests/$_gen_std_tests_name/all.txt"); do
- if [ "$_gen_tests_extra_math" -eq 0 ]; then
+ if [ "$_gen_std_tests_extra_math" -eq 0 ]; then
- if [ -z "${_gen_tests_extra_required##*$_gen_tests_t*}" ]; then
+ if [ -z "${_gen_std_tests_extra_required##*$_gen_std_tests_t*}" ]; then
printf 'test_%s_%s:\n\t@printf "Skipping %s %s\\n"\n\n' \
- "$_gen_tests_name" "$_gen_tests_t" "$_gen_tests_name" \
- "$_gen_tests_t" >> "$scriptdir/Makefile"
+ "$_gen_std_tests_name" "$_gen_std_tests_t" "$_gen_std_tests_name" \
+ "$_gen_std_tests_t" >> "$scriptdir/Makefile"
continue
fi
fi
printf 'test_%s_%s:\n\t@sh tests/test.sh %s %s %s %s %s\n\n' \
- "$_gen_tests_name" "$_gen_tests_t" "$_gen_tests_name" \
- "$_gen_tests_t" "$generate_tests" "$time_tests" \
+ "$_gen_std_tests_name" "$_gen_std_tests_t" "$_gen_std_tests_name" \
+ "$_gen_std_tests_t" "$generate_tests" "$time_tests" \
"$*" >> "$scriptdir/Makefile"
done
@@ -484,15 +484,55 @@ gen_tests() {
# targets.
#
# @param name The name of the calculator to generate test targets for.
-gen_test_targets() {
+gen_std_test_targets() {
- _gen_test_targets_name="$1"
+ _gen_std_test_targets_name="$1"
shift
- _gen_test_targets_tests=$(cat "$scriptdir/tests/${_gen_test_targets_name}/all.txt")
+ _gen_std_test_targets_tests=$(cat "$scriptdir/tests/${_gen_std_test_targets_name}/all.txt")
- for _gen_test_targets_t in $_gen_test_targets_tests; do
- printf ' test_%s_%s' "$_gen_test_targets_name" "$_gen_test_targets_t"
+ for _gen_std_test_targets_t in $_gen_std_test_targets_tests; do
+ printf ' test_%s_%s' "$_gen_std_test_targets_name" "$_gen_std_test_targets_t"
+ done
+
+ printf '\n'
+}
+
+# Generates the proper test targets for each error test to have its own target.
+# This allows `make test_bc_errors` and `make test_dc_errors` to run in
+# parallel.
+#
+# @param name Which calculator to generate tests for.
+gen_err_tests() {
+
+ _gen_err_tests_name="$1"
+ shift
+
+ _gen_err_tests_fs=$(ls "$scriptdir/tests/$_gen_err_tests_name/errors/")
+
+ for _gen_err_tests_t in $_gen_err_tests_fs; do
+
+ printf 'test_%s_error_%s:\n\t@sh tests/error.sh %s %s %s\n\n' \
+ "$_gen_err_tests_name" "$_gen_err_tests_t" "$_gen_err_tests_name" \
+ "$_gen_err_tests_t" "$*" >> "$scriptdir/Makefile"
+
+ done
+
+}
+
+# Generates a list of error test targets that will be used as prerequisites for
+# other targets.
+#
+# @param name The name of the calculator to generate test targets for.
+gen_err_test_targets() {
+
+ _gen_err_test_targets_name="$1"
+ shift
+
+ _gen_err_test_targets_tests=$(ls "$scriptdir/tests/$_gen_err_test_targets_name/errors/")
+
+ for _gen_err_test_targets_t in $_gen_err_test_targets_tests; do
+ printf ' test_%s_error_%s' "$_gen_err_test_targets_name" "$_gen_err_test_targets_t"
done
printf '\n'
@@ -904,10 +944,12 @@ link="@printf 'No link necessary\\\\n'"
main_exec="BC"
executable="BC_EXEC"
-tests="test_bc timeconst test_dc test_history"
+tests="test_bc timeconst test_dc"
bc_test="@tests/all.sh bc $extra_math 1 $generate_tests $time_tests \$(BC_EXEC)"
+bc_test_np="@tests/all.sh -n bc $extra_math 1 $generate_tests $time_tests \$(BC_EXEC)"
dc_test="@tests/all.sh dc $extra_math 1 $generate_tests $time_tests \$(DC_EXEC)"
+dc_test_np="@tests/all.sh -n dc $extra_math 1 $generate_tests $time_tests \$(DC_EXEC)"
timeconst="@tests/bc/timeconst.sh tests/bc/scripts/timeconst.bc \$(BC_EXEC)"
@@ -967,6 +1009,7 @@ elif [ "$bc_only" -eq 1 ]; then
executables="bc"
dc_test="@printf 'No dc tests to run\\\\n'"
+ dc_test_np="@printf 'No dc tests to run\\\\n'"
test_dc_history_prereqs=" test_dc_history_skip"
install_prereqs=" install_execs"
@@ -976,7 +1019,7 @@ elif [ "$bc_only" -eq 1 ]; then
default_target="\$(BC_EXEC)"
second_target="\$(DC_EXEC)"
- tests="test_bc timeconst test_history"
+ tests="test_bc timeconst"
elif [ "$dc_only" -eq 1 ]; then
@@ -992,6 +1035,7 @@ elif [ "$dc_only" -eq 1 ]; then
executable="DC_EXEC"
bc_test="@printf 'No bc tests to run\\\\n'"
+ bc_test_np="@printf 'No bc tests to run\\\\n'"
test_bc_history_prereqs=" test_bc_history_skip"
timeconst="@printf 'timeconst cannot be run because bc is not built\\\\n'"
@@ -1001,7 +1045,7 @@ elif [ "$dc_only" -eq 1 ]; then
uninstall_prereqs=" uninstall_dc"
uninstall_man_prereqs=" uninstall_dc_manpage"
- tests="test_dc test_history"
+ tests="test_dc"
else
@@ -1392,10 +1436,12 @@ if [ "$dc_default_prompt" = "" ]; then
fi
# Generate the test targets and prerequisites.
-bc_tests=$(gen_test_targets bc)
+bc_tests=$(gen_std_test_targets bc)
bc_script_tests=$(gen_script_test_targets bc)
-dc_tests=$(gen_test_targets dc)
+bc_err_tests=$(gen_err_test_targets bc)
+dc_tests=$(gen_std_test_targets dc)
dc_script_tests=$(gen_script_test_targets dc)
+dc_err_tests=$(gen_err_test_targets dc)
# Print out the values; this is for debugging.
if [ "$bc" -ne 0 ]; then
@@ -1483,14 +1529,18 @@ contents=$(replace "$contents" "BC_ENABLED" "$bc")
contents=$(replace "$contents" "DC_ENABLED" "$dc")
contents=$(replace "$contents" "BC_ALL_TESTS" "$bc_test")
+contents=$(replace "$contents" "BC_ALL_TESTS_NP" "$bc_test_np")
contents=$(replace "$contents" "BC_TESTS" "$bc_tests")
contents=$(replace "$contents" "BC_SCRIPT_TESTS" "$bc_script_tests")
+contents=$(replace "$contents" "BC_ERROR_TESTS" "$bc_err_tests")
contents=$(replace "$contents" "BC_TEST_EXEC" "$bc_test_exec")
contents=$(replace "$contents" "TIMECONST_ALL_TESTS" "$timeconst")
contents=$(replace "$contents" "DC_ALL_TESTS" "$dc_test")
+contents=$(replace "$contents" "DC_ALL_TESTS_NP" "$dc_test_np")
contents=$(replace "$contents" "DC_TESTS" "$dc_tests")
contents=$(replace "$contents" "DC_SCRIPT_TESTS" "$dc_script_tests")
+contents=$(replace "$contents" "DC_ERROR_TESTS" "$dc_err_tests")
contents=$(replace "$contents" "DC_TEST_EXEC" "$dc_test_exec")
contents=$(replace "$contents" "BUILD_TYPE" "$manpage_args")
@@ -1551,9 +1601,7 @@ contents=$(replace "$contents" "MAIN_EXEC" "$main_exec")
contents=$(replace "$contents" "EXEC" "$executable")
contents=$(replace "$contents" "TESTS" "$tests")
-contents=$(replace "$contents" "BC_TEST" "$bc_test")
contents=$(replace "$contents" "BC_HISTORY_TEST_PREREQS" "$test_bc_history_prereqs")
-contents=$(replace "$contents" "DC_TEST" "$dc_test")
contents=$(replace "$contents" "DC_HISTORY_TEST_PREREQS" "$test_dc_history_prereqs")
contents=$(replace "$contents" "HISTORY_TESTS" "$history_tests")
@@ -1588,13 +1636,15 @@ printf '%s\n%s\n\n' "$contents" "$SRC_TARGETS" > "$scriptdir/Makefile"
# Generate the individual test targets.
if [ "$bc" -ne 0 ]; then
- gen_tests bc "$extra_math" "$time_tests" $bc_test_exec
+ gen_std_tests bc "$extra_math" "$time_tests" $bc_test_exec
gen_script_tests bc "$extra_math" "$generate_tests" "$time_tests" $bc_test_exec
+ gen_err_tests bc $bc_test_exec
fi
if [ "$dc" -ne 0 ]; then
- gen_tests dc "$extra_math" "$time_tests" $dc_test_exec
+ gen_std_tests dc "$extra_math" "$time_tests" $dc_test_exec
gen_script_tests dc "$extra_math" "$generate_tests" "$time_tests" $dc_test_exec
+ gen_err_tests dc $dc_test_exec
fi
cd "$scriptdir"
diff --git a/gen/bc_help.txt b/gen/bc_help.txt
index 50c38ab61314..9ba34c606481 100644
--- a/gen/bc_help.txt
+++ b/gen/bc_help.txt
@@ -86,6 +86,10 @@ Options:
Force interactive mode.
+ -L --no-line-length
+
+ Disable line length checking.
+
-l --mathlib
Use predefined math routines:
@@ -135,6 +139,10 @@ Options:
Print version information and copyright and exit.
+ -z --leading-zeroes
+
+ Enable leading zeroes on numbers greater than -1 and less than 1.
+
Environment variables:
POSIXLY_CORRECT
@@ -148,7 +156,7 @@ Environment variables:
BC_LINE_LENGTH
If an integer, the number of characters to print on a line before
- wrapping.
+ wrapping. Using 0 will disable line length checking.
BC_BANNER
diff --git a/gen/dc_help.txt b/gen/dc_help.txt
index c0bf34daeb46..4cf10826cd7f 100644
--- a/gen/dc_help.txt
+++ b/gen/dc_help.txt
@@ -89,6 +89,10 @@ Options:
Put dc into interactive mode. See the man page for more details.
+ -L --no-line-length
+
+ Disable line length checking.
+
-P --no-prompt
Disable the prompts in interactive mode.
@@ -105,6 +109,10 @@ Options:
Enable extended register mode.
+ -z --leading-zeroes
+
+ Enable leading zeroes on numbers greater than -1 and less than 1.
+
Environment variables:
DC_ENV_ARGS
@@ -114,7 +122,7 @@ Environment variables:
DC_LINE_LENGTH
If an integer, the number of characters to print on a line before
- wrapping.
+ wrapping. Using 0 will disable line length checking.
DC_SIGINT_RESET
diff --git a/gen/lib2.bc b/gen/lib2.bc
index 93df1889eb63..23cbec104d02 100644
--- a/gen/lib2.bc
+++ b/gen/lib2.bc
@@ -274,6 +274,42 @@ define s2un(x,n){
return x
}
define s2u(x){return s2un(x,sbytes(x))}
+define void plz(x){
+ if(leading_zero())print x
+ else{
+ if(x>-1&&x<1&&x!=0){
+ if(x<0)print"-"
+ print 0,abs(x)
+ }
+ else print x
+ }
+}
+define void plznl(x){
+ plz(x)
+ print"\n"
+}
+define void pnlz(x){
+ auto s,i
+ if(leading_zero()){
+ if(x>-1&&x<1&&x!=0){
+ s=scale(x)
+ if(x<0)print"-"
+ print"."
+ x=abs(x)
+ for(i=0;il.t == BC_LEX_KW_DEFINE) {
- if (BC_ERR(BC_PARSE_NO_EXEC(p)))
- bc_parse_err(p, BC_ERR_PARSE_TOKEN);
+ if (BC_ERR(BC_PARSE_NO_EXEC(p))) {
+ if (p->flags.len == 1 &&
+ BC_PARSE_TOP_FLAG(p) == BC_PARSE_FLAG_IF_END)
+ {
+ bc_parse_noElse(p);
+ }
+ else bc_parse_err(p, BC_ERR_PARSE_TOKEN);
+ }
bc_parse_func(p);
}
@@ -2078,6 +2087,9 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
#if BC_ENABLE_EXTRA_MATH
case BC_LEX_KW_MAXRAND:
#endif // BC_ENABLE_EXTRA_MATH
+ case BC_LEX_KW_LINE_LENGTH:
+ case BC_LEX_KW_GLOBAL_STACKS:
+ case BC_LEX_KW_LEADING_ZERO:
{
// All of these are leaves and cannot come right after a leaf.
if (BC_ERR(BC_PARSE_LEAF(prev, bin_last, rprn)))
diff --git a/src/data.c b/src/data.c
index 0eaf7d699f7d..82475299ed78 100644
--- a/src/data.c
+++ b/src/data.c
@@ -141,6 +141,8 @@ const BcOptLong bc_args_lopt[] = {
{ "file", BC_OPT_REQUIRED, 'f' },
{ "help", BC_OPT_NONE, 'h' },
{ "interactive", BC_OPT_NONE, 'i' },
+ { "leading-zeroes", BC_OPT_NONE, 'z' },
+ { "no-line-length", BC_OPT_NONE, 'L' },
{ "no-prompt", BC_OPT_NONE, 'P' },
{ "no-read-prompt", BC_OPT_NONE, 'R' },
#if BC_ENABLED
@@ -873,6 +875,9 @@ const BcLexKeyword bc_lex_kws[] = {
#if BC_ENABLE_EXTRA_MATH
BC_LEX_KW_ENTRY("maxrand", 7, false),
#endif // BC_ENABLE_EXTRA_MATH
+ BC_LEX_KW_ENTRY("line_length", 11, false),
+ BC_LEX_KW_ENTRY("global_stacks", 13, false),
+ BC_LEX_KW_ENTRY("leading_zero", 12, false),
BC_LEX_KW_ENTRY("stream", 6, false),
BC_LEX_KW_ENTRY("else", 4, false),
};
@@ -928,7 +933,10 @@ const uint8_t bc_parse_exprs[] = {
BC_PARSE_EXPR_ENTRY(true, true, true, true, true, true, false, true),
// Starts with BC_LEX_KW_MAXIBASE.
- BC_PARSE_EXPR_ENTRY(true, true, true, true, true, false, false, 0)
+ BC_PARSE_EXPR_ENTRY(true, true, true, true, true, true, true, true),
+
+ // Starts with BC_LEX_KW_STREAM.
+ BC_PARSE_EXPR_ENTRY(false, false, 0, 0, 0, 0, 0, 0)
#else // BC_ENABLE_EXTRA_MATH
@@ -948,7 +956,7 @@ const uint8_t bc_parse_exprs[] = {
BC_PARSE_EXPR_ENTRY(true, true, true, true, true, false, true, true),
// Starts with BC_LEX_KW_MAXSCALE,
- BC_PARSE_EXPR_ENTRY(true, true, false, false, 0, 0, 0, 0)
+ BC_PARSE_EXPR_ENTRY(true, true, true, true, true, false, false, 0)
#endif // BC_ENABLE_EXTRA_MATH
};
@@ -1170,7 +1178,11 @@ const uchar dc_parse_insts[] = {
#if BC_ENABLE_EXTRA_MATH
BC_INST_MAXRAND,
#endif // BC_ENABLE_EXTRA_MATH
- BC_INST_PRINT_STREAM, BC_INST_INVALID,
+ BC_INST_LINE_LENGTH,
+#if BC_ENABLED
+ BC_INST_INVALID,
+#endif // BC_ENABLED
+ BC_INST_LEADING_ZERO, BC_INST_PRINT_STREAM, BC_INST_INVALID,
BC_INST_REL_EQ, BC_INST_INVALID,
BC_INST_EXECUTE, BC_INST_PRINT_STACK, BC_INST_CLEAR_STACK,
BC_INST_INVALID, BC_INST_STACK_LEN, BC_INST_DUPLICATE, BC_INST_SWAP,
diff --git a/src/dc_lex.c b/src/dc_lex.c
index d0e93c28a431..5c6950ba9698 100644
--- a/src/dc_lex.c
+++ b/src/dc_lex.c
@@ -248,6 +248,19 @@ void dc_lex_token(BcLex *l) {
break;
}
+ case 'g':
+ {
+ c2 = l->buf[l->i];
+
+ if (c2 == 'l') l->t = BC_LEX_KW_LINE_LENGTH;
+ else if (c2 == 'z') l->t = BC_LEX_KW_LEADING_ZERO;
+ else bc_lex_invalidChar(l, c2);
+
+ l->i += 1;
+
+ break;
+ }
+
case '[':
{
dc_lex_string(l);
diff --git a/src/history.c b/src/history.c
index 44fe48acc1ad..b5ba0758075c 100644
--- a/src/history.c
+++ b/src/history.c
@@ -1648,8 +1648,45 @@ void bc_history_string_free(void *str) {
void bc_history_init(BcHistory *h) {
+#ifdef _WIN32
+ HANDLE out, in;
+#endif // _WIN32
+
BC_SIG_ASSERT_LOCKED;
+ h->rawMode = false;
+ h->badTerm = bc_history_isBadTerm();
+
+#ifdef _WIN32
+
+ h->orig_in = 0;
+ h->orig_out = 0;
+
+ in = GetStdHandle(STD_INPUT_HANDLE);
+ out = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ if (!h->badTerm) {
+ SetConsoleCP(CP_UTF8);
+ SetConsoleOutputCP(CP_UTF8);
+ if (!GetConsoleMode(in, &h->orig_in) ||
+ !GetConsoleMode(out, &h->orig_out))
+ {
+ h->badTerm = true;
+ return;
+ }
+ else {
+ DWORD reqOut = ENABLE_VIRTUAL_TERMINAL_PROCESSING |
+ DISABLE_NEWLINE_AUTO_RETURN;
+ DWORD reqIn = ENABLE_VIRTUAL_TERMINAL_INPUT;
+ if (!SetConsoleMode(in, h->orig_in | reqIn) ||
+ !SetConsoleMode(out, h->orig_out | reqOut))
+ {
+ h->badTerm = true;
+ }
+ }
+ }
+#endif // _WIN32
+
bc_vec_init(&h->buf, sizeof(char), BC_DTOR_NONE);
bc_vec_init(&h->history, sizeof(char*), BC_DTOR_HISTORY_STRING);
bc_vec_init(&h->extras, sizeof(char), BC_DTOR_NONE);
@@ -1663,19 +1700,6 @@ void bc_history_init(BcHistory *h) {
sigemptyset(&h->sigmask);
sigaddset(&h->sigmask, SIGINT);
#endif // _WIN32
-
- h->rawMode = false;
- h->badTerm = bc_history_isBadTerm();
-
-#ifdef _WIN32
- if (!h->badTerm) {
- SetConsoleCP(CP_UTF8);
- SetConsoleOutputCP(CP_UTF8);
- GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &h->orig_console_mode);
- SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),
- ENABLE_VIRTUAL_TERMINAL_INPUT);
- }
-#endif // _WIN32
}
void bc_history_free(BcHistory *h) {
@@ -1683,7 +1707,8 @@ void bc_history_free(BcHistory *h) {
#ifndef _WIN32
bc_history_disableRaw(h);
#else // _WIN32
- SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), h->orig_console_mode);
+ SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), h->orig_in);
+ SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), h->orig_out);
#endif // _WIN32
#ifndef NDEBUG
bc_vec_free(&h->buf);
diff --git a/src/library.c b/src/library.c
index dbc8355a6b8e..e0bd3ee98b85 100644
--- a/src/library.c
+++ b/src/library.c
@@ -185,6 +185,14 @@ void bcl_setAbortOnFatalError(bool abrt) {
vm.abrt = abrt;
}
+bool bcl_leadingZeroes(void) {
+ return vm.leading_zeroes;
+}
+
+void bcl_setLeadingZeroes(bool leadingZeroes) {
+ vm.leading_zeroes = leadingZeroes;
+}
+
BclContext bcl_ctxt_create(void) {
BclContext ctxt = NULL;
diff --git a/src/num.c b/src/num.c
index 604328dca80d..dc3f63ab076e 100644
--- a/src/num.c
+++ b/src/num.c
@@ -2366,7 +2366,7 @@ int_err:
*/
static inline void bc_num_printNewline(void) {
#if !BC_ENABLE_LIBRARY
- if (vm.nchars >= vm.line_len - 1) {
+ if (vm.nchars >= vm.line_len - 1 && vm.line_len) {
bc_vm_putchar('\\', bc_flush_none);
bc_vm_putchar('\n', bc_flush_err);
}
@@ -2475,9 +2475,6 @@ static void bc_num_printDecimal(const BcNum *restrict n, bool newline) {
bool zero = true;
size_t buffer[BC_BASE_DIGS];
- // Print the sign.
- if (BC_NUM_NEG(n)) bc_num_putchar('-', true);
-
// Print loop.
for (i = n->len - 1; i < n->len; --i) {
@@ -2975,9 +2972,6 @@ static void bc_num_printBase(BcNum *restrict n, BcBigDig base, bool newline) {
BcNumDigitOp print;
bool neg = BC_NUM_NEG(n);
- // Just take care of the sign right here.
- if (neg) bc_num_putchar('-', true);
-
// Clear the sign because it makes the actual printing easier when we have
// to do math.
BC_NUM_NEG_CLR(n);
@@ -3145,6 +3139,16 @@ void bc_num_print(BcNum *restrict n, BcBigDig base, bool newline) {
// We may need a newline, just to start.
bc_num_printNewline();
+ if (BC_NUM_NONZERO(n)) {
+
+ // 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)
+ bc_num_printHex(0, 1, false, !newline);
+ }
+
// Short-circuit 0.
if (BC_NUM_ZERO(n)) bc_num_printHex(0, 1, false, !newline);
else if (base == BC_BASE) bc_num_printDecimal(n, newline);
diff --git a/src/program.c b/src/program.c
index 1ba012e57a5e..1ff9c24f323b 100644
--- a/src/program.c
+++ b/src/program.c
@@ -287,6 +287,14 @@ static BcNum* bc_program_num(BcProgram *p, BcResult *r) {
BcNum *n;
+#ifdef _WIN32
+ // Windows made it an error to not initialize this, so shut it up.
+ // I don't want to do this on other platforms because this procedure
+ // is one of the most heavily-used, and eliminating the initialization
+ // is a performance win.
+ n = NULL;
+#endif // _WIN32
+
switch (r->t) {
case BC_RESULT_STR:
@@ -2389,6 +2397,28 @@ static void bc_program_pushGlobal(BcProgram *p, uchar inst) {
bc_program_pushBigdig(p, p->globals[inst - BC_INST_IBASE], t);
}
+/**
+ * Pushes the value of a global setting onto the stack.
+ * @param p The program.
+ * @param inst Which global setting to push, as an instruction.
+ */
+static void bc_program_globalSetting(BcProgram *p, uchar inst) {
+
+ BcBigDig val;
+
+ // Make sure the instruction is valid.
+ assert(inst >= BC_INST_LINE_LENGTH && inst <= BC_INST_LEADING_ZERO);
+
+ 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);
+#endif // BC_ENABLED
+ else val = (BC_Z != 0);
+
+ // Push the global.
+ bc_program_pushBigdig(p, val, BC_RESULT_TEMP);
+}
+
#if BC_ENABLE_EXTRA_MATH
/**
@@ -2822,6 +2852,16 @@ void bc_program_exec(BcProgram *p) {
BC_PROG_JUMP(inst, code, ip);
}
+ BC_PROG_LBL(BC_INST_LINE_LENGTH):
+#if BC_ENABLED
+ BC_PROG_LBL(BC_INST_GLOBAL_STACKS):
+#endif // BC_ENABLED
+ BC_PROG_LBL(BC_INST_LEADING_ZERO):
+ {
+ bc_program_globalSetting(p, inst);
+ BC_PROG_JUMP(inst, code, ip);
+ }
+
BC_PROG_LBL(BC_INST_VAR):
{
bc_program_pushVar(p, code, &ip->idx, false, false);
diff --git a/src/read.c b/src/read.c
index aa906c7e5dd5..84621ad3acac 100644
--- a/src/read.c
+++ b/src/read.c
@@ -232,10 +232,11 @@ BcStatus bc_read_line(BcVec *vec, const char *prompt) {
char* bc_read_file(const char *path) {
BcErr e = BC_ERR_FATAL_IO_ERR;
- size_t size, r;
+ size_t size, to_read;
struct stat pstat;
int fd;
char* buf;
+ char* buf2;
BC_SIG_ASSERT_LOCKED;
@@ -264,11 +265,18 @@ char* bc_read_file(const char *path) {
// Get the size of the file and allocate that much.
size = (size_t) pstat.st_size;
buf = bc_vm_malloc(size + 1);
+ buf2 = buf;
+ to_read = size;
- // Read the file. We just bail if a signal interrupts. This is so that users
- // can interrupt the reading of big files if they want.
- r = (size_t) read(fd, buf, size);
- if (BC_ERR(r != size)) goto read_err;
+ do {
+
+ // Read the file. We just bail if a signal interrupts. This is so that
+ // users can interrupt the reading of big files if they want.
+ ssize_t r = read(fd, buf2, to_read);
+ if (BC_ERR(r < 0)) goto read_err;
+ to_read -= (size_t) r;
+ buf2 += (size_t) r;
+ } while (to_read);
// Got to have a nul byte.
buf[size] = '\0';
diff --git a/src/vm.c b/src/vm.c
index dc15d7dae3c0..8f222f8ccf69 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -495,7 +495,7 @@ static size_t bc_vm_envLen(const char *var) {
// Parse it and clamp it if needed.
len = (size_t) atoi(lenv) - 1;
- if (len < 2 || len >= UINT16_MAX) len = BC_NUM_PRINT_WIDTH;
+ if (len == 1 || len >= UINT16_MAX) len = BC_NUM_PRINT_WIDTH;
}
// Set the default.
else len = BC_NUM_PRINT_WIDTH;
@@ -1336,6 +1336,13 @@ void bc_vm_boot(int argc, char *argv[]) {
vm.flags |= BC_TTY ? BC_FLAG_P | BC_FLAG_R : 0;
vm.flags |= BC_I ? BC_FLAG_Q : 0;
+#if BC_ENABLED
+ if (BC_IS_BC && BC_I) {
+ // Set whether we print the banner or not.
+ bc_vm_setenvFlag("BC_BANNER", BC_DEFAULT_BANNER, BC_FLAG_Q);
+ }
+#endif // BC_ENABLED
+
// Are we in TTY mode?
if (BC_TTY) {
@@ -1368,11 +1375,6 @@ void bc_vm_boot(int argc, char *argv[]) {
// Set whether we reset on SIGINT or not.
bc_vm_setenvFlag(env_sigint, env_sigint_def, BC_FLAG_SIGINT);
-#if BC_ENABLED
- // Set whether we print the banner or not.
- if (BC_IS_BC)
- bc_vm_setenvFlag("BC_BANNER", BC_DEFAULT_BANNER, BC_FLAG_Q);
-#endif // BC_ENABLED
}
#if BC_ENABLED
diff --git a/tests/all.sh b/tests/all.sh
index a4a9c8bc8936..d3e79ef80ece 100755
--- a/tests/all.sh
+++ b/tests/all.sh
@@ -27,19 +27,29 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-set -e
-
script="$0"
testdir=$(dirname "$script")
. "$testdir/../scripts/functions.sh"
+# We need to figure out if we should run stuff in parallel.
+pll=1
+
+while getopts "n" opt; do
+
+ case "$opt" in
+ n) pll=0 ; shift ; set -e ;;
+ ?) usage "Invalid option: $opt" ;;
+ esac
+
+done
+
# Command-line processing.
if [ "$#" -ge 1 ]; then
d="$1"
shift
else
- err_exit "usage: $script dir [run_extra_tests] [run_stack_tests] [gen_tests] [time_tests] [exec args...]" 1
+ err_exit "usage: $script [-n] dir [run_extra_tests] [run_stack_tests] [gen_tests] [time_tests] [exec args...]" 1
fi
if [ "$#" -lt 1 ]; then
@@ -96,6 +106,8 @@ unset DC_LINE_LENGTH
# Get the list of tests that require extra math.
extra_required=$(cat "$testdir/extra_required.txt")
+pids=""
+
printf '\nRunning %s tests...\n\n' "$d"
# Run the tests one at a time.
@@ -109,28 +121,93 @@ while read t; do
fi
fi
- sh "$testdir/test.sh" "$d" "$t" "$generate_tests" "$time_tests" "$exe" "$@"
+ if [ "$pll" -ne 0 ]; then
+ sh "$testdir/test.sh" "$d" "$t" "$generate_tests" "$time_tests" "$exe" "$@" &
+ pids="$pids $!"
+ else
+ sh "$testdir/test.sh" "$d" "$t" "$generate_tests" "$time_tests" "$exe" "$@"
+ fi
done < "$testdir/$d/all.txt"
# stdin tests.
-sh "$testdir/stdin.sh" "$d" "$exe" "$@"
+if [ "$pll" -ne 0 ]; then
+ sh "$testdir/stdin.sh" "$d" "$exe" "$@" &
+ pids="$pids $!"
+else
+ sh "$testdir/stdin.sh" "$d" "$exe" "$@"
+fi
# Script tests.
-sh "$testdir/scripts.sh" "$d" "$extra" "$run_stack_tests" "$generate_tests" \
- "$time_tests" "$exe" "$@"
+if [ "$pll" -ne 0 ]; then
+ sh "$testdir/scripts.sh" "$d" "$extra" "$run_stack_tests" "$generate_tests" \
+ "$time_tests" "$exe" "$@" &
+ pids="$pids $!"
+else
+ sh "$testdir/scripts.sh" -n "$d" "$extra" "$run_stack_tests" "$generate_tests" \
+ "$time_tests" "$exe" "$@"
+fi
# Read tests.
-sh "$testdir/read.sh" "$d" "$exe" "$@"
+if [ "$pll" -ne 0 ]; then
+ sh "$testdir/read.sh" "$d" "$exe" "$@" &
+ pids="$pids $!"
+else
+ sh "$testdir/read.sh" "$d" "$exe" "$@"
+fi
# Error tests.
-sh "$testdir/errors.sh" "$d" "$exe" "$@"
+if [ "$pll" -ne 0 ]; then
+ sh "$testdir/errors.sh" "$d" "$exe" "$@" &
+ pids="$pids $!"
+else
+ sh "$testdir/errors.sh" "$d" "$exe" "$@"
+fi
+
+# Test all the files in the errors directory. While the other error test (in
+# tests/errors.sh) does a 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
+
+ b=$(basename "$testfile")
+
+ if [ "$pll" -ne 0 ]; then
+ sh "$testdir/error.sh" "$d" "$b" "$@" &
+ pids="$pids $!"
+ else
+ sh "$testdir/error.sh" "$d" "$b" "$@"
+ fi
+
+done
# Other tests.
-sh "$testdir/other.sh" "$d" "$extra" "$exe" "$@"
+if [ "$pll" -ne 0 ]; then
+ sh "$testdir/other.sh" "$d" "$extra" "$exe" "$@" &
+ pids="$pids $!"
+else
+ sh "$testdir/other.sh" "$d" "$extra" "$exe" "$@"
+fi
-# History tests.
-sh "$testdir/history.sh" "$d" -a
+if [ "$pll" -ne 0 ]; then
+
+ exit_err=0
+
+ for p in $pids; do
+
+ wait "$p"
+ err="$?"
+
+ if [ "$err" -ne 0 ]; then
+ printf 'A test failed!\n'
+ exit_err=1
+ fi
+ done
+
+ if [ "$exit_err" -ne 0 ]; then
+ exit 1
+ fi
+
+fi
printf '\nAll %s tests passed.\n' "$d"
diff --git a/tests/bc/all.txt b/tests/bc/all.txt
index 6f3b41a37ac1..23244773b933 100644
--- a/tests/bc/all.txt
+++ b/tests/bc/all.txt
@@ -49,3 +49,4 @@ recursive_arrays
divmod
modexp
bitfuncs
+leadingzero
diff --git a/tests/bc/leadingzero.txt b/tests/bc/leadingzero.txt
new file mode 100644
index 000000000000..77c7dcd08ef9
--- /dev/null
+++ b/tests/bc/leadingzero.txt
@@ -0,0 +1,12 @@
+plznl(0.01)
+plznl(-0.01)
+plznl(.01)
+plznl(-.01)
+plznl(1.01)
+plznl(-1.01)
+pnlznl(0.01)
+pnlznl(-0.01)
+pnlznl(.01)
+pnlznl(-.01)
+pnlznl(1.01)
+pnlznl(-1.01)
diff --git a/tests/bc/leadingzero_results.txt b/tests/bc/leadingzero_results.txt
new file mode 100644
index 000000000000..4b542860a773
--- /dev/null
+++ b/tests/bc/leadingzero_results.txt
@@ -0,0 +1,12 @@
+0.01
+-0.01
+0.01
+-0.01
+1.01
+-1.01
+.01
+-.01
+.01
+-.01
+1.01
+-1.01
diff --git a/tests/bc/scripts/globals.bc b/tests/bc/scripts/globals.bc
index e9a0c6dbacd3..30ff9074387e 100644
--- a/tests/bc/scripts/globals.bc
+++ b/tests/bc/scripts/globals.bc
@@ -1,5 +1,9 @@
#! /usr/bin/bc -gq
+if (!global_stacks()) {
+ sqrt(-1)
+}
+
define i(x) {
ibase=x
return ibase
diff --git a/tests/bcl.c b/tests/bcl.c
index 89ee185145a5..e1d527ad8721 100644
--- a/tests/bcl.c
+++ b/tests/bcl.c
@@ -234,6 +234,104 @@ int main(void) {
// Clean up.
bcl_num_free(n);
+ // Test leading zeroes.
+ if (bcl_leadingZeroes())
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ n = bcl_parse("0.01");
+ err(bcl_err(n));
+
+ n2 = bcl_parse("-0.01");
+ err(bcl_err(n2));
+
+ n3 = bcl_parse("1.01");
+ err(bcl_err(n3));
+
+ n4 = bcl_parse("-1.01");
+ err(bcl_err(n4));
+
+ res = bcl_string(bcl_dup(n));
+ if (strcmp(res, ".01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ res = bcl_string(bcl_dup(n2));
+ if (strcmp(res, "-.01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ res = bcl_string(bcl_dup(n3));
+ if (strcmp(res, "1.01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ res = bcl_string(bcl_dup(n4));
+ if (strcmp(res, "-1.01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ bcl_setLeadingZeroes(true);
+
+ if (!bcl_leadingZeroes())
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ res = bcl_string(bcl_dup(n));
+ if (strcmp(res, "0.01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ res = bcl_string(bcl_dup(n2));
+ if (strcmp(res, "-0.01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ res = bcl_string(bcl_dup(n3));
+ if (strcmp(res, "1.01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ res = bcl_string(bcl_dup(n4));
+ if (strcmp(res, "-1.01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ bcl_setLeadingZeroes(false);
+
+ if (bcl_leadingZeroes())
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ res = bcl_string(n);
+ if (strcmp(res, ".01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ res = bcl_string(n2);
+ if (strcmp(res, "-.01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ res = bcl_string(n3);
+ if (strcmp(res, "1.01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
+ res = bcl_string(n4);
+ if (strcmp(res, "-1.01"))
+ err(BCL_ERROR_FATAL_UNKNOWN_ERR);
+
+ free(res);
+
bcl_ctxt_freeNums(ctxt);
bcl_gc();
diff --git a/tests/dc/errors.txt b/tests/dc/errors.txt
index 37513e972647..95fff37d915f 100644
--- a/tests/dc/errors.txt
+++ b/tests/dc/errors.txt
@@ -24,6 +24,9 @@ zp198202389.289374pzp[He World!]xSzpzXfrfxzpfR
3 0~
0 _251^pR
.
+ga
+gb
+gd
@
0 0< $
0 0> s e %
diff --git a/tests/error.sh b/tests/error.sh
new file mode 100755
index 000000000000..c76dcdf113dd
--- /dev/null
+++ b/tests/error.sh
@@ -0,0 +1,99 @@
+#! /bin/sh
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+script="$0"
+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 [exec args...]\n' "$script"
+ exit 1
+else
+ d="$1"
+ shift
+
+ t="$1"
+ shift
+fi
+
+if [ "$#" -lt 1 ]; then
+ exe="$testdir/../bin/$d"
+else
+ exe="$1"
+ shift
+fi
+
+# I use these, so unset them to make the tests work.
+unset BC_ENV_ARGS
+unset BC_LINE_LENGTH
+unset DC_ENV_ARGS
+unset DC_LINE_LENGTH
+
+out="$outputdir/${d}_outputs/error_results_${t}"
+outdir=$(dirname "$out")
+
+# Make sure the directory exists.
+if [ ! -d "$outdir" ]; then
+ mkdir -p "$outdir"
+fi
+
+# Set stuff for the correct calculator.
+if [ "$d" = "bc" ]; then
+ opts="-l"
+ halt="halt"
+ read_call="read()"
+ read_expr="${read_call}\n5+5;"
+else
+ opts="-x"
+ halt="q"
+fi
+
+testfile="$testdir/$d/errors/$t"
+
+printf 'Running %s error file %s...' "$d" "$t"
+
+printf '%s\n' "$halt" | "$exe" "$@" $opts "$testfile" 2> "$out" > /dev/null
+err="$?"
+
+checkerrtest "$d" "$err" "$testfile" "$out" "$exebase" > /dev/null
+
+printf 'pass\n'
+
+printf 'Running %s error file %s through cat...' "$d" "$t"
+
+cat "$testfile" | "$exe" "$@" $opts 2> "$out" > /dev/null
+err="$?"
+
+checkcrash "$d" "$err" "$testfile"
+
+printf 'pass\n'
diff --git a/tests/errors.sh b/tests/errors.sh
index c8c82cfe356f..4acc978b9e5a 100755
--- a/tests/errors.sh
+++ b/tests/errors.sh
@@ -147,28 +147,3 @@ for testfile in $testdir/$d/*errors.txt; do
printf 'pass\n'
done
-
-# 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
-
- printf 'Running %s error file %s...' "$d" "$testfile"
-
- printf '%s\n' "$halt" | "$exe" "$@" $opts "$testfile" 2> "$out" > /dev/null
- err="$?"
-
- checkerrtest "$d" "$err" "$testfile" "$out" "$exebase"
-
- printf 'pass\n'
-
- printf 'Running %s error file %s through cat...' "$d" "$testfile"
-
- cat "$testfile" | "$exe" "$@" $opts 2> "$out" > /dev/null
- err="$?"
-
- checkcrash "$d" "$err" "$testfile"
-
- printf 'pass\n'
-
-done
diff --git a/tests/extra_required.txt b/tests/extra_required.txt
index bcce9ee83b03..e36d95a1305b 100644
--- a/tests/extra_required.txt
+++ b/tests/extra_required.txt
@@ -6,3 +6,4 @@ scientific
shift
trunc
bitfuncs
+leadingzero
diff --git a/tests/history.py b/tests/history.py
index fff531652b1b..17006c93ef2d 100755
--- a/tests/history.py
+++ b/tests/history.py
@@ -30,6 +30,7 @@
import os, sys
import time
import signal
+import traceback
try:
import pexpect
@@ -72,23 +73,54 @@ utf8_stress_strs = [
]
+def expect(child, data):
+ child.expect(data)
+
+
+# Eats all of the child's data.
+# @param child The child whose data should be eaten.
+def eat(child):
+ while child.buffer is not None and len(child.buffer) > 0:
+ expect(child, ".+")
+
+
+# Send data to a child. This makes sure the buffers are empty first.
+# @param child The child to send data to.
+# @param data The data to send.
+def send(child, data):
+ eat(child)
+ child.send(data)
+
+
+def wait(child):
+ if child.isalive():
+ child.sendeof()
+ time.sleep(1)
+ if child.isalive():
+ child.kill(signal.SIGTERM)
+ time.sleep(1)
+ if child.isalive():
+ child.kill(signal.SIGKILL)
+ child.wait()
+
+
# 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):
- child.send("\n")
+ send(child, "\n")
prefix = "\r\n" if history else ""
- child.expect(prefix + expected + "\r\n" + prompt)
+ expect(child, prefix + expected + "\r\n" + prompt)
# Write a string to output, checking all of the characters are output,
# one-by-one.
def write_str(child, s):
for c in s:
- child.send(c)
+ send(child, c)
if c in escapes:
- child.expect("\\{}".format(c))
+ expect(child, "\\{}".format(c))
else:
- child.expect(c)
+ expect(child, c)
# Check the bc banner.
@@ -98,11 +130,11 @@ def bc_banner(child):
bc_banner2 = "Copyright \(c\) 2018-[2-9][0-9][0-9][0-9] Gavin D. Howard and contributors\r\n"
bc_banner3 = "Report bugs at: https://git.yzena.com/gavin/bc\r\n\r\n"
bc_banner4 = "This is free software with ABSOLUTELY NO WARRANTY.\r\n\r\n"
- child.expect(bc_banner1)
- child.expect(bc_banner2)
- child.expect(bc_banner3)
- child.expect(bc_banner4)
- child.expect(prompt)
+ expect(child, bc_banner1)
+ expect(child, bc_banner2)
+ expect(child, bc_banner3)
+ expect(child, bc_banner4)
+ expect(child, prompt)
# Common UTF-8 testing function. The index is the index into utf8_stress_strs
@@ -121,20 +153,20 @@ def test_utf8(exe, args, env, idx, bc=True):
try:
# Write the stress string.
- child.send(utf8_stress_strs[idx])
- child.send("\n")
- child.expect("Parse error: bad character")
+ send(child, utf8_stress_strs[idx])
+ send(child, "\n")
if bc:
- child.send("quit")
+ send(child, "quit")
else:
- child.send("q")
+ send(child, "q")
- child.send("\n")
+ send(child, "\n")
- child.wait()
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -162,21 +194,21 @@ def test_utf8_0(exe, args, env, bc=True):
# Just random UTF-8 I generated somewhow, plus ensuring that insert works.
write_str(child, "ﴪáá̵̗🈐ã")
- child.send("\x1b[D\x1b[D\x1b[D\x1b\x1b[Aℐ")
- child.send("\n")
-
- child.expect("Parse error: bad character")
+ send(child, "\x1b[D\x1b[D\x1b[D\x1b\x1b[Aℐ")
+ send(child, "\n")
if bc:
- child.send("quit")
+ send(child, "quit")
else:
- child.send("q")
+ send(child, "q")
- child.send("\n")
+ send(child, "\n")
+ eat(child)
- child.wait()
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -212,15 +244,19 @@ def test_utf8_4(exe, args, env, bc=True):
# @param env The environment.
def test_sigint_sigquit(exe, args, env):
+ # Because both bc and dc use this, make sure the banner doesn't pop.
+ env["BC_BANNER"] = "0"
+
child = pexpect.spawn(exe, args=args, env=env)
try:
- child.send("\t")
- child.expect(" ")
- child.send("\x03")
- child.send("\x1c")
- child.wait()
+ send(child, "\t")
+ expect(child, " ")
+ send(child, "\x03")
+ send(child, "\x1c")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -240,14 +276,18 @@ def test_sigint_sigquit(exe, args, env):
# @param env The environment.
def test_eof(exe, args, env):
+ # Because both bc and dc use this, make sure the banner doesn't pop.
+ env["BC_BANNER"] = "0"
+
child = pexpect.spawn(exe, args=args, env=env)
try:
- child.send("\t")
- child.expect(" ")
- child.send("\x04")
- child.wait()
+ send(child, "\t")
+ expect(child, " ")
+ send(child, "\x04")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -267,17 +307,21 @@ def test_eof(exe, args, env):
# @param env The environment.
def test_sigint(exe, args, env):
+ # Because both bc and dc use this, make sure the banner doesn't pop.
+ env["BC_BANNER"] = "0"
+
env["BC_SIGINT_RESET"] = "0"
env["DC_SIGINT_RESET"] = "0"
child = pexpect.spawn(exe, args=args, env=env)
try:
- child.send("\t")
- child.expect(" ")
- child.send("\x03")
- child.wait()
+ send(child, "\t")
+ expect(child, " ")
+ send(child, "\x03")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -297,12 +341,19 @@ def test_sigint(exe, args, env):
# @param env The environment.
def test_sigtstp(exe, args, env):
+ # This test does not work on FreeBSD, so skip.
+ if sys.platform.startswith("freebsd"):
+ sys.exit(0)
+
+ # Because both bc and dc use this, make sure the banner doesn't pop.
+ env["BC_BANNER"] = "0"
+
child = pexpect.spawn(exe, args=args, env=env)
try:
- child.send("\t")
- child.expect(" ")
- child.send("\x13")
+ send(child, "\t")
+ expect(child, " ")
+ send(child, "\x13")
time.sleep(1)
if not child.isalive():
print("child exited early")
@@ -310,10 +361,11 @@ def test_sigtstp(exe, args, env):
print(str(child.buffer))
sys.exit(1)
child.kill(signal.SIGCONT)
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -333,19 +385,22 @@ def test_sigtstp(exe, args, env):
# @param env The environment.
def test_sigstop(exe, args, env):
+ # Because both bc and dc use this, make sure the banner doesn't pop.
+ env["BC_BANNER"] = "0"
+
child = pexpect.spawn(exe, args=args, env=env)
try:
- child.send("\t")
- child.expect(" ")
- child.send("\x14")
+ send(child, "\t")
+ expect(child, " ")
+ send(child, "\x14")
time.sleep(1)
if not child.isalive():
print("child exited early")
print(str(child))
print(str(child.buffer))
sys.exit(1)
- child.send("\x13")
+ send(child, "\x13")
time.sleep(1)
if not child.isalive():
print("child exited early")
@@ -353,10 +408,11 @@ def test_sigstop(exe, args, env):
print(str(child.buffer))
sys.exit(1)
child.kill(signal.SIGCONT)
- child.send("quit")
- child.send("\n")
- child.wait()
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -404,10 +460,11 @@ def test_bc1(exe, args, env):
check_line(child, "1")
write_str(child, "1")
check_line(child, "1")
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -438,8 +495,9 @@ def test_bc2(exe, args, env):
time.sleep(1)
child.sendintr()
child.sendline("quit")
- child.wait()
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -463,22 +521,23 @@ def test_bc3(exe, args, env):
try:
bc_banner(child)
- child.send("\x1b[D\x1b[D\x1b[C\x1b[C")
- child.send("\n")
- child.expect(prompt)
- child.send("12\x1b[D3\x1b[C4\x1bOD5\x1bOC6")
- child.send("\n")
+ send(child, "\x1b[D\x1b[D\x1b[C\x1b[C")
+ send(child, "\n")
+ expect(child, prompt)
+ send(child, "12\x1b[D3\x1b[C4\x1bOD5\x1bOC6")
+ send(child, "\n")
check_line(child, "132546")
- child.send("12\x023\x064")
- child.send("\n")
+ send(child, "12\x023\x064")
+ send(child, "\n")
check_line(child, "1324")
- child.send("12\x1b[H3\x1bOH\x01\x1b[H45\x1bOF6\x05\x1b[F7\x1bOH8")
- child.send("\n")
+ send(child, "12\x1b[H3\x1bOH\x01\x1b[H45\x1bOF6\x05\x1b[F7\x1bOH8")
+ send(child, "\n")
check_line(child, "84531267")
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -502,25 +561,26 @@ def test_bc4(exe, args, env):
try:
bc_banner(child)
- child.send("\x1b[A\x1bOA\x1b[B\x1bOB")
- child.send("\n")
- child.expect(prompt)
+ send(child, "\x1b[A\x1bOA\x1b[B\x1bOB")
+ send(child, "\n")
+ expect(child, prompt)
write_str(child, "15")
check_line(child, "15")
write_str(child, "2^16")
check_line(child, "65536")
- child.send("\x1b[A\x1bOA")
- child.send("\n")
+ send(child, "\x1b[A\x1bOA")
+ send(child, "\n")
check_line(child, "15")
- child.send("\x1b[A\x1bOA\x1b[A\x1b[B")
+ send(child, "\x1b[A\x1bOA\x1b[A\x1b[B")
check_line(child, "65536")
- child.send("\x1b[A\x1bOA\x0e\x1b[A\x1b[A\x1b[A\x1b[B\x10\x1b[B\x1b[B\x1bOB\x1b[B\x1bOA")
- child.send("\n")
+ send(child, "\x1b[A\x1bOA\x0e\x1b[A\x1b[A\x1b[A\x1b[B\x10\x1b[B\x1b[B\x1bOB\x1b[B\x1bOA")
+ send(child, "\n")
check_line(child, "65536")
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -544,11 +604,12 @@ def test_bc5(exe, args, env):
try:
bc_banner(child)
- child.send("\x0c")
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "\x0c")
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -572,15 +633,16 @@ def test_bc6(exe, args, env):
try:
bc_banner(child)
- child.send("print \"Enter number: \"")
- child.send("\n")
- child.expect("Enter number: ")
- child.send("4\x1b[A\x1b[A")
- child.send("\n")
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "print \"Enter number: \"")
+ send(child, "\n")
+ expect(child, "Enter number: ")
+ send(child, "4\x1b[A\x1b[A")
+ send(child, "\n")
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -604,34 +666,35 @@ def test_bc7(exe, args, env):
try:
bc_banner(child)
- child.send("\x1bb\x1bb\x1bf\x1bf")
- child.send("\n")
- child.expect(prompt)
- child.send("\x1b[0~\x1b[3a")
- child.send("\n")
- child.expect(prompt)
- child.send("\x1b[0;4\x1b[0A")
- child.send("\n")
- child.expect(prompt)
- child.send(" ")
- child.send("\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb")
- child.send("\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf")
- child.send("\n")
- child.expect(prompt)
+ send(child, "\x1bb\x1bb\x1bf\x1bf")
+ send(child, "\n")
+ expect(child, prompt)
+ send(child, "\x1b[0~\x1b[3a")
+ send(child, "\n")
+ expect(child, prompt)
+ send(child, "\x1b[0;4\x1b[0A")
+ send(child, "\n")
+ expect(child, prompt)
+ send(child, " ")
+ send(child, "\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb")
+ send(child, "\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf")
+ send(child, "\n")
+ expect(child, prompt)
write_str(child, "12 + 34 + 56 + 78 + 90")
check_line(child, "270")
- child.send("\x1b[A")
- child.send("\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb")
- child.send("\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf")
+ send(child, "\x1b[A")
+ send(child, "\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb")
+ send(child, "\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf")
check_line(child, "270")
- child.send("\x1b[A")
- child.send("\x1bh\x1bh\x1bf + 14 ")
- child.send("\n")
+ send(child, "\x1b[A")
+ send(child, "\x1bh\x1bh\x1bf + 14 ")
+ send(child, "\n")
check_line(child, "284")
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -655,13 +718,14 @@ def test_bc8(exe, args, env):
try:
bc_banner(child)
- child.send("12\x1b[D3\x1b[C4\x08\x7f")
- child.send("\n")
+ send(child, "12\x1b[D3\x1b[C4\x08\x7f")
+ send(child, "\n")
check_line(child, "13")
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -685,26 +749,27 @@ def test_bc9(exe, args, env):
try:
bc_banner(child)
- child.send("\x1b[0;5D\x1b[0;5D\x1b[0;5D\x1b[0;5C\x1b[0;5D\x1bd\x1b[3~\x1b[d\x1b[d\x1b[d\x1b[d\x7f\x7f\x7f")
- child.send("\n")
- child.expect(prompt)
+ send(child, "\x1b[0;5D\x1b[0;5D\x1b[0;5D\x1b[0;5C\x1b[0;5D\x1bd\x1b[3~\x1b[d\x1b[d\x1b[d\x1b[d\x7f\x7f\x7f")
+ send(child, "\n")
+ expect(child, prompt)
write_str(child, "12 + 34 + 56 + 78 + 90")
check_line(child, "270")
- child.send("\x1b[A")
- child.send("\x1b[0;5D\x1b[0;5D\x1b[0;5D\x1b[0;5C\x1b[0;5D\x1bd\x1b[3~\x1b[d\x1b[d\x1b[d\x1b[d\x7f\x7f\x7f")
- child.send("\n")
+ send(child, "\x1b[A")
+ send(child, "\x1b[0;5D\x1b[0;5D\x1b[0;5D\x1b[0;5C\x1b[0;5D\x1bd\x1b[3~\x1b[d\x1b[d\x1b[d\x1b[d\x7f\x7f\x7f")
+ send(child, "\n")
check_line(child, "102")
- child.send("\x1b[A")
- child.send("\x17\x17")
- child.send("\n")
+ send(child, "\x1b[A")
+ send(child, "\x17\x17")
+ send(child, "\n")
check_line(child, "46")
- child.send("\x17\x17")
- child.send("\n")
- child.expect(prompt)
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "\x17\x17")
+ send(child, "\n")
+ expect(child, prompt)
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -728,26 +793,27 @@ def test_bc10(exe, args, env):
try:
bc_banner(child)
- child.send("\x1b[3~\x1b[3~")
- child.send("\n")
- child.expect(prompt)
- child.send(" \x1b[3~\x1b[3~")
- child.send("\n")
- child.expect(prompt)
+ send(child, "\x1b[3~\x1b[3~")
+ send(child, "\n")
+ expect(child, prompt)
+ send(child, " \x1b[3~\x1b[3~")
+ send(child, "\n")
+ expect(child, prompt)
write_str(child, "12 + 34 + 56 + 78 + 90")
check_line(child, "270")
- child.send("\x1b[A\x1b[A\x1b[A\x1b[B\x1b[B\x1b[B\x1b[A")
- child.send("\n")
+ send(child, "\x1b[A\x1b[A\x1b[A\x1b[B\x1b[B\x1b[B\x1b[A")
+ send(child, "\n")
check_line(child, "270")
- child.send("\x1b[A\x1b[0;5D\x1b[0;5D\x0b")
- child.send("\n")
+ send(child, "\x1b[A\x1b[0;5D\x1b[0;5D\x0b")
+ send(child, "\n")
check_line(child, "180")
- child.send("\x1b[A\x1521")
+ send(child, "\x1b[A\x1521")
check_line(child, "21")
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -771,17 +837,18 @@ def test_bc11(exe, args, env):
try:
bc_banner(child)
- child.send("\x1b[A\x02\x14")
- child.send("\n")
- child.expect(prompt)
+ send(child, "\x1b[A\x02\x14")
+ send(child, "\n")
+ expect(child, prompt)
write_str(child, "12 + 34 + 56 + 78")
check_line(child, "180")
- child.send("\x1b[A\x02\x14")
+ send(child, "\x1b[A\x02\x14")
check_line(child, "189")
- write_str(child, "quit")
- child.send("\n")
- child.wait()
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -805,18 +872,19 @@ def test_bc12(exe, args, env):
try:
bc_banner(child)
- child.send("12 +")
- child.send("\n")
+ send(child, "12 +")
+ send(child, "\n")
time.sleep(1)
if not child.isalive():
print("child exited early")
print(str(child))
print(str(child.buffer))
sys.exit(1)
- child.send("quit")
- child.send("\n")
- child.wait()
+ send(child, "quit")
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -864,9 +932,10 @@ def test_dc1(exe, args, env):
write_str(child, "1pR")
check_line(child, "1")
write_str(child, "q")
- child.send("\n")
- child.wait()
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -896,8 +965,9 @@ def test_dc2(exe, args, env):
time.sleep(1)
child.sendintr()
child.sendline("q")
- child.wait()
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -925,9 +995,10 @@ def test_dc3(exe, args, env):
write_str(child, "1pR")
check_line(child, "1")
write_str(child, "q")
- child.send("\n")
- child.wait()
+ send(child, "\n")
+ wait(child)
except pexpect.TIMEOUT:
+ traceback.print_tb(sys.exc_info()[2])
print("timed out")
print(str(child))
sys.exit(2)
@@ -988,7 +1059,7 @@ def usage():
print(" The valid values for dir are: 'bc' and 'dc'.")
print(" The max test_idx for bc is {}.".format(len(bc_tests) - 1))
print(" The max test_idx for dc is {}.".format(len(dc_tests) - 1))
- print(" If -a is given, the number of test for dir is printed.")
+ print(" If -a is given, the number of tests for dir is printed.")
print(" No tests are run.")
sys.exit(1)
@@ -1038,7 +1109,7 @@ exebase = os.path.basename(exe)
# Use the correct options.
if exebase == "bc":
halt = "halt\n"
- options = "-lq"
+ options = "-l"
test_array = bc_tests
else:
halt = "q\n"
@@ -1076,7 +1147,7 @@ child.close()
exit = child.exitstatus
-if exit != 0:
+if exit is not None and exit != 0:
print("child failed; expected exit code 0, got {}".format(exit))
print(str(child))
sys.exit(1)
diff --git a/tests/history.sh b/tests/history.sh
index bf25b2ffea92..92db985a4f86 100755
--- a/tests/history.sh
+++ b/tests/history.sh
@@ -33,7 +33,7 @@ testdir=$(dirname "$script")
. "$testdir/../scripts/functions.sh"
-# usage: history.sh dir -a|idx
+# usage: history.sh dir -a|idx [exe args...]
# If Python does not exist, then just skip.
py=$(command -v python3)
@@ -60,6 +60,24 @@ shift
idx="$1"
shift
+if [ "$#" -gt 0 ]; then
+
+ # exe is the executable to run.
+ exe="$1"
+ shift
+
+else
+ exe="$testdir/../bin/$d"
+fi
+
+if [ "$d" = "bc" ]; then
+ flip="! %s"
+ addone="%s + 1"
+else
+ flip="%s Np"
+ addone="%s 1+p"
+fi
+
# Set the test range correctly for all tests or one test. st is the start index.
if [ "$idx" = "-a" ]; then
idx=$("$py" "$testdir/history.py" "$d" -a)
@@ -72,12 +90,12 @@ fi
# Run all of the tests.
for i in $(seq "$st" "$idx"); do
+ printf 'Running %s history test %d...' "$d" "$i"
+
for j in $(seq 1 3); do
- printf 'Running %s history test %d...' "$d" "$i"
-
- "$py" "$testdir/history.py" "$d" "$i" "$@"
- err=$?
+ "$py" "$testdir/history.py" "$d" "$i" "$exe" "$@"
+ err="$?"
if [ "$err" -eq 0 ]; then
break
@@ -85,7 +103,7 @@ for i in $(seq "$st" "$idx"); do
done
- checktest_retcode "$d" "$err" "$d history tests $i"
+ checktest_retcode "$d" "$err" "$d history test $i"
printf 'pass\n'
diff --git a/tests/other.sh b/tests/other.sh
index 4a26582457e3..bd0014641846 100755
--- a/tests/other.sh
+++ b/tests/other.sh
@@ -64,6 +64,7 @@ fi
# For tests later.
num=100000000000000000000000000000000000000000000000000000000000000000000000000000
+num2="$num"
numres="$num"
num70="10000000000000000000000000000000000000000000000000000000000000000000\\
0000000000"
@@ -74,12 +75,14 @@ if [ "$d" = "bc" ]; then
opt="x"
lopt="extended-register"
line_var="BC_LINE_LENGTH"
+ lltest="line_length()"
else
halt="q"
opt="l"
lopt="mathlib"
line_var="DC_LINE_LENGTH"
num="$num pR"
+ lltest="glpR"
fi
# I use these, so unset them to make the tests work.
@@ -234,17 +237,32 @@ printf '%s\n' "$numres" > "$out1"
export "$line_var"=80
printf '%s\n' "$num" | "$exe" "$@" > "$out2"
-checktest "$d" "$?" "environment var" "$out1" "$out2"
+checktest "$d" "$?" "line length" "$out1" "$out2"
printf '%s\n' "$num70" > "$out1"
export "$line_var"=2147483647
printf '%s\n' "$num" | "$exe" "$@" > "$out2"
-checktest "$d" "$?" "environment var" "$out1" "$out2"
+checktest "$d" "$?" "line length 2" "$out1" "$out2"
+
+printf '%s\n' "$num2" > "$out1"
+
+export "$line_var"=62
+printf '%s\n' "$num" | "$exe" "$@" -L > "$out2"
+
+checktest "$d" "$?" "line length 3" "$out1" "$out2"
+
+printf '0\n' > "$out1"
+printf '%s\n' "$lltest" | "$exe" "$@" -L > "$out2"
+
+checktest "$d" "$?" "line length 3" "$out1" "$out2"
printf 'pass\n'
+printf '%s\n' "$numres" > "$out1"
+export "$line_var"=2147483647
+
printf 'Running %s arg tests...' "$d"
f="$testdir/$d/add.txt"
@@ -276,6 +294,26 @@ checktest_retcode "$d" "$?" "arg"
printf '%s\n' "$halt" | "$exe" "$@" -V > /dev/null
checktest_retcode "$d" "$?" "arg"
+out=$(printf '0.1\n-0.1\n1.1\n-1.1\n0.1\n-0.1\n')
+printf '%s\n' "$out" > "$out1"
+
+if [ "$d" = "bc" ]; then
+ data=$(printf '0.1\n-0.1\n1.1\n-1.1\n.1\n-.1\n')
+else
+ data=$(printf '0.1pR\n_0.1pR\n1.1pR\n_1.1pR\n.1pR\n_.1pR\n')
+fi
+
+printf '%s\n' "$data" | "$exe" "$@" -z > "$out2"
+checktest "$d" "$?" "leading zero" "$out1" "$out2"
+
+if [ "$d" = "bc" ] && [ "$extra_math" -ne 0 ]; then
+
+ printf '%s\n' "$halt" | "$exe" "$@" -lz "$testdir/bc/leadingzero.txt" > "$out2"
+
+ checktest "$d" "$?" "leading zero script" "$testdir/bc/leadingzero_results.txt" "$out2"
+
+fi
+
"$exe" "$@" -f "saotehasotnehasthistohntnsahxstnhalcrgxgrlpyasxtsaosysxsatnhoy.txt" > /dev/null 2> "$out2"
err="$?"
diff --git a/tests/scripts.sh b/tests/scripts.sh
index 30fb42f1e873..46aa7e761170 100755
--- a/tests/scripts.sh
+++ b/tests/scripts.sh
@@ -27,15 +27,27 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-set -e
-
script="$0"
testdir=$(dirname "${script}")
+pids=""
+
+# We need to figure out if we should run stuff in parallel.
+pll=1
+
+while getopts "n" opt; do
+
+ case "$opt" in
+ n) pll=0 ; shift ; set -e ;;
+ ?) usage "Invalid option: $opt" ;;
+ esac
+
+done
+
# Command-line processing.
if [ "$#" -eq 0 ]; then
- printf 'usage: %s dir [run_extra_tests] [run_stack_tests] [generate_tests] [time_tests] [exec args...]\n' "$script"
+ printf 'usage: %s [-n] dir [run_extra_tests] [run_stack_tests] [generate_tests] [time_tests] [exec args...]\n' "$script"
exit 1
else
d="$1"
@@ -85,7 +97,36 @@ scripts=$(cat "$scriptdir/all.txt")
for s in $scripts; do
f=$(basename "$s")
- sh "$testdir/script.sh" "$d" "$f" "$run_extra_tests" "$run_stack_tests" \
- "$generate" "$time_tests" "$exe" "$@"
+
+ if [ "$pll" -ne 0 ]; then
+ sh "$testdir/script.sh" "$d" "$f" "$run_extra_tests" "$run_stack_tests" \
+ "$generate" "$time_tests" "$exe" "$@" &
+ pids="$pids $!"
+ else
+ sh "$testdir/script.sh" "$d" "$f" "$run_extra_tests" "$run_stack_tests" \
+ "$generate" "$time_tests" "$exe" "$@"
+ fi
done
+
+if [ "$pll" -ne 0 ]; then
+
+ exit_err=0
+
+ for p in $pids; do
+
+ wait "$p"
+ err="$?"
+
+ if [ "$err" -ne 0 ]; then
+ printf 'A script failed!\n'
+ exit_err=1
+ fi
+
+ done
+
+ if [ "$exit_err" -ne 0 ]; then
+ exit 1
+ fi
+
+fi
diff --git a/bc.sln b/vs/bc.sln
similarity index 53%
rename from bc.sln
rename to vs/bc.sln
index 584b28d13bf6..daf1a4a12bd8 100644
--- a/bc.sln
+++ b/vs/bc.sln
@@ -1,9 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
-VisualStudioVersion = 16.0.31129.286
+VisualStudioVersion = 16.0.31515.178
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc", "bc.vcxproj", "{D5086CFE-052C-4742-B005-E05DB983BBA2}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc", "bc.vcxproj", "{4450D61F-2535-4085-B1B1-F96ACD23CC9F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -13,19 +13,19 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x64.ActiveCfg = Debug|x64
- {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x64.Build.0 = Debug|x64
- {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x86.ActiveCfg = Debug|Win32
- {D5086CFE-052C-4742-B005-E05DB983BBA2}.Debug|x86.Build.0 = Debug|Win32
- {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x64.ActiveCfg = Release|x64
- {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x64.Build.0 = Release|x64
- {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x86.ActiveCfg = Release|Win32
- {D5086CFE-052C-4742-B005-E05DB983BBA2}.Release|x86.Build.0 = Release|Win32
+ {4450D61F-2535-4085-B1B1-F96ACD23CC9F}.Debug|x64.ActiveCfg = Debug|x64
+ {4450D61F-2535-4085-B1B1-F96ACD23CC9F}.Debug|x64.Build.0 = Debug|x64
+ {4450D61F-2535-4085-B1B1-F96ACD23CC9F}.Debug|x86.ActiveCfg = Debug|Win32
+ {4450D61F-2535-4085-B1B1-F96ACD23CC9F}.Debug|x86.Build.0 = Debug|Win32
+ {4450D61F-2535-4085-B1B1-F96ACD23CC9F}.Release|x64.ActiveCfg = Release|x64
+ {4450D61F-2535-4085-B1B1-F96ACD23CC9F}.Release|x64.Build.0 = Release|x64
+ {4450D61F-2535-4085-B1B1-F96ACD23CC9F}.Release|x86.ActiveCfg = Release|Win32
+ {4450D61F-2535-4085-B1B1-F96ACD23CC9F}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {7869B1FB-A7C4-4FCF-8B99-F696DB2765EC}
+ SolutionGuid = {99364EF5-C65F-4658-A3FA-19EAC64BE8B9}
EndGlobalSection
EndGlobal
diff --git a/vs/bc.vcxproj b/vs/bc.vcxproj
new file mode 100644
index 000000000000..19b53d66a405
--- /dev/null
+++ b/vs/bc.vcxproj
@@ -0,0 +1,297 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ Win32Proj
+ {4450d61f-2535-4085-b1b1-f96acd23cc9f}
+ bc
+ 10.0
+
+
+
+ Application
+ true
+ v142
+ Unicode
+
+
+ Application
+ false
+ v142
+ true
+ Unicode
+
+
+ Application
+ true
+ v142
+ Unicode
+
+
+ Application
+ false
+ v142
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ ClCompile
+ false
+ bin\$(Platform)\$(Configuration)\
+ bin\$(Platform)\$(Configuration)\
+
+
+ false
+ ClCompile
+ false
+ bin\$(Platform)\$(Configuration)\
+ bin\$(Platform)\$(Configuration)\
+
+
+ true
+ ClCompile
+ false
+ bin\$(Platform)\$(Configuration)\
+ bin\$(Platform)\$(Configuration)\
+
+
+ false
+ ClCompile
+ false
+ bin\$(Platform)\$(Configuration)\
+ bin\$(Platform)\$(Configuration)\
+
+
+
+ Level3
+ true
+ BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;BUILD_TYPE=HN;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ ..\include
+ MultiThreadedDebug
+ true
+
+
+ Console
+ true
+ bcrypt.lib;%(AdditionalDependencies)
+
+
+ copy /b /y $(OutDir)bc.exe $(OutDir)dc.exe
+
+
+
+
+
+ Level3
+ true
+ true
+ true
+ BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;BUILD_TYPE=HN;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ ..\include
+ MultiThreaded
+ true
+
+
+ Console
+ true
+ true
+ false
+ bcrypt.lib;%(AdditionalDependencies)
+
+
+ copy /b /y $(OutDir)bc.exe $(OutDir)dc.exe
+
+
+
+
+
+ Level3
+ true
+ BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;BUILD_TYPE=HN;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ ..\include
+ MultiThreadedDebug
+ true
+
+
+ Console
+ true
+ bcrypt.lib;%(AdditionalDependencies)
+
+
+ copy /b /y $(OutDir)bc.exe $(OutDir)dc.exe
+
+
+
+
+
+ Level3
+ true
+ true
+ BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;BUILD_TYPE=HN;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ ..\include
+ MultiThreaded
+ true
+ true
+
+
+ Console
+ true
+ true
+ false
+ bcrypt.lib;%(AdditionalDependencies)
+
+
+ copy /b /y $(OutDir)bc.exe $(OutDir)dc.exe
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CppCode
+ cl.exe /Fo:$(OutDir)strgen.obj /Fe:$(OutDir)strgen.exe %(Identity)
+ $(OutDir)strgen.exe
+ cl.exe /Fo:$(OutDir)strgen.obj /Fe:$(OutDir)strgen.exe %(Identity)
+ $(OutDir)strgen.exe
+ cl.exe /Fo:$(OutDir)strgen.obj /Fe:$(OutDir)strgen.exe %(Identity)
+ $(OutDir)strgen.exe
+ cl.exe /Fo:$(OutDir)strgen.obj /Fe:$(OutDir)strgen.exe %(Identity)
+ $(OutDir)strgen.exe
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Document
+ $(OutDir)strgen.exe %(Identity) src2\lib.c bc_lib bc_lib_name BC_ENABLED 1
+ src2\lib.c
+ $(OutDir)strgen.exe %(Identity) src2\lib.c bc_lib bc_lib_name BC_ENABLED 1
+ src2\lib.c
+ $(OutDir)strgen.exe %(Identity) src2\lib.c bc_lib bc_lib_name BC_ENABLED 1
+ src2\lib.c
+ $(OutDir)strgen.exe %(Identity) src2\lib.c bc_lib bc_lib_name BC_ENABLED 1
+ src2\lib.c
+
+
+
+
+ Document
+ $(OutDir)strgen.exe %(Identity) src2\lib2.c bc_lib2 bc_lib2_name BC_ENABLED 1
+ src2\lib2.c
+ $(OutDir)strgen.exe %(Identity) src2\lib2.c bc_lib2 bc_lib2_name BC_ENABLED 1
+ src2\lib2.c
+ $(OutDir)strgen.exe %(Identity) src2\lib2.c bc_lib2 bc_lib2_name BC_ENABLED 1
+ src2\lib2.c
+ $(OutDir)strgen.exe %(Identity) src2\lib2.c bc_lib2 bc_lib2_name BC_ENABLED 1
+ src2\lib2.c
+
+
+
+
+ $(OutDir)strgen.exe %(Identity) src2\dc_help.c dc_help "" DC_ENABLED
+ src2\dc_help.c
+ $(OutDir)strgen.exe %(Identity) src2\dc_help.c dc_help "" DC_ENABLED
+ src2\dc_help.c
+ $(OutDir)strgen.exe %(Identity) src2\dc_help.c dc_help "" DC_ENABLED
+ src2\dc_help.c
+ $(OutDir)strgen.exe %(Identity) src2\dc_help.c dc_help "" DC_ENABLED
+ src2\dc_help.c
+
+
+
+
+ $(OutDir)strgen.exe %(Identity) src2\bc_help.c bc_help "" BC_ENABLED
+ src2\bc_help.c
+ $(OutDir)strgen.exe %(Identity) src2\bc_help.c bc_help "" BC_ENABLED
+ src2\bc_help.c
+ $(OutDir)strgen.exe %(Identity) src2\bc_help.c bc_help "" BC_ENABLED
+ src2\bc_help.c
+ $(OutDir)strgen.exe %(Identity) src2\bc_help.c bc_help "" BC_ENABLED
+ src2\bc_help.c
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vs/bc.vcxproj.filters b/vs/bc.vcxproj.filters
new file mode 100644
index 000000000000..f26387253f27
--- /dev/null
+++ b/vs/bc.vcxproj.filters
@@ -0,0 +1,173 @@
+
+
+
+
+ {ef855c5b-fc2c-4736-bb38-346aae9184f7}
+
+
+ {df4ea0e1-2549-4c13-bf11-79ba8ba4cad9}
+
+
+ {1bbcb2e0-c1a0-417e-88bf-8eda8a53714e}
+
+
+ {c384b486-4ea2-473a-8b04-86f2f5f7bb69}
+
+
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src2
+
+
+ src2
+
+
+ src2
+
+
+ src2
+
+
+
+
+ gen
+
+
+ gen
+
+
+ gen
+
+
+ gen
+
+
+ gen
+
+
+
\ No newline at end of file
diff --git a/vs/bcl.sln b/vs/bcl.sln
new file mode 100644
index 000000000000..bc6d37a72360
--- /dev/null
+++ b/vs/bcl.sln
@@ -0,0 +1,37 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31515.178
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bcl", "bcl.vcxproj", "{76B451C9-72BF-45B2-B78D-B3515410F99F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ ReleaseMD|x64 = ReleaseMD|x64
+ ReleaseMD|x86 = ReleaseMD|x86
+ ReleaseMT|x64 = ReleaseMT|x64
+ ReleaseMT|x86 = ReleaseMT|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.Debug|x64.ActiveCfg = Debug|x64
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.Debug|x64.Build.0 = Debug|x64
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.Debug|x86.ActiveCfg = Debug|Win32
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.Debug|x86.Build.0 = Debug|Win32
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.ReleaseMD|x64.ActiveCfg = ReleaseMD|x64
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.ReleaseMD|x64.Build.0 = ReleaseMD|x64
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.ReleaseMD|x86.ActiveCfg = ReleaseMD|Win32
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.ReleaseMD|x86.Build.0 = ReleaseMD|Win32
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.ReleaseMT|x64.ActiveCfg = ReleaseMT|x64
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.ReleaseMT|x64.Build.0 = ReleaseMT|x64
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.ReleaseMT|x86.ActiveCfg = ReleaseMT|Win32
+ {76B451C9-72BF-45B2-B78D-B3515410F99F}.ReleaseMT|x86.Build.0 = ReleaseMT|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {C943D6A7-81EA-47C8-90D6-7DB528C262E7}
+ EndGlobalSection
+EndGlobal
diff --git a/vs/bcl.vcxproj b/vs/bcl.vcxproj
new file mode 100644
index 000000000000..a8de10e9f10b
--- /dev/null
+++ b/vs/bcl.vcxproj
@@ -0,0 +1,259 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ ReleaseMD
+ Win32
+
+
+ Debug
+ x64
+
+
+ ReleaseMD
+ x64
+
+
+ ReleaseMT
+ Win32
+
+
+ ReleaseMT
+ x64
+
+
+
+ 16.0
+ Win32Proj
+ {76b451c9-72bf-45b2-b78d-b3515410f99f}
+ bcl
+ 10.0
+
+
+
+ StaticLibrary
+ true
+ v142
+ Unicode
+
+
+ StaticLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+ StaticLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+ StaticLibrary
+ true
+ v142
+ Unicode
+
+
+ StaticLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+ StaticLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ lib\$(Platform)\$(Configuration)\
+ lib\$(Platform)\$(Configuration)\
+
+
+ false
+ lib\$(Platform)\$(Configuration)\
+ lib\$(Platform)\$(Configuration)\
+
+
+ false
+ lib\$(Platform)\$(Configuration)\
+ lib\$(Platform)\$(Configuration)\
+
+
+ true
+ lib\$(Platform)\$(Configuration)\
+ lib\$(Platform)\$(Configuration)\
+
+
+ false
+ lib\$(Platform)\$(Configuration)\
+ lib\$(Platform)\$(Configuration)\
+
+
+ false
+ lib\$(Platform)\$(Configuration)\
+ lib\$(Platform)\$(Configuration)\
+
+
+
+ Level3
+ true
+ BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ ..\include
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ ..\include
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ ..\include
+ MultiThreaded
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ ..\include
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ ..\include
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ ..\include
+ MultiThreaded
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vs/bcl.vcxproj.filters b/vs/bcl.vcxproj.filters
new file mode 100644
index 000000000000..b62d1899e2bf
--- /dev/null
+++ b/vs/bcl.vcxproj.filters
@@ -0,0 +1,90 @@
+
+
+
+
+ {4eccf85f-77c4-4ebd-b89c-3920075c5b2d}
+
+
+ {48fc3219-18c1-42d7-b9f4-da5f65ab1ccc}
+
+
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+ include
+
+
+
\ No newline at end of file
diff --git a/vs/bin/some.txt b/vs/bin/some.txt
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/vs/tests/some.txt b/vs/tests/some.txt
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/vs/tests/tests_bc.bat b/vs/tests/tests_bc.bat
new file mode 100644
index 000000000000..5fbd4e35fc3a
--- /dev/null
+++ b/vs/tests/tests_bc.bat
@@ -0,0 +1,104 @@
+@echo off
+
+set scripts=..\..\tests\bc
+set bc=%~dp0\bc.exe
+set args=-ql
+
+del /f /q *.txt > NUL
+
+
+rem excluded: all, errors, read_errors, posix_errors, misc6, misc7, recursive_arrays
+
+for %%i in (
+abs
+add
+arctangent
+arrays
+assignments
+bitfuncs
+boolean
+comp
+cosine
+decimal
+divide
+divmod
+engineering
+exponent
+functions
+globals
+length
+letters
+lib2
+log
+misc
+misc1
+misc2
+misc3
+misc4
+misc5
+modexp
+modulus
+multiply
+pi
+places
+power
+print2
+rand
+read
+scale
+scientific
+shift
+sine
+sqrt
+stdin
+stdin1
+stdin2
+strings
+subtract
+trunc
+vars
+void
+leadingzero
+) do (
+if exist "%scripts%\%%i.txt" (
+ "%bc%" "%args%" < "%scripts%\%%i.txt" > "%%i_results.txt"
+
+ if errorlevel 1 (
+ echo FAIL_RUNTIME: %%i
+ goto :eof
+ )
+
+ fc.exe "%scripts%\%%i_results.txt" "%%i_results.txt" > NUL
+
+ if errorlevel 1 (
+ echo FAIL_RESULTS: %%i
+ goto :eof
+ )
+
+ echo PASS: %%i
+) else (
+ echo FAIL_NOT_EXIST: %%i
+ goto :eof
+)
+)
+
+if exist "%scripts%\leadingzero.txt" (
+ "%bc%" "%args%" -z < "%scripts%\leadingzero.txt" > "leadingzero_z_results.txt"
+
+ if errorlevel 1 (
+ echo FAIL_RUNTIME: leadingzero_z
+ goto :eof
+ )
+
+ fc.exe "%scripts%\leadingzero_results.txt" "leadingzero_z_results.txt" > NUL
+
+ if errorlevel 1 (
+ echo FAIL_RESULTS: leadingzero_z
+ goto :eof
+ )
+
+ echo PASS: leadingzero_z
+) else (
+ echo FAIL_NOT_EXIST: leadingzero_z
+ goto :eof
+)
\ No newline at end of file
diff --git a/vs/tests/tests_dc.bat b/vs/tests/tests_dc.bat
new file mode 100644
index 000000000000..36c97daa4e11
--- /dev/null
+++ b/vs/tests/tests_dc.bat
@@ -0,0 +1,61 @@
+@echo off
+
+set scripts=..\..\tests\dc
+set dc=%~dp0\dc.exe
+set args=-x
+
+del /f /q *.txt > NUL
+
+
+rem excluded: all, errors, read_errors
+
+for %%i in (
+abs
+add
+boolean
+decimal
+divide
+divmod
+engineering
+exec_stack_len
+length
+misc
+modexp
+modulus
+multiply
+negate
+places
+power
+rand
+read
+scientific
+shift
+sqrt
+stack_len
+stdin
+strings
+subtract
+trunc
+vars
+) do (
+if exist "%scripts%\%%i.txt" (
+ "%dc%" "%args%" < "%scripts%\%%i.txt" > "%%i_results.txt"
+
+ if errorlevel 1 (
+ echo FAIL_RUNTIME: %%i
+ goto :eof
+ )
+
+ fc.exe "%scripts%\%%i_results.txt" "%%i_results.txt" > NUL
+
+ if errorlevel 1 (
+ echo FAIL_RESULTS: %%i
+ goto :eof
+ )
+
+ echo PASS: %%i
+) else (
+ echo FAIL_NOT_EXIST: %%i
+ goto :eof
+)
+)
\ No newline at end of file