diff options
author | Stefan Eßer <se@FreeBSD.org> | 2023-02-24 22:14:58 +0000 |
---|---|---|
committer | Stefan Eßer <se@FreeBSD.org> | 2023-02-24 22:14:58 +0000 |
commit | 61e1a12bb6c3bfdb0a4e499c88e8eaa2b548e427 (patch) | |
tree | 86bf7579a17d0deeccf9d4a705c36eed3b1e3273 | |
parent | aaf1213c6f70af0b517f6aa13cd837d3468a7a0d (diff) |
77 files changed, 442 insertions, 294 deletions
diff --git a/MEMORY_BUGS.md b/MEMORY_BUGS.md index d675b28b342a..12e0b854e9d8 100644 --- a/MEMORY_BUGS.md +++ b/MEMORY_BUGS.md @@ -51,3 +51,8 @@ existed in. had properly hooked Valgrind into my `bcl` tests, but I had not. The first version without this bug is `6.0.1`. + +* In version `6.0.0` until `6.2.4` (inclusive) of `bcl`, there is a possible + use-after-free if `bcl_init()` fails. + + The first version without this bug is `6.2.5`. diff --git a/Makefile.in b/Makefile.in index 83417a333826..89ddb7589c47 100644 --- a/Makefile.in +++ b/Makefile.in @@ -239,25 +239,25 @@ $(GEN_EXEC): $(GEN_DIR) %%GEN_EXEC_TARGET%% $(BC_LIB_C): $(GEN_EXEC) $(BC_LIB) - $(GEN_EMU) $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C) $(BC_EXCLUDE_EXTRA_MATH) $(BC_LIB_C_ARGS) + $(GEN_EMU) $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C) $(BC_EXCLUDE_EXTRA_MATH) $(BC_LIB_C_ARGS) "" "" 1 $(BC_LIB_O): $(BC_LIB_C) $(CC) $(CFLAGS) -o $@ -c $< $(BC_LIB2_C): $(GEN_EXEC) $(BC_LIB2) - $(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_EXCLUDE_EXTRA_MATH) $(BC_LIB2_C_ARGS) + $(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_EXCLUDE_EXTRA_MATH) $(BC_LIB2_C_ARGS) "" "" 1 $(BC_LIB2_O): $(BC_LIB2_C) $(CC) $(CFLAGS) -o $@ -c $< $(BC_HELP_C): $(GEN_EXEC) $(BC_HELP) - $(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) $(BC_EXCLUDE_EXTRA_MATH) bc_help "" $(BC_ENABLED_NAME) + $(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) $(BC_EXCLUDE_EXTRA_MATH) bc_help "" $(BC_ENABLED_NAME) 0 $(BC_HELP_O): $(BC_HELP_C) $(CC) $(CFLAGS) -o $@ -c $< $(DC_HELP_C): $(GEN_EXEC) $(DC_HELP) - $(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) $(BC_EXCLUDE_EXTRA_MATH) dc_help "" $(DC_ENABLED_NAME) + $(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) $(BC_EXCLUDE_EXTRA_MATH) dc_help "" $(DC_ENABLED_NAME) 0 $(DC_HELP_O): $(DC_HELP_C) $(CC) $(CFLAGS) -o $@ -c $< @@ -536,6 +536,7 @@ clean:%%CLEAN_PREREQS%% @$(RM) -f $(BC_HELP_C) $(BC_HELP_O) @$(RM) -f $(DC_HELP_C) $(DC_HELP_O) @$(RM) -fr vs/bin/ vs/lib/ + @$(RM) -f $(BCL_PC) clean_benchmarks: @printf 'Cleaning benchmarks...\n' @@ -548,6 +549,7 @@ clean_config: clean clean_benchmarks @$(RM) -f Makefile @$(RM) -f $(BC_MD) $(BC_MANPAGE) @$(RM) -f $(DC_MD) $(DC_MANPAGE) + @$(RM) -f compile_commands.json clean_coverage: @printf 'Cleaning coverage files...\n' @@ -1,5 +1,30 @@ # News +## 6.3.1 + +This is a production release that fixes a `bc` dependency loop for minimal +environments and Linux from Scratch. + +## 6.3.0 + +This is a production release with a couple of fixes for manuals and a new +feature for `dc`: there is now a command to query whether extended registers are +enabled or not. + +Users who don't care do not need to upgrade. + +## 6.2.6 + +This is a production release that fixes an install bug that affected locale +installation of all locales when using `mksh`. Users do ***NOT*** need to +upgrade if they don't use `mksh` and/or don't need to install all locales. + +## 6.2.5 + +This is a production release that fixes a test bug that affected Android and +`mksh`. Users do ***NOT*** need to upgrade unless they use `mksh` or another +affected shell and need to run the test suite. + ## 6.2.4 This is a production release that fixes a test failure that happens when diff --git a/gen/lib2.bc b/gen/lib2.bc index 826f8a430cea..2811430d534e 100644 --- a/gen/lib2.bc +++ b/gen/lib2.bc @@ -36,7 +36,7 @@ define p(x,y){ auto a a=y$ - if(y==a)return (x^a)@scale + if(y==a)return(x^a)@scale return e(y*l(x)) } define r(x,p){ @@ -474,7 +474,7 @@ define bxor(a,b){ return bunrev(t) } define bshl(a,b){return abs(a)$*2^abs(b)$} -define bshr(a,b){return (abs(a)$/2^abs(b)$)$} +define bshr(a,b){return(abs(a)$/2^abs(b)$)$} define bnotn(x,n){ auto s,t,m[] s=scale diff --git a/gen/strgen.c b/gen/strgen.c index dbea0212f617..2cb3ed9e8475 100644 --- a/gen/strgen.c +++ b/gen/strgen.c @@ -157,11 +157,11 @@ bc_read_file(const char* path) assert(path != NULL); -#ifndef NDEBUG +#if BC_DEBUG // Need this to quiet MSan. // NOLINTNEXTLINE memset(&pstat, 0, sizeof(struct stat)); -#endif // NDEBUG +#endif // BC_DEBUG fd = bc_read_open(path, O_RDONLY); @@ -360,7 +360,7 @@ main(int argc, char* argv[]) has_define = (argc > 6 && strcmp("", argv[6]) != 0); define = has_define ? argv[6] : ""; - remove_tabs = (argc > 7); + remove_tabs = (argc > 7 && atoi(argv[7]) != 0); in = bc_read_file(argv[1]); if (in == NULL) return INVALID_INPUT_FILE; diff --git a/gen/strgen.sh b/gen/strgen.sh index a65e221ad0b4..2b8927b5528e 100755 --- a/gen/strgen.sh +++ b/gen/strgen.sh @@ -62,7 +62,9 @@ name="$4" label="$5" define="$6" remove_tabs="$7" -check_bool_arg "$remove_tabs" +if [ "$remove_tabs" != "" ]; then + check_bool_arg "$remove_tabs" +fi tmpinput=$(mktemp -t "${input##*/}_XXXXXX") diff --git a/include/bcl.h b/include/bcl.h index 234fe475f00e..253138231c66 100644 --- a/include/bcl.h +++ b/include/bcl.h @@ -41,6 +41,12 @@ #include <limits.h> #include <stdint.h> +#ifndef NDEBUG +#define BC_DEBUG (1) +#else // NDEBUG +#define BC_DEBUG (0) +#endif // NDEBUG + #ifdef _WIN32 #include <Windows.h> #include <BaseTsd.h> diff --git a/include/lang.h b/include/lang.h index 2d9776532249..97aeeaa98da8 100644 --- a/include/lang.h +++ b/include/lang.h @@ -277,6 +277,9 @@ typedef enum BcInst #if DC_ENABLED + /// dc extended registers command. + BC_INST_EXTENDED_REGISTERS, + /// dc's return; it pops an executing string off of the stack. BC_INST_POP_EXEC, @@ -575,7 +578,7 @@ bc_func_insert(BcFunc* f, struct BcProgram* p, char* name, BcType type, void bc_func_reset(BcFunc* f); -#ifndef NDEBUG +#if BC_DEBUG /** * Frees a function. This is a destructor. This is only used in debug builds * because all functions are freed at exit. We free them in debug builds to @@ -584,7 +587,7 @@ bc_func_reset(BcFunc* f); */ void bc_func_free(void* func); -#endif // NDEBUG +#endif // BC_DEBUG /** * Initializes an array, which is the array type in bc and dc source code. Since diff --git a/include/lex.h b/include/lex.h index 54d704f8b447..ac9b7b6ea69c 100644 --- a/include/lex.h +++ b/include/lex.h @@ -49,11 +49,11 @@ * @param l The lexer. * @param e The error. */ -#ifndef NDEBUG +#if BC_DEBUG #define bc_lex_err(l, e) (bc_vm_handleError((e), __FILE__, __LINE__, (l)->line)) -#else // NDEBUG +#else // BC_DEBUG #define bc_lex_err(l, e) (bc_vm_handleError((e), (l)->line)) -#endif // NDEBUG +#endif // BC_DEBUG /** * A convenience macro for throwing errors in lex code. This takes care of @@ -61,12 +61,12 @@ * @param l The lexer. * @param e The error. */ -#ifndef NDEBUG +#if BC_DEBUG #define bc_lex_verr(l, e, ...) \ (bc_vm_handleError((e), __FILE__, __LINE__, (l)->line, __VA_ARGS__)) -#else // NDEBUG +#else // BC_DEBUG #define bc_lex_verr(l, e, ...) (bc_vm_handleError((e), (l)->line, __VA_ARGS__)) -#endif // NDEBUG +#endif // BC_DEBUG // BC_LEX_NEG_CHAR returns the char that corresponds to negative for the // current calculator. @@ -409,6 +409,9 @@ typedef enum BcLexType #if DC_ENABLED + /// dc extended registers keyword. + BC_LEX_EXTENDED_REGISTERS, + /// A special token for dc to calculate equal without a register. BC_LEX_EQ_NO_REG, @@ -533,7 +536,7 @@ void bc_lex_init(BcLex* l); /** - * Frees a lexer. This is not guarded by #ifndef NDEBUG because a separate + * Frees a lexer. This is not guarded by #if BC_DEBUG because a separate * parser is created at runtime to parse read() expressions and dc strings, and * that parser needs a lexer. * @param l The lexer to free. diff --git a/include/parse.h b/include/parse.h index 2527aeb824f8..ece413e7bd74 100644 --- a/include/parse.h +++ b/include/parse.h @@ -110,12 +110,12 @@ * @param p The parser. * @param e The error. */ -#ifndef NDEBUG +#if BC_DEBUG #define bc_parse_err(p, e) \ (bc_vm_handleError((e), __FILE__, __LINE__, (p)->l.line)) -#else // NDEBUG +#else // BC_DEBUG #define bc_parse_err(p, e) (bc_vm_handleError((e), (p)->l.line)) -#endif // NDEBUG +#endif // BC_DEBUG /** * A convenience macro for throwing errors in parse code. This takes care of @@ -124,13 +124,13 @@ * @param e The error. * @param ... The varags that are needed. */ -#ifndef NDEBUG +#if BC_DEBUG #define bc_parse_verr(p, e, ...) \ (bc_vm_handleError((e), __FILE__, __LINE__, (p)->l.line, __VA_ARGS__)) -#else // NDEBUG +#else // BC_DEBUG #define bc_parse_verr(p, e, ...) \ (bc_vm_handleError((e), (p)->l.line, __VA_ARGS__)) -#endif // NDEBUG +#endif // BC_DEBUG // Forward declarations. struct BcParse; @@ -215,7 +215,7 @@ void bc_parse_init(BcParse* p, struct BcProgram* prog, size_t func); /** - * Frees a parser. This is not guarded by #ifndef NDEBUG because a separate + * Frees a parser. This is not guarded by #if BC_DEBUG because a separate * parser is created at runtime to parse read() expressions and dc strings. * @param p The parser to free. */ diff --git a/include/program.h b/include/program.h index 3a3ea6c9dab7..ff32d5db7760 100644 --- a/include/program.h +++ b/include/program.h @@ -247,9 +247,9 @@ typedef struct BcProgram // In debug mode, we want bc to check the stack, but otherwise, we don't because // the bc language implicitly mandates that the stack should always have enough // items. -#ifdef NDEBUG +#ifdef BC_DEBUG #define BC_PROG_NO_STACK_CHECK -#endif // NDEBUG +#endif // BC_DEBUG #endif // DC_ENABLED @@ -298,7 +298,7 @@ typedef void (*BcProgramUnary)(BcResult* r, BcNum* n); void bc_program_init(BcProgram* p); -#ifndef NDEBUG +#if BC_DEBUG /** * Frees a BcProgram. This is only used in debug builds because a BcProgram is @@ -309,7 +309,7 @@ bc_program_init(BcProgram* p); void bc_program_free(BcProgram* p); -#endif // NDEBUG +#endif // BC_DEBUG /** * Prints a stack trace of the bc functions or dc strings currently executing. @@ -608,6 +608,7 @@ extern const char bc_program_esc_seqs[]; &&lbl_BC_INST_MODEXP, \ &&lbl_BC_INST_DIVMOD, \ &&lbl_BC_INST_PRINT_STREAM, \ + &&lbl_BC_INST_EXTENDED_REGISTERS, \ &&lbl_BC_INST_POP_EXEC, \ &&lbl_BC_INST_EXECUTE, \ &&lbl_BC_INST_EXEC_COND, \ @@ -701,6 +702,7 @@ extern const char bc_program_esc_seqs[]; &&lbl_BC_INST_MODEXP, \ &&lbl_BC_INST_DIVMOD, \ &&lbl_BC_INST_PRINT_STREAM, \ + &&lbl_BC_INST_EXTENDED_REGISTERS, \ &&lbl_BC_INST_POP_EXEC, \ &&lbl_BC_INST_EXECUTE, \ &&lbl_BC_INST_EXEC_COND, \ @@ -959,6 +961,7 @@ extern const char bc_program_esc_seqs[]; &&lbl_BC_INST_MODEXP, \ &&lbl_BC_INST_DIVMOD, \ &&lbl_BC_INST_PRINT_STREAM, \ + &&lbl_BC_INST_EXTENDED_REGISTERS, \ &&lbl_BC_INST_POP_EXEC, \ &&lbl_BC_INST_EXECUTE, \ &&lbl_BC_INST_EXEC_COND, \ @@ -1027,6 +1030,7 @@ extern const char bc_program_esc_seqs[]; &&lbl_BC_INST_MODEXP, \ &&lbl_BC_INST_DIVMOD, \ &&lbl_BC_INST_PRINT_STREAM, \ + &&lbl_BC_INST_EXTENDED_REGISTERS, \ &&lbl_BC_INST_POP_EXEC, \ &&lbl_BC_INST_EXECUTE, \ &&lbl_BC_INST_EXEC_COND, \ diff --git a/include/rand.h b/include/rand.h index 7db0ee90af1f..e516295d7c5c 100644 --- a/include/rand.h +++ b/include/rand.h @@ -53,11 +53,11 @@ #if BC_ENABLE_LIBRARY #define BC_RAND_USE_FREE (1) #else // BC_ENABLE_LIBRARY -#ifndef NDEBUG +#if BC_DEBUG #define BC_RAND_USE_FREE (1) -#else // NDEBUG +#else // BC_DEBUG #define BC_RAND_USE_FREE (0) -#endif // NDEBUG +#endif // BC_DEBUG #endif // BC_ENABLE_LIBRARY /** diff --git a/include/status.h b/include/status.h index 9962d58d0be0..198cf5704a57 100644 --- a/include/status.h +++ b/include/status.h @@ -700,7 +700,7 @@ typedef enum BcMode #define BC_SIG_INTERRUPT(vm) BC_UNLIKELY((vm)->sig != 0) #endif // _WIN32 -#ifndef NDEBUG +#if BC_DEBUG /// Assert that signals are locked. There are non-async-signal-safe functions in /// bc, and they *must* have signals locked. Other functions are expected to @@ -724,7 +724,7 @@ typedef enum BcMode } \ while (0) -#else // NDEBUG +#else // BC_DEBUG /// Assert that signals are locked. There are non-async-signal-safe functions in /// bc, and they *must* have signals locked. Other functions are expected to @@ -738,7 +738,7 @@ typedef enum BcMode /// (no-op in non-debug mode) that check that signals are unlocked. #define BC_SIG_ASSERT_NOT_LOCKED -#endif // NDEBUG +#endif // BC_DEBUG /// Locks signals. #define BC_SIG_LOCK \ @@ -957,33 +957,33 @@ typedef enum BcMode * @param l The line of the script that the error happened. * @param ... Extra arguments for error messages as necessary. */ -#ifndef NDEBUG +#if BC_DEBUG #define bc_error(e, l, ...) \ (bc_vm_handleError((e), __FILE__, __LINE__, (l), __VA_ARGS__)) -#else // NDEBUG +#else // BC_DEBUG #define bc_error(e, l, ...) (bc_vm_handleError((e), (l), __VA_ARGS__)) -#endif // NDEBUG +#endif // BC_DEBUG /** * Call bc's error handling routine. * @param e The error. */ -#ifndef NDEBUG +#if BC_DEBUG #define bc_err(e) (bc_vm_handleError((e), __FILE__, __LINE__, 0)) -#else // NDEBUG +#else // BC_DEBUG #define bc_err(e) (bc_vm_handleError((e), 0)) -#endif // NDEBUG +#endif // BC_DEBUG /** * Call bc's error handling routine. * @param e The error. */ -#ifndef NDEBUG +#if BC_DEBUG #define bc_verr(e, ...) \ (bc_vm_handleError((e), __FILE__, __LINE__, 0, __VA_ARGS__)) -#else // NDEBUG +#else // BC_DEBUG #define bc_verr(e, ...) (bc_vm_handleError((e), 0, __VA_ARGS__)) -#endif // NDEBUG +#endif // BC_DEBUG #endif // BC_ENABLE_LIBRARY diff --git a/include/vector.h b/include/vector.h index 51c5e8b95293..b86be1424537 100644 --- a/include/vector.h +++ b/include/vector.h @@ -85,12 +85,12 @@ typedef enum BcDtorType #if !BC_ENABLE_LIBRARY -#ifndef NDEBUG +#if BC_DEBUG /// BcFunc destructor. BC_DTOR_FUNC, -#endif // NDEBUG +#endif // BC_DEBUG /// BcSlab destructor. BC_DTOR_SLAB, diff --git a/include/version.h b/include/version.h index 6d8ddfea0940..f5e345b3b189 100644 --- a/include/version.h +++ b/include/version.h @@ -37,6 +37,6 @@ #define BC_VERSION_H /// The current version. -#define VERSION 6.2.4 +#define VERSION 6.3.1 #endif // BC_VERSION_H diff --git a/include/vm.h b/include/vm.h index 1c303add2de0..dd21d43f5260 100644 --- a/include/vm.h +++ b/include/vm.h @@ -999,7 +999,7 @@ bc_vm_atexit(void); size_t bc_vm_numDigits(size_t val); -#ifndef NDEBUG +#if BC_DEBUG /** * Handle an error. This is the true error handler. It will start a jump series @@ -1013,7 +1013,7 @@ bc_vm_numDigits(size_t val); void bc_vm_handleError(BcErr e, const char* file, int fline, size_t line, ...); -#else // NDEBUG +#else // BC_DEBUG /** * Handle an error. This is the true error handler. It will start a jump series @@ -1025,7 +1025,7 @@ bc_vm_handleError(BcErr e, const char* file, int fline, size_t line, ...); void bc_vm_handleError(BcErr e, size_t line, ...); -#endif // NDEBUG +#endif // BC_DEBUG /** * Handle a fatal error. diff --git a/manuals/bc/A.1 b/manuals/bc/A.1 index b1996a1f282e..5de2d3529bcf 100644 --- a/manuals/bc/A.1 +++ b/manuals/bc/A.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH NAME @@ -477,8 +477,8 @@ Makes bc(1) print all numbers greater than \f[B]-1\f[R] and less than .RS .PP This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). +\f[B]plznl(x)\f[R], \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions +in the extended math library (see the \f[B]LIBRARY\f[R] section). .PP This is a \f[B]non-portable extension\f[R]. .RE diff --git a/manuals/bc/A.1.md b/manuals/bc/A.1.md index e7b4c8212190..3f34f451c9ed 100644 --- a/manuals/bc/A.1.md +++ b/manuals/bc/A.1.md @@ -372,7 +372,7 @@ The following are the options that bc(1) accepts. : Makes bc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, + This can be set for individual numbers with the **plz(x)**, **plznl(x)**, **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see the **LIBRARY** section). diff --git a/manuals/bc/E.1 b/manuals/bc/E.1 index fea1cecdc4c5..ecb8b128712a 100644 --- a/manuals/bc/E.1 +++ b/manuals/bc/E.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH NAME @@ -433,8 +433,8 @@ Makes bc(1) print all numbers greater than \f[B]-1\f[R] and less than .RS .PP This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). +\f[B]plznl(x)\f[R], \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions +in the extended math library (see the \f[B]LIBRARY\f[R] section). .PP This is a \f[B]non-portable extension\f[R]. .RE diff --git a/manuals/bc/E.1.md b/manuals/bc/E.1.md index 3631267f2dc9..5411dcf6cc70 100644 --- a/manuals/bc/E.1.md +++ b/manuals/bc/E.1.md @@ -344,7 +344,7 @@ The following are the options that bc(1) accepts. : Makes bc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, + This can be set for individual numbers with the **plz(x)**, **plznl(x)**, **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see the **LIBRARY** section). diff --git a/manuals/bc/EH.1 b/manuals/bc/EH.1 index 2a36cab7f778..507e7f4a9a7a 100644 --- a/manuals/bc/EH.1 +++ b/manuals/bc/EH.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH NAME @@ -433,8 +433,8 @@ Makes bc(1) print all numbers greater than \f[B]-1\f[R] and less than .RS .PP This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). +\f[B]plznl(x)\f[R], \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions +in the extended math library (see the \f[B]LIBRARY\f[R] section). .PP This is a \f[B]non-portable extension\f[R]. .RE diff --git a/manuals/bc/EH.1.md b/manuals/bc/EH.1.md index f2f49ea76944..6f4c43263003 100644 --- a/manuals/bc/EH.1.md +++ b/manuals/bc/EH.1.md @@ -344,7 +344,7 @@ The following are the options that bc(1) accepts. : Makes bc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, + This can be set for individual numbers with the **plz(x)**, **plznl(x)**, **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see the **LIBRARY** section). diff --git a/manuals/bc/EHN.1 b/manuals/bc/EHN.1 index 75768a03c141..e00fcd578b1c 100644 --- a/manuals/bc/EHN.1 +++ b/manuals/bc/EHN.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH NAME @@ -433,8 +433,8 @@ Makes bc(1) print all numbers greater than \f[B]-1\f[R] and less than .RS .PP This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). +\f[B]plznl(x)\f[R], \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions +in the extended math library (see the \f[B]LIBRARY\f[R] section). .PP This is a \f[B]non-portable extension\f[R]. .RE diff --git a/manuals/bc/EHN.1.md b/manuals/bc/EHN.1.md index a38503cc8a24..6f7a33210205 100644 --- a/manuals/bc/EHN.1.md +++ b/manuals/bc/EHN.1.md @@ -344,7 +344,7 @@ The following are the options that bc(1) accepts. : Makes bc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, + This can be set for individual numbers with the **plz(x)**, **plznl(x)**, **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see the **LIBRARY** section). diff --git a/manuals/bc/EN.1 b/manuals/bc/EN.1 index 9c0158583199..ea842eac7e97 100644 --- a/manuals/bc/EN.1 +++ b/manuals/bc/EN.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH NAME @@ -433,8 +433,8 @@ Makes bc(1) print all numbers greater than \f[B]-1\f[R] and less than .RS .PP This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). +\f[B]plznl(x)\f[R], \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions +in the extended math library (see the \f[B]LIBRARY\f[R] section). .PP This is a \f[B]non-portable extension\f[R]. .RE diff --git a/manuals/bc/EN.1.md b/manuals/bc/EN.1.md index 28b558d8b21d..189193bf2a03 100644 --- a/manuals/bc/EN.1.md +++ b/manuals/bc/EN.1.md @@ -344,7 +344,7 @@ The following are the options that bc(1) accepts. : Makes bc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, + This can be set for individual numbers with the **plz(x)**, **plznl(x)**, **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see the **LIBRARY** section). diff --git a/manuals/bc/H.1 b/manuals/bc/H.1 index cbd93da0df81..d477dc8ab24b 100644 --- a/manuals/bc/H.1 +++ b/manuals/bc/H.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH NAME @@ -477,8 +477,8 @@ Makes bc(1) print all numbers greater than \f[B]-1\f[R] and less than .RS .PP This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). +\f[B]plznl(x)\f[R], \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions +in the extended math library (see the \f[B]LIBRARY\f[R] section). .PP This is a \f[B]non-portable extension\f[R]. .RE diff --git a/manuals/bc/H.1.md b/manuals/bc/H.1.md index ac35def9019f..2cb0b4eb27cc 100644 --- a/manuals/bc/H.1.md +++ b/manuals/bc/H.1.md @@ -372,7 +372,7 @@ The following are the options that bc(1) accepts. : Makes bc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, + This can be set for individual numbers with the **plz(x)**, **plznl(x)**, **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see the **LIBRARY** section). diff --git a/manuals/bc/HN.1 b/manuals/bc/HN.1 index 5893d2a7f9a9..10d9621c42ee 100644 --- a/manuals/bc/HN.1 +++ b/manuals/bc/HN.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH NAME @@ -477,8 +477,8 @@ Makes bc(1) print all numbers greater than \f[B]-1\f[R] and less than .RS .PP This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). +\f[B]plznl(x)\f[R], \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions +in the extended math library (see the \f[B]LIBRARY\f[R] section). .PP This is a \f[B]non-portable extension\f[R]. .RE diff --git a/manuals/bc/HN.1.md b/manuals/bc/HN.1.md index 82a99addd344..25f136a21e0a 100644 --- a/manuals/bc/HN.1.md +++ b/manuals/bc/HN.1.md @@ -372,7 +372,7 @@ The following are the options that bc(1) accepts. : Makes bc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, + This can be set for individual numbers with the **plz(x)**, **plznl(x)**, **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see the **LIBRARY** section). diff --git a/manuals/bc/N.1 b/manuals/bc/N.1 index 791f47407001..f39e51277b65 100644 --- a/manuals/bc/N.1 +++ b/manuals/bc/N.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH NAME @@ -477,8 +477,8 @@ Makes bc(1) print all numbers greater than \f[B]-1\f[R] and less than .RS .PP This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). +\f[B]plznl(x)\f[R], \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions +in the extended math library (see the \f[B]LIBRARY\f[R] section). .PP This is a \f[B]non-portable extension\f[R]. .RE diff --git a/manuals/bc/N.1.md b/manuals/bc/N.1.md index b8339ea31a5e..56a4b2274d29 100644 --- a/manuals/bc/N.1.md +++ b/manuals/bc/N.1.md @@ -372,7 +372,7 @@ The following are the options that bc(1) accepts. : Makes bc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, + This can be set for individual numbers with the **plz(x)**, **plznl(x)**, **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see the **LIBRARY** section). diff --git a/manuals/bcl.3 b/manuals/bcl.3 index 6bebaa8f02cd..5c3731a141eb 100644 --- a/manuals/bcl.3 +++ b/manuals/bcl.3 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BCL" "3" "October 2022" "Gavin D. Howard" "Libraries Manual" +.TH "BCL" "3" "February 2023" "Gavin D. Howard" "Libraries Manual" .nh .ad l .SH NAME diff --git a/manuals/dc/A.1 b/manuals/dc/A.1 index 13ed8c4cf808..bef54876d7f2 100644 --- a/manuals/dc/A.1 +++ b/manuals/dc/A.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "DC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH Name @@ -271,10 +271,6 @@ Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than \f[B]1\f[R], and not equal to \f[B]0\f[R], with a leading zero. .RS .PP -This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). -.PP This is a \f[B]non-portable extension\f[R]. .RE .PP @@ -1255,6 +1251,12 @@ section). Pushes the line length set by \f[B]DC_LINE_LENGTH\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section) onto the stack. .TP +\f[B]gx\f[R] +Pushes \f[B]1\f[R] onto the stack if extended register mode is on, +\f[B]0\f[R] otherwise. +See the \f[I]Extended Register Mode\f[R] subsection of the +\f[B]REGISTERS\f[R] section for more information. +.TP \f[B]gz\f[R] Pushes \f[B]0\f[R] onto the stack if the leading zero setting has not been enabled with the \f[B]-z\f[R] or \f[B]--leading-zeroes\f[R] options diff --git a/manuals/dc/A.1.md b/manuals/dc/A.1.md index b656650cb820..44b1578b670c 100644 --- a/manuals/dc/A.1.md +++ b/manuals/dc/A.1.md @@ -224,10 +224,6 @@ The following are the options that dc(1) accepts. : Makes dc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, - **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see - the **LIBRARY** section). - This is a **non-portable extension**. All long options are **non-portable extensions**. @@ -1087,6 +1083,12 @@ other character produces a parse error (see the **ERRORS** section). : Pushes the line length set by **DC_LINE_LENGTH** (see the **ENVIRONMENT VARIABLES** section) onto the stack. +**gx** + +: Pushes **1** onto the stack if extended register mode is on, **0** + otherwise. See the *Extended Register Mode* subsection of the **REGISTERS** + section for more information. + **gz** : Pushes **0** onto the stack if the leading zero setting has not been enabled diff --git a/manuals/dc/E.1 b/manuals/dc/E.1 index 3fb69dfe70da..41de5e08f743 100644 --- a/manuals/dc/E.1 +++ b/manuals/dc/E.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "DC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH Name @@ -256,10 +256,6 @@ Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than \f[B]1\f[R], and not equal to \f[B]0\f[R], with a leading zero. .RS .PP -This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). -.PP This is a \f[B]non-portable extension\f[R]. .RE .PP @@ -1040,6 +1036,12 @@ section). Pushes the line length set by \f[B]DC_LINE_LENGTH\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section) onto the stack. .TP +\f[B]gx\f[R] +Pushes \f[B]1\f[R] onto the stack if extended register mode is on, +\f[B]0\f[R] otherwise. +See the \f[I]Extended Register Mode\f[R] subsection of the +\f[B]REGISTERS\f[R] section for more information. +.TP \f[B]gz\f[R] Pushes \f[B]0\f[R] onto the stack if the leading zero setting has not been enabled with the \f[B]-z\f[R] or \f[B]--leading-zeroes\f[R] options diff --git a/manuals/dc/E.1.md b/manuals/dc/E.1.md index 0bbe97612889..8a172d8a124b 100644 --- a/manuals/dc/E.1.md +++ b/manuals/dc/E.1.md @@ -215,10 +215,6 @@ The following are the options that dc(1) accepts. : Makes dc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, - **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see - the **LIBRARY** section). - This is a **non-portable extension**. All long options are **non-portable extensions**. @@ -918,6 +914,12 @@ other character produces a parse error (see the **ERRORS** section). : Pushes the line length set by **DC_LINE_LENGTH** (see the **ENVIRONMENT VARIABLES** section) onto the stack. +**gx** + +: Pushes **1** onto the stack if extended register mode is on, **0** + otherwise. See the *Extended Register Mode* subsection of the **REGISTERS** + section for more information. + **gz** : Pushes **0** onto the stack if the leading zero setting has not been enabled diff --git a/manuals/dc/EH.1 b/manuals/dc/EH.1 index da7776edd538..08cb483dc926 100644 --- a/manuals/dc/EH.1 +++ b/manuals/dc/EH.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "DC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH Name @@ -256,10 +256,6 @@ Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than \f[B]1\f[R], and not equal to \f[B]0\f[R], with a leading zero. .RS .PP -This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). -.PP This is a \f[B]non-portable extension\f[R]. .RE .PP @@ -1040,6 +1036,12 @@ section). Pushes the line length set by \f[B]DC_LINE_LENGTH\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section) onto the stack. .TP +\f[B]gx\f[R] +Pushes \f[B]1\f[R] onto the stack if extended register mode is on, +\f[B]0\f[R] otherwise. +See the \f[I]Extended Register Mode\f[R] subsection of the +\f[B]REGISTERS\f[R] section for more information. +.TP \f[B]gz\f[R] Pushes \f[B]0\f[R] onto the stack if the leading zero setting has not been enabled with the \f[B]-z\f[R] or \f[B]--leading-zeroes\f[R] options diff --git a/manuals/dc/EH.1.md b/manuals/dc/EH.1.md index 0751d3f78d21..1c5b6f566b19 100644 --- a/manuals/dc/EH.1.md +++ b/manuals/dc/EH.1.md @@ -215,10 +215,6 @@ The following are the options that dc(1) accepts. : Makes dc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, - **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see - the **LIBRARY** section). - This is a **non-portable extension**. All long options are **non-portable extensions**. @@ -918,6 +914,12 @@ other character produces a parse error (see the **ERRORS** section). : Pushes the line length set by **DC_LINE_LENGTH** (see the **ENVIRONMENT VARIABLES** section) onto the stack. +**gx** + +: Pushes **1** onto the stack if extended register mode is on, **0** + otherwise. See the *Extended Register Mode* subsection of the **REGISTERS** + section for more information. + **gz** : Pushes **0** onto the stack if the leading zero setting has not been enabled diff --git a/manuals/dc/EHN.1 b/manuals/dc/EHN.1 index 10ef283ea056..efeb0bbaecf9 100644 --- a/manuals/dc/EHN.1 +++ b/manuals/dc/EHN.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "DC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH Name @@ -256,10 +256,6 @@ Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than \f[B]1\f[R], and not equal to \f[B]0\f[R], with a leading zero. .RS .PP -This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). -.PP This is a \f[B]non-portable extension\f[R]. .RE .PP @@ -1040,6 +1036,12 @@ section). Pushes the line length set by \f[B]DC_LINE_LENGTH\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section) onto the stack. .TP +\f[B]gx\f[R] +Pushes \f[B]1\f[R] onto the stack if extended register mode is on, +\f[B]0\f[R] otherwise. +See the \f[I]Extended Register Mode\f[R] subsection of the +\f[B]REGISTERS\f[R] section for more information. +.TP \f[B]gz\f[R] Pushes \f[B]0\f[R] onto the stack if the leading zero setting has not been enabled with the \f[B]-z\f[R] or \f[B]--leading-zeroes\f[R] options diff --git a/manuals/dc/EHN.1.md b/manuals/dc/EHN.1.md index 9ba7fe13e0ad..8a3c6d2b7807 100644 --- a/manuals/dc/EHN.1.md +++ b/manuals/dc/EHN.1.md @@ -215,10 +215,6 @@ The following are the options that dc(1) accepts. : Makes dc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, - **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see - the **LIBRARY** section). - This is a **non-portable extension**. All long options are **non-portable extensions**. @@ -918,6 +914,12 @@ other character produces a parse error (see the **ERRORS** section). : Pushes the line length set by **DC_LINE_LENGTH** (see the **ENVIRONMENT VARIABLES** section) onto the stack. +**gx** + +: Pushes **1** onto the stack if extended register mode is on, **0** + otherwise. See the *Extended Register Mode* subsection of the **REGISTERS** + section for more information. + **gz** : Pushes **0** onto the stack if the leading zero setting has not been enabled diff --git a/manuals/dc/EN.1 b/manuals/dc/EN.1 index abdcbe8c63f8..ce1e6b9be79c 100644 --- a/manuals/dc/EN.1 +++ b/manuals/dc/EN.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "DC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH Name @@ -256,10 +256,6 @@ Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than \f[B]1\f[R], and not equal to \f[B]0\f[R], with a leading zero. .RS .PP -This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). -.PP This is a \f[B]non-portable extension\f[R]. .RE .PP @@ -1040,6 +1036,12 @@ section). Pushes the line length set by \f[B]DC_LINE_LENGTH\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section) onto the stack. .TP +\f[B]gx\f[R] +Pushes \f[B]1\f[R] onto the stack if extended register mode is on, +\f[B]0\f[R] otherwise. +See the \f[I]Extended Register Mode\f[R] subsection of the +\f[B]REGISTERS\f[R] section for more information. +.TP \f[B]gz\f[R] Pushes \f[B]0\f[R] onto the stack if the leading zero setting has not been enabled with the \f[B]-z\f[R] or \f[B]--leading-zeroes\f[R] options diff --git a/manuals/dc/EN.1.md b/manuals/dc/EN.1.md index 5c0590c53aee..f8deee533c4e 100644 --- a/manuals/dc/EN.1.md +++ b/manuals/dc/EN.1.md @@ -215,10 +215,6 @@ The following are the options that dc(1) accepts. : Makes dc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, - **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see - the **LIBRARY** section). - This is a **non-portable extension**. All long options are **non-portable extensions**. @@ -918,6 +914,12 @@ other character produces a parse error (see the **ERRORS** section). : Pushes the line length set by **DC_LINE_LENGTH** (see the **ENVIRONMENT VARIABLES** section) onto the stack. +**gx** + +: Pushes **1** onto the stack if extended register mode is on, **0** + otherwise. See the *Extended Register Mode* subsection of the **REGISTERS** + section for more information. + **gz** : Pushes **0** onto the stack if the leading zero setting has not been enabled diff --git a/manuals/dc/H.1 b/manuals/dc/H.1 index c96100e51bc5..8baa0b74316e 100644 --- a/manuals/dc/H.1 +++ b/manuals/dc/H.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "DC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH Name @@ -271,10 +271,6 @@ Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than \f[B]1\f[R], and not equal to \f[B]0\f[R], with a leading zero. .RS .PP -This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). -.PP This is a \f[B]non-portable extension\f[R]. .RE .PP @@ -1255,6 +1251,12 @@ section). Pushes the line length set by \f[B]DC_LINE_LENGTH\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section) onto the stack. .TP +\f[B]gx\f[R] +Pushes \f[B]1\f[R] onto the stack if extended register mode is on, +\f[B]0\f[R] otherwise. +See the \f[I]Extended Register Mode\f[R] subsection of the +\f[B]REGISTERS\f[R] section for more information. +.TP \f[B]gz\f[R] Pushes \f[B]0\f[R] onto the stack if the leading zero setting has not been enabled with the \f[B]-z\f[R] or \f[B]--leading-zeroes\f[R] options diff --git a/manuals/dc/H.1.md b/manuals/dc/H.1.md index 0dddf66d700a..7166c155efa3 100644 --- a/manuals/dc/H.1.md +++ b/manuals/dc/H.1.md @@ -224,10 +224,6 @@ The following are the options that dc(1) accepts. : Makes dc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, - **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see - the **LIBRARY** section). - This is a **non-portable extension**. All long options are **non-portable extensions**. @@ -1087,6 +1083,12 @@ other character produces a parse error (see the **ERRORS** section). : Pushes the line length set by **DC_LINE_LENGTH** (see the **ENVIRONMENT VARIABLES** section) onto the stack. +**gx** + +: Pushes **1** onto the stack if extended register mode is on, **0** + otherwise. See the *Extended Register Mode* subsection of the **REGISTERS** + section for more information. + **gz** : Pushes **0** onto the stack if the leading zero setting has not been enabled diff --git a/manuals/dc/HN.1 b/manuals/dc/HN.1 index a6644ecd575b..2a3926309868 100644 --- a/manuals/dc/HN.1 +++ b/manuals/dc/HN.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "DC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH Name @@ -271,10 +271,6 @@ Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than \f[B]1\f[R], and not equal to \f[B]0\f[R], with a leading zero. .RS .PP -This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). -.PP This is a \f[B]non-portable extension\f[R]. .RE .PP @@ -1255,6 +1251,12 @@ section). Pushes the line length set by \f[B]DC_LINE_LENGTH\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section) onto the stack. .TP +\f[B]gx\f[R] +Pushes \f[B]1\f[R] onto the stack if extended register mode is on, +\f[B]0\f[R] otherwise. +See the \f[I]Extended Register Mode\f[R] subsection of the +\f[B]REGISTERS\f[R] section for more information. +.TP \f[B]gz\f[R] Pushes \f[B]0\f[R] onto the stack if the leading zero setting has not been enabled with the \f[B]-z\f[R] or \f[B]--leading-zeroes\f[R] options diff --git a/manuals/dc/HN.1.md b/manuals/dc/HN.1.md index d39a7497d3ac..6239a12b2861 100644 --- a/manuals/dc/HN.1.md +++ b/manuals/dc/HN.1.md @@ -224,10 +224,6 @@ The following are the options that dc(1) accepts. : Makes dc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, - **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see - the **LIBRARY** section). - This is a **non-portable extension**. All long options are **non-portable extensions**. @@ -1087,6 +1083,12 @@ other character produces a parse error (see the **ERRORS** section). : Pushes the line length set by **DC_LINE_LENGTH** (see the **ENVIRONMENT VARIABLES** section) onto the stack. +**gx** + +: Pushes **1** onto the stack if extended register mode is on, **0** + otherwise. See the *Extended Register Mode* subsection of the **REGISTERS** + section for more information. + **gz** : Pushes **0** onto the stack if the leading zero setting has not been enabled diff --git a/manuals/dc/N.1 b/manuals/dc/N.1 index f9aeb1acfb6c..b7b501fbed13 100644 --- a/manuals/dc/N.1 +++ b/manuals/dc/N.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "DC" "1" "October 2022" "Gavin D. Howard" "General Commands Manual" +.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual" .nh .ad l .SH Name @@ -271,10 +271,6 @@ Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than \f[B]1\f[R], and not equal to \f[B]0\f[R], with a leading zero. .RS .PP -This can be set for individual numbers with the \f[B]plz(x)\f[R], -plznl(x)**, \f[B]pnlz(x)\f[R], and \f[B]pnlznl(x)\f[R] functions in the -extended math library (see the \f[B]LIBRARY\f[R] section). -.PP This is a \f[B]non-portable extension\f[R]. .RE .PP @@ -1255,6 +1251,12 @@ section). Pushes the line length set by \f[B]DC_LINE_LENGTH\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section) onto the stack. .TP +\f[B]gx\f[R] +Pushes \f[B]1\f[R] onto the stack if extended register mode is on, +\f[B]0\f[R] otherwise. +See the \f[I]Extended Register Mode\f[R] subsection of the +\f[B]REGISTERS\f[R] section for more information. +.TP \f[B]gz\f[R] Pushes \f[B]0\f[R] onto the stack if the leading zero setting has not been enabled with the \f[B]-z\f[R] or \f[B]--leading-zeroes\f[R] options diff --git a/manuals/dc/N.1.md b/manuals/dc/N.1.md index 3c36661d3902..8795d947eec7 100644 --- a/manuals/dc/N.1.md +++ b/manuals/dc/N.1.md @@ -224,10 +224,6 @@ The following are the options that dc(1) accepts. : Makes dc(1) print all numbers greater than **-1** and less than **1**, and not equal to **0**, with a leading zero. - This can be set for individual numbers with the **plz(x)**, plznl(x)**, - **pnlz(x)**, and **pnlznl(x)** functions in the extended math library (see - the **LIBRARY** section). - This is a **non-portable extension**. All long options are **non-portable extensions**. @@ -1087,6 +1083,12 @@ other character produces a parse error (see the **ERRORS** section). : Pushes the line length set by **DC_LINE_LENGTH** (see the **ENVIRONMENT VARIABLES** section) onto the stack. +**gx** + +: Pushes **1** onto the stack if extended register mode is on, **0** + otherwise. See the *Extended Register Mode* subsection of the **REGISTERS** + section for more information. + **gz** : Pushes **0** onto the stack if the leading zero setting has not been enabled diff --git a/scripts/exec-install.sh b/scripts/exec-install.sh index 3b9375af3834..8180b29c9997 100755 --- a/scripts/exec-install.sh +++ b/scripts/exec-install.sh @@ -60,6 +60,12 @@ fi # If it's a symlink, create an equivalent in the install directory. for exe in $bindir/*; do + # Skip any directories in case the bin/ directory is also used as the + # prefix. + if [ -d "$exe" ]; then + continue + fi + base=$(basename "$exe") if [ -L "$exe" ]; then diff --git a/scripts/format.sh b/scripts/format.sh index efb90ef1f328..dd227555b0fe 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -29,6 +29,8 @@ scriptdir=$(dirname "$0") +. "$scriptdir/functions.sh" + cd "$scriptdir/.." if [ "$#" -gt 0 ]; then diff --git a/scripts/link.sh b/scripts/link.sh index 4a472828f3e9..7d95f866e17b 100755 --- a/scripts/link.sh +++ b/scripts/link.sh @@ -32,6 +32,11 @@ usage() { exit 1 } +script="$0" +scriptdir=$(dirname "$script") + +. "$scriptdir/functions.sh" + # Command-line processing. test "$#" -gt 1 || usage diff --git a/scripts/lint.sh b/scripts/lint.sh index 78260dff2daa..5a217204f8f5 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -27,7 +27,10 @@ # POSSIBILITY OF SUCH DAMAGE. # -scriptdir=$(dirname "$0") +script="$0" +scriptdir=$(dirname "$script") + +. "$scriptdir/functions.sh" cd "$scriptdir/.." diff --git a/scripts/locale_install.sh b/scripts/locale_install.sh index 75534a735cdb..3816f54ef495 100755 --- a/scripts/locale_install.sh +++ b/scripts/locale_install.sh @@ -184,11 +184,12 @@ all_locales=0 while getopts "l" opt; do case "$opt" in - l) all_locales=1 ; shift ;; + l) all_locales=1 ;; ?) usage "Invalid option: $opt" ;; esac done +shift $(($OPTIND - 1)) test "$#" -ge 2 || usage "Must have at least two arguments" diff --git a/scripts/safe-install.sh b/scripts/safe-install.sh index 041088386682..5774a17e20de 100755 --- a/scripts/safe-install.sh +++ b/scripts/safe-install.sh @@ -41,7 +41,7 @@ set -e if test "$mkdirp" ; then umask 022 -case "$2" in +case "$dst" in */*) mkdir -p "${dst%/*}" ;; esac fi @@ -51,15 +51,15 @@ trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP umask 077 if test "$symlink" ; then -ln -s "$1" "$tmp" +ln -s "$src" "$tmp" else -cat < "$1" > "$tmp" +cat < "$src" > "$tmp" chmod "$mode" "$tmp" fi -mv -f "$tmp" "$2" -test -d "$2" && { -rm -f "$2/$tmp" +mv -f "$tmp" "$dst" +test -d "$dst" && { +rm -f "$dst/$tmp" printf "%s: %s is a directory\n" "$0" "$dst" 1>&2 exit 1 } diff --git a/src/args.c b/src/args.c index 60a82ac1b867..9cb8165f8832 100644 --- a/src/args.c +++ b/src/args.c @@ -345,7 +345,7 @@ bc_args(int argc, char* argv[], bool exit_exprs, BcBigDig* scale, } #endif // DC_ENABLED -#ifndef NDEBUG +#if BC_DEBUG // We shouldn't get here because bc_opt_error()/bc_error() should // longjmp() out. case '?': @@ -357,7 +357,7 @@ bc_args(int argc, char* argv[], bool exit_exprs, BcBigDig* scale, abort(); #endif // !BC_CLANG } -#endif // NDEBUG +#endif // BC_DEBUG } } diff --git a/src/bc_parse.c b/src/bc_parse.c index c64c194863f1..4cf886ef5a9b 100644 --- a/src/bc_parse.c +++ b/src/bc_parse.c @@ -1888,6 +1888,7 @@ bc_parse_stmt(BcParse* p) case BC_LEX_KW_AUTO: case BC_LEX_KW_DEFINE: #if DC_ENABLED + case BC_LEX_EXTENDED_REGISTERS: case BC_LEX_EQ_NO_REG: case BC_LEX_COLON: case BC_LEX_EXECUTE: @@ -2436,6 +2437,7 @@ bc_parse_expr_err(BcParse* p, uint8_t flags, BcParseNext next) case BC_LEX_KW_STREAM: case BC_LEX_KW_ELSE: #if DC_ENABLED + case BC_LEX_EXTENDED_REGISTERS: case BC_LEX_EQ_NO_REG: case BC_LEX_COLON: case BC_LEX_EXECUTE: @@ -2462,11 +2464,11 @@ bc_parse_expr_err(BcParse* p, uint8_t flags, BcParseNext next) case BC_LEX_ARRAY_LENGTH: #endif // DC_ENABLED { -#ifndef NDEBUG +#if BC_DEBUG // We should never get here, even in debug builds. bc_parse_err(p, BC_ERR_PARSE_TOKEN); break; -#endif // NDEBUG +#endif // BC_DEBUG } } diff --git a/src/data.c b/src/data.c index 284d3de7b642..abaf3b8e39ab 100644 --- a/src/data.c +++ b/src/data.c @@ -308,9 +308,9 @@ const BcVecFree bc_vec_dtors[] = { bc_vec_free, bc_num_free, #if !BC_ENABLE_LIBRARY -#ifndef NDEBUG +#if BC_DEBUG bc_func_free, -#endif // NDEBUG +#endif // BC_DEBUG bc_slab_free, bc_const_free, bc_result_free, @@ -1199,12 +1199,12 @@ const uchar dc_parse_insts[] = { #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, - BC_INST_POP, BC_INST_INVALID, BC_INST_INVALID, - BC_INST_INVALID, + BC_INST_LEADING_ZERO, BC_INST_PRINT_STREAM, BC_INST_INVALID, + BC_INST_EXTENDED_REGISTERS, 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, BC_INST_POP, BC_INST_INVALID, + BC_INST_INVALID, BC_INST_INVALID, #if BC_ENABLE_EXTRA_MATH BC_INST_INVALID, #endif // BC_ENABLE_EXTRA_MATH diff --git a/src/dc_lex.c b/src/dc_lex.c index cf737ea3c80c..963e3f1331c2 100644 --- a/src/dc_lex.c +++ b/src/dc_lex.c @@ -278,6 +278,7 @@ dc_lex_token(BcLex* l) c2 = l->buf[l->i]; if (c2 == 'l') l->t = BC_LEX_KW_LINE_LENGTH; + else if (c2 == 'x') l->t = BC_LEX_EXTENDED_REGISTERS; else if (c2 == 'z') l->t = BC_LEX_KW_LEADING_ZERO; else bc_lex_invalidChar(l, c2); diff --git a/src/dc_parse.c b/src/dc_parse.c index 638ccfb769c5..2a6f387ac67a 100644 --- a/src/dc_parse.c +++ b/src/dc_parse.c @@ -349,6 +349,7 @@ dc_parse_token(BcParse* p, BcLexType t, uint8_t flags) case BC_LEX_KW_LEADING_ZERO: case BC_LEX_KW_STREAM: case BC_LEX_KW_ELSE: + case BC_LEX_EXTENDED_REGISTERS: case BC_LEX_EQ_NO_REG: case BC_LEX_EXECUTE: case BC_LEX_PRINT_STACK: diff --git a/src/file.c b/src/file.c index aeee9f97aa98..c038c4472f36 100644 --- a/src/file.c +++ b/src/file.c @@ -336,7 +336,7 @@ bc_file_vprintf(BcFile* restrict f, const char* fmt, va_list args) bc_file_puts(f, bc_flush_none, s); } -#ifndef NDEBUG +#if BC_DEBUG // We only print signed integers in debug code. else if (c == 'd') { @@ -357,7 +357,7 @@ bc_file_vprintf(BcFile* restrict f, const char* fmt, va_list args) bc_file_puts(f, bc_flush_none, buf); } } -#endif // NDEBUG +#endif // BC_DEBUG else { unsigned long long ull; diff --git a/src/history.c b/src/history.c index 472eec55c25d..924b62b41c2d 100644 --- a/src/history.c +++ b/src/history.c @@ -2187,11 +2187,11 @@ bc_history_free(BcHistory* h) SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), h->orig_in); SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), h->orig_out); #endif // _WIN32 -#ifndef NDEBUG +#if BC_DEBUG bc_vec_free(&h->buf); bc_vec_free(&h->history); bc_vec_free(&h->extras); -#endif // NDEBUG +#endif // BC_DEBUG } #if BC_DEBUG_CODE diff --git a/src/lang.c b/src/lang.c index cb928ba31f7e..b1c7d4808ec3 100644 --- a/src/lang.c +++ b/src/lang.c @@ -136,7 +136,7 @@ bc_func_reset(BcFunc* f) #endif // BC_ENABLED } -#ifndef NDEBUG +#if BC_DEBUG void bc_func_free(void* func) { @@ -155,7 +155,7 @@ bc_func_free(void* func) } #endif // BC_ENABLED } -#endif // NDEBUG +#endif // BC_DEBUG void bc_array_init(BcVec* a, bool nums) @@ -302,10 +302,10 @@ bc_result_copy(BcResult* d, BcResult* src) case BC_RESULT_VOID: case BC_RESULT_LAST: { -#ifndef NDEBUG +#if BC_DEBUG // We should *never* try copying either of these. abort(); -#endif // NDEBUG +#endif // BC_DEBUG } #endif // BC_ENABLED } diff --git a/src/library.c b/src/library.c index 223fe4a208fc..6283d198139e 100644 --- a/src/library.c +++ b/src/library.c @@ -201,6 +201,8 @@ bcl_init(void) err: + BC_FUNC_FOOTER(vm, e); + // This is why we had to set them to NULL. if (BC_ERR(vm != NULL && vm->err)) { @@ -211,8 +213,6 @@ err: free(vm); } - BC_FUNC_FOOTER(vm, e); - return e; } diff --git a/src/num.c b/src/num.c index 58beb1dbad8b..8f70c6a409d1 100644 --- a/src/num.c +++ b/src/num.c @@ -3474,11 +3474,11 @@ bc_num_len(const BcNum* restrict n) void bc_num_parse(BcNum* restrict n, const char* restrict val, BcBigDig base) { -#ifndef NDEBUG +#if BC_DEBUG #if BC_ENABLE_LIBRARY BcVm* vm = bcl_getspecific(); #endif // BC_ENABLE_LIBRARY -#endif // NDEBUG +#endif // BC_DEBUG assert(n != NULL && val != NULL && base); assert(base >= BC_NUM_MIN_BASE && base <= vm->maxes[BC_PROG_GLOBALS_IBASE]); @@ -3539,11 +3539,11 @@ bc_num_print(BcNum* restrict n, BcBigDig base, bool newline) BcBigDig bc_num_bigdig2(const BcNum* restrict n) { -#ifndef NDEBUG +#if BC_DEBUG #if BC_ENABLE_LIBRARY BcVm* vm = bcl_getspecific(); #endif // BC_ENABLE_LIBRARY -#endif // NDEBUG +#endif // BC_DEBUG // This function returns no errors because it's guaranteed to succeed if // its preconditions are met. Those preconditions include both n needs to @@ -4256,11 +4256,11 @@ bc_num_modexp(BcNum* a, BcNum* b, BcNum* c, BcNum* restrict d) if (BC_ERR(BC_NUM_ZERO(c))) bc_err(BC_ERR_MATH_DIVIDE_BY_ZERO); if (BC_ERR(BC_NUM_NEG(b))) bc_err(BC_ERR_MATH_NEGATIVE); -#ifndef NDEBUG +#if BC_DEBUG || BC_GCC // This is entirely for quieting a useless scan-build error. btemp.len = 0; ctemp.len = 0; -#endif // NDEBUG +#endif // BC_DEBUG || BC_GCC // Eliminate fractional parts that are zero or error if they are not zero. if (BC_ERR(bc_num_nonInt(a, &atemp) || bc_num_nonInt(b, &btemp) || diff --git a/src/parse.c b/src/parse.c index 1834bde2883d..b02a195f83bb 100644 --- a/src/parse.c +++ b/src/parse.c @@ -223,7 +223,7 @@ bc_parse_reset(BcParse* p) if (BC_ERR(vm->status)) BC_JMP; } -#ifndef NDEBUG +#if BC_DEBUG void bc_parse_free(BcParse* p) { @@ -244,7 +244,7 @@ bc_parse_free(BcParse* p) bc_lex_free(&p->l); } -#endif // NDEBUG +#endif // BC_DEBUG void bc_parse_init(BcParse* p, BcProgram* prog, size_t func) diff --git a/src/program.c b/src/program.c index 7e2ba8178b61..b6fac12c7d65 100644 --- a/src/program.c +++ b/src/program.c @@ -411,12 +411,12 @@ bc_program_num(BcProgram* p, BcResult* r) // We should never get here; this is taken care of earlier because a // result is expected. case BC_RESULT_VOID: -#ifndef NDEBUG +#if BC_DEBUG { abort(); // Fallthrough } -#endif // NDEBUG +#endif // BC_DEBUG case BC_RESULT_LAST: { n = &p->last; @@ -839,14 +839,14 @@ bc_program_rand(BcProgram* p) bc_program_pushBigdig(p, (BcBigDig) rand, BC_RESULT_TEMP); -#ifndef NDEBUG +#if BC_DEBUG // This is just to ensure that the generated number is correct. I also use // braces because I declare every local at the top of the scope. { BcResult* r = bc_vec_top(&p->results); assert(BC_NUM_RDX_VALID_NP(r->d.n)); } -#endif // NDEBUG +#endif // BC_DEBUG } #endif // BC_ENABLE_EXTRA_MATH @@ -1140,13 +1140,13 @@ bc_program_logical(BcProgram* p, uchar inst) cond = (cmp > 0); break; } -#ifndef NDEBUG +#if BC_DEBUG default: { // There is a bug if we get here. abort(); } -#endif // NDEBUG +#endif // BC_DEBUG } } @@ -2689,12 +2689,20 @@ bc_program_globalSetting(BcProgram* p, uchar inst) BcBigDig val; // Make sure the instruction is valid. +#if DC_ENABLED + assert((inst >= BC_INST_LINE_LENGTH && inst <= BC_INST_LEADING_ZERO) || + (BC_IS_DC && inst == BC_INST_EXTENDED_REGISTERS)); +#else // DC_ENABLED assert(inst >= BC_INST_LINE_LENGTH && inst <= BC_INST_LEADING_ZERO); +#endif // DC_ENABLED if (inst == BC_INST_LINE_LENGTH) val = (BcBigDig) vm->line_len; #if BC_ENABLED else if (inst == BC_INST_GLOBAL_STACKS) val = (BC_G != 0); #endif // BC_ENABLED +#if DC_ENABLED + else if (inst == BC_INST_EXTENDED_REGISTERS) val = (DC_X != 0); +#endif // DC_ENABLED else val = (BC_Z != 0); // Push the global. @@ -2779,7 +2787,7 @@ bc_program_insertFunc(BcProgram* p, const char* name) return idx; } -#ifndef NDEBUG +#if BC_DEBUG void bc_program_free(BcProgram* p) { @@ -2826,7 +2834,7 @@ bc_program_free(BcProgram* p) if (BC_IS_DC) bc_vec_free(&p->tail_calls); #endif // DC_ENABLED } -#endif // NDEBUG +#endif // BC_DEBUG void bc_program_init(BcProgram* p) @@ -2883,11 +2891,11 @@ bc_program_init(BcProgram* p) if (BC_IS_BC) bc_num_init(&p->last, BC_NUM_DEF_SIZE); #endif // BC_ENABLED -#ifndef NDEBUG +#if BC_DEBUG bc_vec_init(&p->fns, sizeof(BcFunc), BC_DTOR_FUNC); -#else // NDEBUG +#else // BC_DEBUG bc_vec_init(&p->fns, sizeof(BcFunc), BC_DTOR_NONE); -#endif // NDEBUG +#endif // BC_DEBUG bc_map_init(&p->fn_map); bc_program_insertFunc(p, bc_func_main); bc_program_insertFunc(p, bc_func_read); @@ -3002,9 +3010,9 @@ bc_program_exec(BcProgram* p) BcNum* num; #endif // BC_ENABLED #if !BC_HAS_COMPUTED_GOTO -#ifndef NDEBUG +#if BC_DEBUG size_t jmp_bufs_len; -#endif // NDEBUG +#endif // BC_DEBUG #endif // !BC_HAS_COMPUTED_GOTO #if BC_HAS_COMPUTED_GOTO @@ -3042,9 +3050,9 @@ bc_program_exec(BcProgram* p) #if !BC_HAS_COMPUTED_GOTO -#ifndef NDEBUG +#if BC_DEBUG jmp_bufs_len = vm->jmp_bufs.len; -#endif // NDEBUG +#endif // BC_DEBUG // This loop is the heart of the execution engine. It *is* the engine. For // computed goto, it is ignored. @@ -3246,6 +3254,9 @@ bc_program_exec(BcProgram* p) #if BC_ENABLED BC_PROG_LBL(BC_INST_GLOBAL_STACKS): #endif // BC_ENABLED +#if DC_ENABLED + BC_PROG_LBL(BC_INST_EXTENDED_REGISTERS): +#endif // DC_ENABLE BC_PROG_LBL(BC_INST_LEADING_ZERO): // clang-format on { @@ -3669,9 +3680,9 @@ bc_program_exec(BcProgram* p) default: { BC_UNREACHABLE -#if !defined(NDEBUG) && !BC_CLANG +#if BC_DEBUG && !BC_CLANG abort(); -#endif // !defined(NDEBUG) && !BC_CLANG +#endif // BC_DEBUG && !BC_CLANG } #endif // BC_HAS_COMPUTED_GOTO } @@ -3688,12 +3699,12 @@ bc_program_exec(BcProgram* p) #else // BC_HAS_COMPUTED_GOTO -#ifndef NDEBUG +#if BC_DEBUG // This is to allow me to use a debugger to see the last instruction, // which will point to which function was the problem. But it's also a // good smoke test for error handling changes. assert(jmp_bufs_len == vm->jmp_bufs.len); -#endif // NDEBUG +#endif // BC_DEBUG #endif // BC_HAS_COMPUTED_GOTO } diff --git a/src/read.c b/src/read.c index d5af9e1ba273..de9e24ed6acf 100644 --- a/src/read.c +++ b/src/read.c @@ -279,11 +279,11 @@ bc_read_file(const char* path) assert(path != NULL); -#ifndef NDEBUG +#if BC_DEBUG // Need this to quiet MSan. // NOLINTNEXTLINE memset(&pstat, 0, sizeof(struct stat)); -#endif // NDEBUG +#endif // BC_DEBUG fd = bc_read_open(path, O_RDONLY); @@ -101,9 +101,9 @@ bc_vm_jmp(void) bc_file_flush(&vm->ferr, bc_flush_none); #endif // BC_DEBUG_CODE -#ifndef NDEBUG +#if BC_DEBUG assert(vm->jmp_bufs.len - (size_t) vm->sig_pop); -#endif // NDEBUG +#endif // BC_DEBUG if (vm->jmp_bufs.len == 0) abort(); if (vm->sig_pop) bc_vec_pop(&vm->jmp_bufs); @@ -349,13 +349,13 @@ bc_vm_handleError(BcErr e) BC_JMP; } #else // BC_ENABLE_LIBRARY -#ifndef NDEBUG +#if BC_DEBUG void bc_vm_handleError(BcErr e, const char* file, int fline, size_t line, ...) -#else // NDEBUG +#else // BC_DEBUG void bc_vm_handleError(BcErr e, size_t line, ...) -#endif // NDEBUG +#endif // BC_DEBUG { BcStatus s; va_list args; @@ -423,9 +423,9 @@ bc_vm_handleError(BcErr e, size_t line, ...) bc_file_putchar(&vm->ferr, bc_flush_none, '\n'); } -#ifndef NDEBUG +#if BC_DEBUG bc_file_printf(&vm->ferr, "\n %s:%d\n", file, fline); -#endif // NDEBUG +#endif // BC_DEBUG bc_file_puts(&vm->ferr, bc_flush_none, "\n"); @@ -650,7 +650,7 @@ bc_vm_shutdown(void) if (BC_TTY && !vm->history.badTerm) bc_history_free(&vm->history); #endif // BC_ENABLE_HISTORY -#ifndef NDEBUG +#if BC_DEBUG #if !BC_ENABLE_LIBRARY bc_vec_free(&vm->env_args); free(vm->env_args_buffer); @@ -670,7 +670,7 @@ bc_vm_shutdown(void) #endif // !BC_ENABLE_LIBRARY bc_vm_freeTemps(); -#endif // NDEBUG +#endif // BC_DEBUG #if !BC_ENABLE_LIBRARY // We always want to flush. @@ -1242,12 +1242,12 @@ err: goto restart; } -#ifndef NDEBUG +#if BC_DEBUG // Since these are tied to this function, free them here. We only free in // debug mode because stdin is always the last thing read. bc_vec_free(&vm->line_buf); bc_vec_free(&vm->buffer); -#endif // NDEBUG +#endif // BC_DEBUG BC_LONGJMP_CONT(vm); } @@ -1767,17 +1767,17 @@ bc_vm_init(void) void bc_vm_atexit(void) { -#ifndef NDEBUG +#if BC_DEBUG #if BC_ENABLE_LIBRARY BcVm* vm = bcl_getspecific(); #endif // BC_ENABLE_LIBRARY -#endif // NDEBUG +#endif // BC_DEBUG bc_vm_shutdown(); -#ifndef NDEBUG +#if BC_DEBUG bc_vec_free(&vm->jmp_bufs); -#endif // NDEBUG +#endif // BC_DEBUG } #else // BC_ENABLE_LIBRARY int @@ -1788,9 +1788,9 @@ bc_vm_atexit(int status) bc_vm_shutdown(); -#ifndef NDEBUG +#if BC_DEBUG bc_vec_free(&vm->jmp_bufs); -#endif // NDEBUG +#endif // BC_DEBUG return s; } diff --git a/tests/all.sh b/tests/all.sh index 099804777c13..9174d3982606 100755 --- a/tests/all.sh +++ b/tests/all.sh @@ -50,11 +50,12 @@ pll=1 while getopts "n" opt; do case "$opt" in - n) pll=0 ; shift ; set -e ;; + n) pll=0 ; set -e ;; ?) usage "Invalid option: $opt" ;; esac done +shift $(($OPTIND - 1)) # Command-line processing. if [ "$#" -ge 1 ]; then diff --git a/tests/error.sh b/tests/error.sh index 11d7a8126a27..b87a3d354477 100755 --- a/tests/error.sh +++ b/tests/error.sh @@ -109,7 +109,7 @@ fi printf 'Running %s error file %s with clamping...' "$d" "$t" -printf '%s\n' "$halt" | "$exe" "$@" $opts -c "$testfile" 2> "$out" > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" $opts -c "$testfile" 2> "$out" > /dev/null err="$?" checkerrtest "$d" "$err" "$testfile" "$out" "$exebase" > /dev/null @@ -118,7 +118,7 @@ printf 'pass\n' printf 'Running %s error file %s without clamping...' "$d" "$t" -printf '%s\n' "$halt" | "$exe" "$@" $opts -C "$testfile" 2> "$out" > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" $opts -C "$testfile" 2> "$out" > /dev/null err="$?" checkerrtest "$d" "$err" "$testfile" "$out" "$exebase" > /dev/null @@ -127,7 +127,7 @@ printf 'pass\n' printf 'Running %s error file %s through cat with clamping...' "$d" "$t" -cat "$testfile" | "$exe" "$@" $opts -c 2> "$out" > /dev/null +cat "$testfile" 2> /dev/null | "$exe" "$@" $opts -c 2> "$out" > /dev/null err="$?" checkerrtest "$d" "$err" "$testfile" "$out" "$exebase" @@ -136,7 +136,7 @@ printf 'pass\n' printf 'Running %s error file %s through cat without clamping...' "$d" "$t" -cat "$testfile" | "$exe" "$@" $opts -C 2> "$out" > /dev/null +cat "$testfile" 2> /dev/null | "$exe" "$@" $opts -C 2> "$out" > /dev/null err="$?" checkerrtest "$d" "$err" "$testfile" "$out" "$exebase" diff --git a/tests/errors.sh b/tests/errors.sh index 11d03299b418..081beb724118 100755 --- a/tests/errors.sh +++ b/tests/errors.sh @@ -98,12 +98,12 @@ fi printf 'Running %s command-line error tests...' "$d" -printf '%s\n' "$halt" | "$exe" "$@" -e "1+1" -f- -e "2+2" 2> "$out" > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -e "1+1" -f- -e "2+2" 2> "$out" > /dev/null err="$?" checkerrtest "$d" "$err" "command-line -e test" "$out" "$exebase" -printf '%s\n' "$halt" | "$exe" "$@" -e "1+1" -f- -f "$testdir/$d/decimal.txt" 2> "$out" > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -e "1+1" -f- -f "$testdir/$d/decimal.txt" 2> "$out" > /dev/null err="$?" checkerrtest "$d" "$err" "command-line -f test" "$out" "$exebase" @@ -123,7 +123,7 @@ for testfile in $testdir/$d/*errors.txt; do # Just test warnings. line="last" - printf '%s\n' "$line" | "$exe" "$@" "-lw" 2> "$out" > /dev/null + printf '%s\n' "$line" 2> /dev/null | "$exe" "$@" "-lw" 2> "$out" > /dev/null err="$?" if [ "$err" -ne 0 ]; then @@ -150,7 +150,7 @@ for testfile in $testdir/$d/*errors.txt; do rm -f "$out" - printf '%s\n' "$line" | "$exe" "$@" "$options" 2> "$out" > /dev/null + printf '%s\n' "$line" 2> /dev/null | "$exe" "$@" "$options" 2> "$out" > /dev/null err="$?" checkerrtest "$d" "$err" "$line" "$out" "$exebase" diff --git a/tests/other.sh b/tests/other.sh index 4f491a64c770..c3a739a32e7e 100755 --- a/tests/other.sh +++ b/tests/other.sh @@ -112,14 +112,14 @@ set +e printf '\nRunning %s quit test...' "$d" -printf '%s\n' "$halt" | "$exe" "$@" > /dev/null 2>&1 +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" > /dev/null 2>&1 checktest_retcode "$d" "$?" "quit" # bc has two halt or quit commands, so test the second as well. if [ "$d" = bc ]; then - printf '%s\n' "quit" | "$exe" "$@" > /dev/null 2>&1 + printf '%s\n' "quit" 2> /dev/null | "$exe" "$@" > /dev/null 2>&1 checktest_retcode "$d" "$?" quit @@ -142,11 +142,11 @@ if [ "$d" = "bc" ]; then export BC_ENV_ARGS=" '-l' '' -q" - printf 's(.02893)\n' | "$exe" "$@" > /dev/null + printf 's(.02893)\n' 2> /dev/null | "$exe" "$@" > /dev/null checktest_retcode "$d" "$?" "environment var" - printf 'halt\n' | "$exe" "$@" -e 4 > /dev/null + printf 'halt\n' 2> /dev/null | "$exe" "$@" -e 4 > /dev/null err="$?" checktest_retcode "$d" "$?" "environment var" @@ -168,19 +168,19 @@ if [ "$d" = "bc" ]; then printf '5\n0\n' > "$redefine_res" - printf 'halt\n' | "$exe" "$@" --redefine=print -e 'define print(x) { x }' -e 'print(5)' > "$redefine_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" --redefine=print -e 'define print(x) { x }' -e 'print(5)' > "$redefine_out" err="$?" checktest "$d" "$err" "keyword redefinition" "$redefine_res" "$redefine_out" - printf 'halt\n' | "$exe" "$@" -r "abs" -r "else" -e 'abs = 5;else = 0' -e 'abs;else' > "$redefine_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -r "abs" -r "else" -e 'abs = 5;else = 0' -e 'abs;else' > "$redefine_out" err="$?" checktest "$d" "$err" "keyword redefinition" "$redefine_res" "$redefine_out" if [ "$extra_math" -ne 0 ]; then - printf 'halt\n' | "$exe" "$@" -lr abs -e "perm(5, 1)" -e "0" > "$redefine_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -lr abs -e "perm(5, 1)" -e "0" > "$redefine_out" err="$?" checktest "$d" "$err" "keyword not redefined in builtin library" "$redefine_res" "$redefine_out" @@ -204,7 +204,7 @@ if [ "$d" = "bc" ]; then multiline_expr_out="$outputdir/bc_outputs/multiline_expr_results.txt" # tests/bc/misc1.txt happens to have a multiline comment in it. - printf 'halt\n' | "$exe" "$@" -f "$testdir/bc/misc1.txt" > "$multiline_expr_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/misc1.txt" > "$multiline_expr_out" err="$?" checktest "$d" "$err" "multiline comment in expression file" "$testdir/bc/misc1_results.txt" \ @@ -213,7 +213,7 @@ if [ "$d" = "bc" ]; then printf 'pass\n' printf 'Running multiline comment expression file error test...' - printf 'halt\n' | "$exe" "$@" -f "$testdir/bc/errors/05.txt" 2> "$multiline_expr_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/errors/05.txt" 2> "$multiline_expr_out" err="$?" checkerrtest "$d" "$err" "multiline comment in expression file error" \ @@ -223,7 +223,7 @@ if [ "$d" = "bc" ]; then printf 'Running multiline string expression file test...' # tests/bc/strings.txt happens to have a multiline string in it. - printf 'halt\n' | "$exe" "$@" -f "$testdir/bc/strings.txt" > "$multiline_expr_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/strings.txt" > "$multiline_expr_out" err="$?" checktest "$d" "$err" "multiline string in expression file" "$testdir/bc/strings_results.txt" \ @@ -232,13 +232,13 @@ if [ "$d" = "bc" ]; then printf 'pass\n' printf 'Running multiline string expression file error test...' - printf 'halt\n' | "$exe" "$@" -f "$testdir/bc/errors/16.txt" 2> "$multiline_expr_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/errors/16.txt" 2> "$multiline_expr_out" err="$?" checkerrtest "$d" "$err" "multiline string in expression file with backslash error" \ "$multiline_expr_out" "$d" - printf 'halt\n' | "$exe" "$@" -f "$testdir/bc/errors/04.txt" 2> "$multiline_expr_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/errors/04.txt" 2> "$multiline_expr_out" err="$?" checkerrtest "$d" "$err" "multiline string in expression file error" \ @@ -251,7 +251,7 @@ else export DC_ENV_ARGS="'-x'" export DC_EXPR_EXIT="1" - printf '4s stuff\n' | "$exe" "$@" > /dev/null + printf '4s stuff\n' 2> /dev/null | "$exe" "$@" > /dev/null checktest_retcode "$d" "$?" "environment var" @@ -266,15 +266,15 @@ else # dc has an extra test for a case that someone found running this easter.dc # script. It went into an infinite loop, so we want to check that we did not # regress. - printf 'three\n' | cut -c1-3 > /dev/null + printf 'three\n' 2> /dev/null | cut -c1-3 > /dev/null err=$? if [ "$err" -eq 0 ]; then printf 'Running dc Easter script...' - easter_res="$outputdir/dc_outputs/easter.txt" - easter_out="$outputdir/dc_outputs/easter_results.txt" + easter_out="$outputdir/dc_outputs/easter.txt" + easter_res="$outputdir/dc_outputs/easter_results.txt" outdir=$(dirname "$easter_out") @@ -284,14 +284,44 @@ else printf '4 April 2021\n' > "$easter_res" - "$testdir/dc/scripts/easter.sh" "$exe" 2021 "$@" | cut -c1-12 > "$easter_out" + "$testdir/dc/scripts/easter.sh" "$exe" 2021 "$@" 2> /dev/null | cut -c1-12 > "$easter_out" err="$?" - checktest "$d" "$err" "Easter script" "$easter_res" "$easter_out" + checktest "$d" "$err" "Easter script" "$easter_out" "$easter_res" printf 'pass\n' fi + unset DC_ENV_ARGS + unset DC_EXPR_EXIT + + printf 'Running dc extended register command tests...' + + ext_reg_out="$outputdir/dc_outputs/ext_reg.txt" + ext_reg_res="$outputdir/dc_outputs/ext_reg_results.txt" + + outdir=$(dirname "$ext_reg_out") + + if [ ! -d "$outdir" ]; then + mkdir -p "$outdir" + fi + + printf '0\n' > "$ext_reg_res" + + "$exe" "$@" -e "gxpR" 2> /dev/null > "$ext_reg_out" + err="$?" + + checktest "$d" "$err" "Extended register command" "$ext_reg_out" "$ext_reg_res" + + printf '1\n' > "$ext_reg_res" + + "$exe" "$@" -x -e "gxpR" 2> /dev/null > "$ext_reg_out" + err="$?" + + checktest "$d" "$err" "Extended register command" "$ext_reg_out" "$ext_reg_res" + + printf 'pass\n' + fi out1="$outputdir/${d}_outputs/${d}_other.txt" @@ -302,26 +332,26 @@ printf 'Running %s line length tests...' "$d" printf '%s\n' "$numres" > "$out1" export "$line_var"=80 -printf '%s\n' "$num" | "$exe" "$@" > "$out2" +printf '%s\n' "$num" 2> /dev/null | "$exe" "$@" > "$out2" checktest "$d" "$?" "line length" "$out1" "$out2" printf '%s\n' "$num70" > "$out1" export "$line_var"=2147483647 -printf '%s\n' "$num" | "$exe" "$@" > "$out2" +printf '%s\n' "$num" 2> /dev/null | "$exe" "$@" > "$out2" checktest "$d" "$?" "line length 2" "$out1" "$out2" printf '%s\n' "$num2" > "$out1" export "$line_var"=62 -printf '%s\n' "$num" | "$exe" "$@" -L > "$out2" +printf '%s\n' "$num" 2> /dev/null | "$exe" "$@" -L > "$out2" checktest "$d" "$?" "line length 3" "$out1" "$out2" printf '0\n' > "$out1" -printf '%s\n' "$lltest" | "$exe" "$@" -L > "$out2" +printf '%s\n' "$lltest" 2> /dev/null | "$exe" "$@" -L > "$out2" checktest "$d" "$?" "line length 3" "$out1" "$out2" @@ -342,23 +372,23 @@ printf '%s\n%s\n%s\n%s\n' "$results" "$results" "$results" "$results" > "$out1" checktest "$d" "$?" "arg" "$out1" "$out2" -printf '%s\n' "$halt" | "$exe" "$@" -- "$f" "$f" "$f" "$f" > "$out2" +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -- "$f" "$f" "$f" "$f" > "$out2" checktest "$d" "$?" "arg" "$out1" "$out2" if [ "$d" = "bc" ]; then - printf '%s\n' "$halt" | "$exe" "$@" -i > /dev/null 2>&1 + printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -i > /dev/null 2>&1 fi -printf '%s\n' "$halt" | "$exe" "$@" -h > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -h > /dev/null checktest_retcode "$d" "$?" "arg" -printf '%s\n' "$halt" | "$exe" "$@" -P > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -P > /dev/null checktest_retcode "$d" "$?" "arg" -printf '%s\n' "$halt" | "$exe" "$@" -R > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -R > /dev/null checktest_retcode "$d" "$?" "arg" -printf '%s\n' "$halt" | "$exe" "$@" -v > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -v > /dev/null checktest_retcode "$d" "$?" "arg" -printf '%s\n' "$halt" | "$exe" "$@" -V > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$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') @@ -370,12 +400,12 @@ 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" +printf '%s\n' "$data" 2> /dev/null | "$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" + printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -lz "$testdir/bc/leadingzero.txt" > "$out2" checktest "$d" "$?" "leading zero script" "$testdir/bc/leadingzero_results.txt" "$out2" @@ -446,10 +476,10 @@ if [ "$extra_math" -ne 0 ]; then data=$(printf 'J2@OIKAiAopRpRpRpR') fi - printf '%s\n' "$data" | "$exe" "$@" -S14 -I15 -O16 -E17.25 > "$out2" + printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" -S14 -I15 -O16 -E17.25 > "$out2" checktest "$d" "$?" "builtin variable args" "$out1" "$out2" - printf '%s\n' "$data" | "$exe" "$@" --scale=14 --ibase=15 --obase=16 --seed=17.25 > "$out2" + printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" --scale=14 --ibase=15 --obase=16 --seed=17.25 > "$out2" checktest "$d" "$?" "builtin variable long args" "$out1" "$out2" else @@ -463,10 +493,10 @@ else data=$(printf 'OIKAiAopRpRpR') fi - printf '%s\n' "$data" | "$exe" "$@" -S14 -I15 -O16 > "$out2" + printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" -S14 -I15 -O16 > "$out2" checktest "$d" "$?" "builtin variable args" "$out1" "$out2" - printf '%s\n' "$data" | "$exe" "$@" --scale=14 --ibase=15 --obase=16 > "$out2" + printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" --scale=14 --ibase=15 --obase=16 > "$out2" checktest "$d" "$?" "builtin variable long args" "$out1" "$out2" fi @@ -476,40 +506,40 @@ if [ "$d" = "bc" ]; then out=$(printf '100\n') printf '%s\n' "$out" > "$out1" - printf 'scale\n' | "$exe" "$@" -S100 -l > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" -S100 -l > "$out2" checktest "$d" "$?" "builtin variable args with math lib" "$out1" "$out2" - printf 'scale\n' | "$exe" "$@" --scale=100 --mathlib > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" --scale=100 --mathlib > "$out2" checktest "$d" "$?" "builtin variable long args with math lib" "$out1" "$out2" export BC_ENV_ARGS="-l" - printf 'scale\n' | "$exe" "$@" -S100 > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" -S100 > "$out2" checktest "$d" "$?" "builtin variable args with math lib env arg" "$out1" "$out2" - printf 'scale\n' | "$exe" "$@" --scale=100 > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" --scale=100 > "$out2" checktest "$d" "$?" "builtin variable long args with math lib env arg" "$out1" "$out2" export BC_ENV_ARGS="-S100" - printf 'scale\n' | "$exe" "$@" -l > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" -l > "$out2" checktest "$d" "$?" "builtin variable args with math lib arg" "$out1" "$out2" export BC_ENV_ARGS="--scale=100" - printf 'scale\n' | "$exe" "$@" -l > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" -l > "$out2" checktest "$d" "$?" "builtin variable long args with math lib arg" "$out1" "$out2" fi -printf 'scale\n' | "$exe" "$@" --scale=18923c.rlg > /dev/null 2> "$out2" +printf 'scale\n' 2> /dev/null | "$exe" "$@" --scale=18923c.rlg > /dev/null 2> "$out2" err="$?" checkerrtest "$d" "$err" "invalid command-line arg for builtin variable" "$out2" "$d" if [ "$extra_math" -ne 0 ]; then - printf 'seed\n' | "$exe" "$@" --seed=18923c.rlg > /dev/null 2> "$out2" + printf 'seed\n' 2> /dev/null | "$exe" "$@" --seed=18923c.rlg > /dev/null 2> "$out2" err="$?" checkerrtest "$d" "$err" "invalid command-line arg for seed" "$out2" "$d" @@ -540,7 +570,7 @@ printf 'pass\n' printf 'Running %s binary stdin test...' "$d" -cat "$bin" | "$exe" "$@" > /dev/null 2> "$out2" +cat "$bin" 2> /dev/null | "$exe" "$@" > /dev/null 2> "$out2" err="$?" checkerrtest "$d" "$err" "binary stdin" "$out2" "$d" @@ -550,7 +580,7 @@ printf 'pass\n' if [ "$d" = "bc" ]; then printf 'Running %s limits tests...' "$d" - printf 'limits\n' | "$exe" "$@" /dev/null > "$out2" 2>&1 + printf 'limits\n' 2> /dev/null | "$exe" "$@" /dev/null > "$out2" 2>&1 checktest_retcode "$d" "$?" "limits" diff --git a/tests/script.sh b/tests/script.sh index 460940a21388..438af17c79c4 100755 --- a/tests/script.sh +++ b/tests/script.sh @@ -194,7 +194,7 @@ else # where GNU bc is wrong. See the development manual # (manuals/development.md#script-tests) for more information. printf 'Generating %s results...' "$f" - printf '%s\n' "$halt" | "$d" "$s" | sed -n -f "$testdir/script.sed" > "$results" + printf '%s\n' "$halt" 2> /dev/null | "$d" "$s" | sed -n -f "$testdir/script.sed" > "$results" printf 'done\n' res="$results" fi @@ -206,11 +206,11 @@ printf 'Running %s script %s...' "$d" "$f" # Yes this is poor timing, but it works. if [ "$time_tests" -ne 0 ]; then printf '\n' - printf '%s\n' "$halt" | /usr/bin/time -p "$exe" "$@" $options "$s" > "$out" + printf '%s\n' "$halt" 2> /dev/null | /usr/bin/time -p "$exe" "$@" $options "$s" > "$out" err="$?" printf '\n' else - printf '%s\n' "$halt" | "$exe" "$@" $options "$s" > "$out" + printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" $options "$s" > "$out" err="$?" fi diff --git a/tests/scripts.sh b/tests/scripts.sh index 5c3b6fc3d02c..dda57e435059 100755 --- a/tests/scripts.sh +++ b/tests/scripts.sh @@ -31,6 +31,8 @@ script="$0" testdir=$(dirname "${script}") +. "$testdir/../scripts/functions.sh" + # Just print the usage and exit with an error. This can receive a message to # print. # @param 1 A message to print. @@ -50,11 +52,12 @@ pll=1 while getopts "n" opt; do case "$opt" in - n) pll=0 ; shift ; set -e ;; + n) pll=0 ; set -e ;; ?) usage "Invalid option: $opt" ;; esac done +shift $(($OPTIND - 1)) # Command-line processing. if [ "$#" -eq 0 ]; then diff --git a/tests/test.sh b/tests/test.sh index 11c7e05f739a..343705bf10a9 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -138,7 +138,7 @@ fi # If the results do not exist, generate.. if [ ! -f "$results" ]; then printf 'Generating %s %s results...' "$d" "$t" - printf '%s\n' "$halt" | "$d" $options "$name" > "$results" + printf '%s\n' "$halt" 2> /dev/null | "$d" $options "$name" > "$results" printf 'done\n' fi @@ -157,11 +157,11 @@ printf 'Running %s %s...' "$d" "$t" if [ "$time_tests" -ne 0 ]; then printf '\n' - printf '%s\n' "$halt" | /usr/bin/time -p "$exe" "$@" $options "$name" > "$out" + printf '%s\n' "$halt" 2> /dev/null | /usr/bin/time -p "$exe" "$@" $options "$name" > "$out" err="$?" printf '\n' else - printf '%s\n' "$halt" | "$exe" "$@" $options "$name" > "$out" + printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" $options "$name" > "$out" err="$?" fi diff --git a/vs/bc.vcxproj b/vs/bc.vcxproj index 3579f9094bec..312af50e8a66 100644 --- a/vs/bc.vcxproj +++ b/vs/bc.vcxproj @@ -295,4 +295,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project>
\ No newline at end of file +</Project> |