mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
contrib/bc: upgrade to version 6.7.6
This update fixes a potential issue when flushing stdout on exit fails: longjmp could use an uninitialized target address variable. Most files are included in this commit due to a changed date in the copyright note. (cherry picked from commit 52a5ec1b178fd07651446c7e31b1512794a04dbf) MFC after: 3 days
This commit is contained in:
parent
53734ccd42
commit
a970610a3a
140 changed files with 4445 additions and 4232 deletions
|
@ -1,6 +1,6 @@
|
|||
# License
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard <gavin@gavinhoward.com>
|
||||
Copyright (c) 2018-2024 Gavin D. Howard <gavin@gavinhoward.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
@ -60,7 +60,7 @@ The files `src/rand.c` and `include/rand.h` are under the following copyrights
|
|||
and license:
|
||||
|
||||
Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors<br>
|
||||
Copyright (c) 2018-2023 Gavin D. Howard <gavin@gavinhoward.com>
|
||||
Copyright (c) 2018-2024 Gavin D. Howard <gavin@gavinhoward.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -23,6 +23,13 @@ existed in.
|
|||
|
||||
The first version without this bug is `6.0.2`.
|
||||
|
||||
* In versions `3.0.0` until `6.7.5` (inclusive) of `bc` and `dc`, there is a
|
||||
possible out-of-bounds read when there is an error flushing `stdout` on exit
|
||||
because such an error would cause `bc` and `dc` to attempt to use a `jmp_buf`
|
||||
when none exists.
|
||||
|
||||
The first version without this bug is `6.7.6`.
|
||||
|
||||
* In versions `5.0.0` until `6.0.4` (inclusive) of `bc`, there is an
|
||||
out-of-bounds access if a non-local (non-`auto`) variable is set to a string
|
||||
with `asciify()`, then the function is redefined with a use of the same
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
# News
|
||||
|
||||
## 6.7.6
|
||||
|
||||
This is a production release to fix one bug.
|
||||
|
||||
The bug was that `bc` attempted to jump out when flushing `stdout` on exit, but
|
||||
there is no jump buf at that point.
|
||||
|
||||
## 6.7.5
|
||||
|
||||
This is a production release to fix one small bug.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Notice
|
||||
|
||||
Copyright 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright 2018-2024 Gavin D. Howard and contributors.
|
||||
|
||||
## Contributors
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ POSIX-compatible systems that are known to work:
|
|||
* FreeBSD
|
||||
* OpenBSD
|
||||
* NetBSD
|
||||
* Mac OSX
|
||||
* macOS
|
||||
* Solaris* (as long as the Solaris version supports POSIX 2008)
|
||||
* AIX
|
||||
* HP-UX* (except for history)
|
||||
|
@ -347,6 +347,8 @@ that is because it is more robust. See the [benchmarks][19].
|
|||
Below is a non-comprehensive list of extensions that this `bc` and `dc` have
|
||||
that all others do not.
|
||||
|
||||
* **The `!` operator has higher precedence than the `!` operator in other `bc`
|
||||
implementations.**
|
||||
* An extended math library. (See [here][30] for more information.)
|
||||
* A command-line prompt.
|
||||
* Turning on and off digit clamping. (Digit clamping is about how to treat
|
||||
|
@ -427,7 +429,7 @@ Other projects based on this bc are:
|
|||
* [FreeBSD `bc`][23]. While the `bc` in FreeBSD is kept up-to-date, it is better
|
||||
to [report bugs there][24], as well as [submit patches][25], and the
|
||||
maintainers of the package will contact me if necessary.
|
||||
* [Mac OSX `bc`][35]. Any bugs in that `bc` should be reported to me, but do
|
||||
* [macOS `bc`][35]. Any bugs in that `bc` should be reported to me, but do
|
||||
expect bugs because the version is old.
|
||||
* [Android Open Source `bc`][32]. Any bugs in that `bc` can be reported here.
|
||||
|
||||
|
|
15
contrib/bc/compile_flags.txt
Normal file
15
contrib/bc/compile_flags.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
-Weverything
|
||||
-pedantic
|
||||
-Wno-unsafe-buffer-usage
|
||||
-D_POSIX_C_SOURCE=200809L
|
||||
-D_XOPEN_SOURCE=700
|
||||
-D_BSD_SOURCE
|
||||
-D_GNU_SOURCE
|
||||
-D_DEFAULT_SOURCE
|
||||
-Iinclude/
|
||||
-DBC_DEBUG=1
|
||||
-DBC_ENABLED=1
|
||||
-DDC_ENABLED=1
|
||||
-DBC_ENABLE_EXTRA_MATH=1
|
||||
-DBC_ENABLE_HISTORY=1
|
||||
-DBC_ENABLE_NLS=1
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
@ -127,7 +127,7 @@ usage() {
|
|||
printf ' If this option is given along with -e and -r, the last occurrence of\n'
|
||||
printf ' all of the three is used.\n'
|
||||
printf ' -k KARATSUBA_LEN, --karatsuba-len KARATSUBA_LEN\n'
|
||||
printf ' Set the karatsuba length to KARATSUBA_LEN (default is 64).\n'
|
||||
printf ' Set the karatsuba length to KARATSUBA_LEN (default is 32).\n'
|
||||
printf ' It is an error if KARATSUBA_LEN is not a number or is less than 16.\n'
|
||||
printf ' -l, --install-all-locales\n'
|
||||
printf ' Installs all locales, regardless of how many are on the system. This\n'
|
||||
|
@ -163,7 +163,7 @@ usage() {
|
|||
printf ' Enable the use of libreadline/readline. This is meant for those users\n'
|
||||
printf ' that want vi-like or Emacs-like behavior in history. This option is\n'
|
||||
printf ' ignored if history is disabled. If this option is given along with -e\n'
|
||||
printf ' and -r, the last occurrence of all of the three is used.\n'
|
||||
printf ' and -i, the last occurrence of all of the three is used.\n'
|
||||
printf ' -s SETTING, --set-default-on SETTING\n'
|
||||
printf ' Set the default named by SETTING to on. See below for possible values\n'
|
||||
printf ' for SETTING. For multiple instances of the -s or -S for the the same\n'
|
||||
|
@ -1671,10 +1671,10 @@ else
|
|||
CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
|
||||
fi
|
||||
|
||||
# Test Mac OSX. This is not in an if statement because regardless of whatever
|
||||
# the user says, we need to know if we are on Mac OSX. If we are, we have to set
|
||||
# Test macOS. This is not in an if statement because regardless of whatever the
|
||||
# user says, we need to know if we are on macOS. If we are, we have to set
|
||||
# _DARWIN_C_SOURCE.
|
||||
printf 'Testing for Mac OSX...\n'
|
||||
printf 'Testing for macOS...\n'
|
||||
|
||||
flags="-DBC_TEST_APPLE -DBC_ENABLE_AFL=0"
|
||||
"$CC" $CPPFLAGS $CFLAGS $flags "-I$scriptdir/include" -E "$scriptdir/src/vm.c" > /dev/null 2>&1
|
||||
|
@ -1682,15 +1682,15 @@ flags="-DBC_TEST_APPLE -DBC_ENABLE_AFL=0"
|
|||
err="$?"
|
||||
|
||||
if [ "$err" -ne 0 ]; then
|
||||
printf 'On Mac OSX. Using _DARWIN_C_SOURCE.\n\n'
|
||||
printf 'On macOS. Using _DARWIN_C_SOURCE.\n\n'
|
||||
apple="-D_DARWIN_C_SOURCE"
|
||||
else
|
||||
printf 'Not on Mac OSX.\n\n'
|
||||
printf 'Not on macOS.\n\n'
|
||||
apple=""
|
||||
fi
|
||||
|
||||
# We can't use the linker's strip flag on Mac OSX.
|
||||
if [ "$debug" -eq 0 ] && [ "$apple" == "" ] && [ "$strip_bin" -ne 0 ]; then
|
||||
# We can't use the linker's strip flag on macOS.
|
||||
if [ "$debug" -eq 0 ] && [ "$apple" = "" ] && [ "$strip_bin" -ne 0 ]; then
|
||||
LDFLAGS="-s $LDFLAGS"
|
||||
fi
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
@ -68,7 +68,7 @@ static const char* const bc_gen_ex_end = "{{ end }}";
|
|||
// This is exactly what it looks like. It just slaps a simple license header on
|
||||
// the generated C source file.
|
||||
static const char* const bc_gen_header =
|
||||
"// Copyright (c) 2018-2023 Gavin D. Howard and contributors.\n"
|
||||
"// Copyright (c) 2018-2024 Gavin D. Howard and contributors.\n"
|
||||
"// Licensed under the 2-clause BSD license.\n"
|
||||
"// *** AUTOMATICALLY GENERATED FROM %s. DO NOT MODIFY. ***\n\n";
|
||||
// clang-format on
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
@ -96,7 +96,7 @@ if [ -n "$remove_tabs" ]; then
|
|||
fi
|
||||
|
||||
cat<<EOF
|
||||
// Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
// Copyright (c) 2018-2024 Gavin D. Howard and contributors.
|
||||
// Licensed under the 2-clause BSD license.
|
||||
// *** AUTOMATICALLY GENERATED FROM ${input}. DO NOT MODIFY. ***
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
@ -48,8 +48,9 @@
|
|||
/**
|
||||
* The main function for bc. It just sets variables and passes its arguments
|
||||
* through to @a bc_vm_boot().
|
||||
* @return A status.
|
||||
*/
|
||||
void
|
||||
BcStatus
|
||||
bc_main(int argc, char* argv[]);
|
||||
|
||||
// These are references to the help text, the library text, and the "filename"
|
||||
|
@ -88,10 +89,8 @@ typedef struct BcLexKeyword
|
|||
#define BC_LEX_KW_LEN(kw) ((size_t) ((kw)->data & ~(BC_LEX_CHAR_MSB(1))))
|
||||
|
||||
/// A macro to easily build a keyword entry. See bc_lex_kws in src/data.c.
|
||||
#define BC_LEX_KW_ENTRY(a, b, c) \
|
||||
{ \
|
||||
.data = ((b) & ~(BC_LEX_CHAR_MSB(1))) | BC_LEX_CHAR_MSB(c), .name = a \
|
||||
}
|
||||
#define BC_LEX_KW_ENTRY(a, b, c) \
|
||||
{ .data = ((b) & ~(BC_LEX_CHAR_MSB(1))) | BC_LEX_CHAR_MSB(c), .name = a }
|
||||
|
||||
#if BC_ENABLE_EXTRA_MATH
|
||||
|
||||
|
@ -234,7 +233,7 @@ bc_lex_token(BcLex* l);
|
|||
* @param t The token to return operator data for.
|
||||
* @return The operator data for @a t.
|
||||
*/
|
||||
#define BC_PARSE_OP_DATA(t) bc_parse_ops[((t) -BC_LEX_OP_INC)]
|
||||
#define BC_PARSE_OP_DATA(t) bc_parse_ops[((t) - BC_LEX_OP_INC)]
|
||||
|
||||
/**
|
||||
* Returns non-zero if operator @a op is left associative, zero otherwise.
|
||||
|
@ -341,7 +340,7 @@ bc_lex_token(BcLex* l);
|
|||
* @param t The token to turn into an instruction.
|
||||
* @return The token as an instruction.
|
||||
*/
|
||||
#define BC_PARSE_TOKEN_INST(t) ((uchar) ((t) -BC_LEX_NEG + BC_INST_NEG))
|
||||
#define BC_PARSE_TOKEN_INST(t) ((uchar) ((t) - BC_LEX_NEG + BC_INST_NEG))
|
||||
|
||||
/**
|
||||
* Returns true if the token is a bc keyword.
|
||||
|
@ -372,10 +371,8 @@ typedef struct BcParseNext
|
|||
|
||||
/// A macro to generate a BcParseNext literal from BcParseNext data. See
|
||||
/// src/data.c for examples.
|
||||
#define BC_PARSE_NEXT(a, ...) \
|
||||
{ \
|
||||
.len = (uchar) (a), BC_PARSE_NEXT_TOKENS(__VA_ARGS__) \
|
||||
}
|
||||
#define BC_PARSE_NEXT(a, ...) \
|
||||
{ .len = (uchar) (a), BC_PARSE_NEXT_TOKENS(__VA_ARGS__) }
|
||||
|
||||
/// A status returned by @a bc_parse_expr_err(). It can either return success or
|
||||
/// an error indicating an empty expression.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
@ -45,8 +45,9 @@
|
|||
/**
|
||||
* The main function for dc. It just sets variables and passes its arguments
|
||||
* through to @a bc_vm_boot().
|
||||
* @return A status.
|
||||
*/
|
||||
void
|
||||
BcStatus
|
||||
dc_main(int argc, char* argv[]);
|
||||
|
||||
// A reference to the dc help text.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
@ -54,6 +54,9 @@ typedef struct BcFile
|
|||
// with the existing code as possible.
|
||||
FILE* f;
|
||||
|
||||
// True if errors should be fatal, false otherwise.
|
||||
bool errors_fatal;
|
||||
|
||||
} BcFile;
|
||||
|
||||
#else // BC_ENABLE_LINE_LIB
|
||||
|
@ -64,6 +67,9 @@ typedef struct BcFile
|
|||
// The actual file descriptor.
|
||||
int fd;
|
||||
|
||||
// True if errors should be fatal, false otherwise.
|
||||
bool errors_fatal;
|
||||
|
||||
// The buffer for the file.
|
||||
char* buf;
|
||||
|
||||
|
@ -123,23 +129,25 @@ typedef enum BcFlushType
|
|||
|
||||
/**
|
||||
* Initialize a file.
|
||||
* @param f The file to initialize.
|
||||
* @param file The stdio file.
|
||||
* @param f The file to initialize.
|
||||
* @param file The stdio file.
|
||||
* @param errors_fatal True if errors should be fatal, false otherwise.
|
||||
*/
|
||||
void
|
||||
bc_file_init(BcFile* f, FILE* file);
|
||||
bc_file_init(BcFile* f, FILE* file, bool errors_fatal);
|
||||
|
||||
#else // BC_ENABLE_LINE_LIB
|
||||
|
||||
/**
|
||||
* Initialize a file.
|
||||
* @param f The file to initialize.
|
||||
* @param fd The file descriptor.
|
||||
* @param buf The buffer for the file.
|
||||
* @param cap The capacity of the buffer.
|
||||
* @param f The file to initialize.
|
||||
* @param fd The file descriptor.
|
||||
* @param buf The buffer for the file.
|
||||
* @param cap The capacity of the buffer.
|
||||
* @param errors_fatal True if errors should be fatal, false otherwise.
|
||||
*/
|
||||
void
|
||||
bc_file_init(BcFile* f, int fd, char* buf, size_t cap);
|
||||
bc_file_init(BcFile* f, int fd, char* buf, size_t cap, bool errors_fatal);
|
||||
|
||||
#endif // BC_ENABLE_LINE_LIB
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* This code is under the following license:
|
||||
*
|
||||
* Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -241,10 +241,7 @@ typedef struct BcRandState
|
|||
* @param l The low 64 bits.
|
||||
* @return The constant built from @a h and @a l.
|
||||
*/
|
||||
#define BC_RAND_CONSTANT(h, l) \
|
||||
{ \
|
||||
.lo = (l), .hi = (h) \
|
||||
}
|
||||
#define BC_RAND_CONSTANT(h, l) { .lo = (l), .hi = (h) }
|
||||
|
||||
/**
|
||||
* Truncates a PCG state to the number of bits in a random integer.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
@ -60,10 +60,10 @@
|
|||
#endif // __FreeBSD__
|
||||
#endif // BC_TEST_FREEBSD
|
||||
|
||||
// This is used by configure.sh to test for Mac OSX.
|
||||
// This is used by configure.sh to test for macOS.
|
||||
#ifdef BC_TEST_APPLE
|
||||
#ifdef __APPLE__
|
||||
#error On Mac OSX without _DARWIN_C_SOURCE
|
||||
#error On macOS without _DARWIN_C_SOURCE
|
||||
#endif // __APPLE__
|
||||
#endif // BC_TEST_APPLE
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
@ -37,6 +37,6 @@
|
|||
#define BC_VERSION_H
|
||||
|
||||
/// The current version.
|
||||
#define VERSION 6.7.5
|
||||
#define VERSION 6.7.6
|
||||
|
||||
#endif // BC_VERSION_H
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2024 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:
|
||||
|
@ -493,7 +493,7 @@
|
|||
#define BC_VM_SAFE_RESULT(r) ((r)->t >= BC_RESULT_TEMP)
|
||||
|
||||
/// The invalid locale catalog return value.
|
||||
#define BC_VM_INVALID_CATALOG ((nl_catd) -1)
|
||||
#define BC_VM_INVALID_CATALOG ((nl_catd) - 1)
|
||||
|
||||
/**
|
||||
* Returns true if the *unsigned* multiplication overflows.
|
||||
|
@ -791,8 +791,9 @@ bc_vm_info(const char* const help);
|
|||
* The entrance point for bc/dc together.
|
||||
* @param argc The count of arguments.
|
||||
* @param argv The argument array.
|
||||
* @return A status.
|
||||
*/
|
||||
void
|
||||
BcStatus
|
||||
bc_vm_boot(int argc, char* argv[]);
|
||||
|
||||
/**
|
||||
|
@ -1045,8 +1046,9 @@ bc_vm_fatalError(BcErr e);
|
|||
* A function to call at exit.
|
||||
* @param status The exit status.
|
||||
*/
|
||||
int
|
||||
bc_vm_atexit(int status);
|
||||
BcStatus
|
||||
bc_vm_atexit(BcStatus status);
|
||||
|
||||
#endif // BC_ENABLE_LIBRARY
|
||||
|
||||
/// A reference to the copyright header.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2024 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:
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
@ -811,6 +811,9 @@ The operators will be described in more detail below.
|
|||
: The **boolean not** operator returns **1** if the expression is **0**, or
|
||||
**0** otherwise.
|
||||
|
||||
**Warning**: This operator has a **different precedence** than the
|
||||
equivalent operator in GNU bc(1) and other bc(1) implementations!
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**\$**
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
@ -688,6 +688,9 @@ The operators will be described in more detail below.
|
|||
: The **boolean not** operator returns **1** if the expression is **0**, or
|
||||
**0** otherwise.
|
||||
|
||||
**Warning**: This operator has a **different precedence** than the
|
||||
equivalent operator in GNU bc(1) and other bc(1) implementations!
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**\^**
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
@ -688,6 +688,9 @@ The operators will be described in more detail below.
|
|||
: The **boolean not** operator returns **1** if the expression is **0**, or
|
||||
**0** otherwise.
|
||||
|
||||
**Warning**: This operator has a **different precedence** than the
|
||||
equivalent operator in GNU bc(1) and other bc(1) implementations!
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**\^**
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
@ -688,6 +688,9 @@ The operators will be described in more detail below.
|
|||
: The **boolean not** operator returns **1** if the expression is **0**, or
|
||||
**0** otherwise.
|
||||
|
||||
**Warning**: This operator has a **different precedence** than the
|
||||
equivalent operator in GNU bc(1) and other bc(1) implementations!
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**\^**
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
@ -688,6 +688,9 @@ The operators will be described in more detail below.
|
|||
: The **boolean not** operator returns **1** if the expression is **0**, or
|
||||
**0** otherwise.
|
||||
|
||||
**Warning**: This operator has a **different precedence** than the
|
||||
equivalent operator in GNU bc(1) and other bc(1) implementations!
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**\^**
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
@ -811,6 +811,9 @@ The operators will be described in more detail below.
|
|||
: The **boolean not** operator returns **1** if the expression is **0**, or
|
||||
**0** otherwise.
|
||||
|
||||
**Warning**: This operator has a **different precedence** than the
|
||||
equivalent operator in GNU bc(1) and other bc(1) implementations!
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**\$**
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
@ -811,6 +811,9 @@ The operators will be described in more detail below.
|
|||
: The **boolean not** operator returns **1** if the expression is **0**, or
|
||||
**0** otherwise.
|
||||
|
||||
**Warning**: This operator has a **different precedence** than the
|
||||
equivalent operator in GNU bc(1) and other bc(1) implementations!
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**\$**
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
@ -811,6 +811,9 @@ The operators will be described in more detail below.
|
|||
: The **boolean not** operator returns **1** if the expression is **0**, or
|
||||
**0** otherwise.
|
||||
|
||||
**Warning**: This operator has a **different precedence** than the
|
||||
equivalent operator in GNU bc(1) and other bc(1) implementations!
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**\$**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2024 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:
|
||||
|
@ -25,17 +25,17 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BCL" "3" "February 2023" "Gavin D. Howard" "Libraries Manual"
|
||||
.TH "BCL" "3" "January 2024" "Gavin D. Howard" "Libraries Manual"
|
||||
.nh
|
||||
.ad l
|
||||
.SH NAME
|
||||
bcl - library of arbitrary precision decimal arithmetic
|
||||
bcl \- library of arbitrary precision decimal arithmetic
|
||||
.SH SYNOPSIS
|
||||
.SS Use
|
||||
\f[I]#include <bcl.h>\f[R]
|
||||
.PP
|
||||
Link with \f[I]-lbcl\f[R], and on POSIX systems, \f[I]-lpthread\f[R] is
|
||||
also required.
|
||||
Link with \f[I]\-lbcl\f[R], and on POSIX systems, \f[I]\-lpthread\f[R]
|
||||
is also required.
|
||||
.SS Setup
|
||||
These items allow clients to set up bcl(3).
|
||||
.PP
|
||||
|
@ -104,7 +104,7 @@ These items allow clients to handle errors.
|
|||
\f[B]BclError bcl_err(BclNumber\f[R] \f[I]n\f[R]\f[B]);\f[R]
|
||||
.SS Numbers
|
||||
These items allow clients to manipulate and query the
|
||||
arbitrary-precision numbers managed by bcl(3).
|
||||
arbitrary\-precision numbers managed by bcl(3).
|
||||
.PP
|
||||
\f[B]typedef struct { size_t i; } BclNumber;\f[R]
|
||||
.PP
|
||||
|
@ -223,8 +223,8 @@ These items are miscellaneous.
|
|||
\f[I]s\f[R]\f[B]);\f[R]
|
||||
.PP
|
||||
\f[B]BclNumber bcl_dup(BclNumber\f[R] \f[I]s\f[R]\f[B]);\f[R]
|
||||
.SS Pseudo-Random Number Generator
|
||||
These items allow clients to manipulate the seeded pseudo-random number
|
||||
.SS Pseudo\-Random Number Generator
|
||||
These items allow clients to manipulate the seeded pseudo\-random number
|
||||
generator in bcl(3).
|
||||
.PP
|
||||
\f[B]#define BCL_SEED_ULONGS\f[R]
|
||||
|
@ -265,8 +265,8 @@ size_t\f[R] \f[I]places\f[R]\f[B]);\f[R]
|
|||
\f[B]BclRandInt bcl_rand_bounded(BclRandInt\f[R]
|
||||
\f[I]bound\f[R]\f[B]);\f[R]
|
||||
.SH DESCRIPTION
|
||||
bcl(3) is a library that implements arbitrary-precision decimal math, as
|
||||
standardized by POSIX
|
||||
bcl(3) is a library that implements arbitrary\-precision decimal math,
|
||||
as standardized by POSIX
|
||||
(https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html) in
|
||||
bc(1).
|
||||
.PP
|
||||
|
@ -361,7 +361,7 @@ a fatal error occurs.
|
|||
.PP
|
||||
If activated, clients do not need to check for fatal errors.
|
||||
.PP
|
||||
This value is \f[I]thread-local\f[R]; it applies to just the thread it
|
||||
This value is \f[I]thread\-local\f[R]; it applies to just the thread it
|
||||
is read on.
|
||||
.PP
|
||||
The default is \f[B]false\f[R].
|
||||
|
@ -375,7 +375,7 @@ If \f[I]abrt\f[R] is \f[B]true\f[R], bcl(3) will cause a
|
|||
\f[B]SIGABRT\f[R] on fatal errors after the call.
|
||||
.RS
|
||||
.PP
|
||||
This value is \f[I]thread-local\f[R]; it applies to just the thread it
|
||||
This value is \f[I]thread\-local\f[R]; it applies to just the thread it
|
||||
is set on.
|
||||
.PP
|
||||
If activated, clients do not need to check for fatal errors.
|
||||
|
@ -384,11 +384,11 @@ If activated, clients do not need to check for fatal errors.
|
|||
\f[B]bool bcl_leadingZeroes(\f[R]\f[I]void\f[R]\f[B])\f[R]
|
||||
Queries and returns the state of whether leading zeroes are added to
|
||||
strings returned by \f[B]bcl_string()\f[R] when numbers are greater than
|
||||
\f[B]-1\f[R], less than \f[B]1\f[R], and not equal to \f[B]0\f[R].
|
||||
\f[B]\-1\f[R], less than \f[B]1\f[R], and not equal to \f[B]0\f[R].
|
||||
If \f[B]true\f[R] is returned, then leading zeroes will be added.
|
||||
.RS
|
||||
.PP
|
||||
This value is \f[I]thread-local\f[R]; it applies to just the thread it
|
||||
This value is \f[I]thread\-local\f[R]; it applies to just the thread it
|
||||
is read on.
|
||||
.PP
|
||||
The default is \f[B]false\f[R].
|
||||
|
@ -396,13 +396,13 @@ The default is \f[B]false\f[R].
|
|||
.TP
|
||||
\f[B]void bcl_setLeadingZeroes(bool\f[R] \f[I]leadingZeroes\f[R]\f[B])\f[R]
|
||||
Sets the state of whether leading zeroes are added to strings returned
|
||||
by \f[B]bcl_string()\f[R] when numbers are greater than \f[B]-1\f[R],
|
||||
by \f[B]bcl_string()\f[R] when numbers are greater than \f[B]\-1\f[R],
|
||||
less than \f[B]1\f[R], and not equal to \f[B]0\f[R].
|
||||
If \f[I]leadingZeroes\f[R] is \f[B]true\f[R], leading zeroes will be
|
||||
added to strings returned by \f[B]bcl_string()\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This value is \f[I]thread-local\f[R]; it applies to just the thread it
|
||||
This value is \f[I]thread\-local\f[R]; it applies to just the thread it
|
||||
is set on.
|
||||
.RE
|
||||
.TP
|
||||
|
@ -426,7 +426,7 @@ while with clamping on and an \f[B]ibase\f[R] of \f[B]3\f[R], the string
|
|||
\[lq]AB\[rq] would be equal to \f[B]3\[ha]1*2+3\[ha]0*2\f[R], which is
|
||||
\f[B]3\f[R] times \f[B]2\f[R] plus \f[B]2\f[R], or \f[B]8\f[R].
|
||||
.PP
|
||||
This value is \f[I]thread-local\f[R]; it applies to just the thread it
|
||||
This value is \f[I]thread\-local\f[R]; it applies to just the thread it
|
||||
is read on.
|
||||
.PP
|
||||
The default is \f[B]true\f[R].
|
||||
|
@ -439,12 +439,12 @@ For more information, see the
|
|||
\f[B]bcl_digitClamp(\f[R]\f[I]void\f[R]\f[B])\f[R] function.
|
||||
.RS
|
||||
.PP
|
||||
This value is \f[I]thread-local\f[R]; it applies to just the thread it
|
||||
This value is \f[I]thread\-local\f[R]; it applies to just the thread it
|
||||
is set on.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]void bcl_gc(\f[R]\f[I]void\f[R]\f[B])\f[R]
|
||||
Garbage collects cached instances of arbitrary-precision numbers.
|
||||
Garbage collects cached instances of arbitrary\-precision numbers.
|
||||
This only frees the memory of numbers that are \f[I]not\f[R] in use, so
|
||||
it is safe to call at any time.
|
||||
.SS Contexts
|
||||
|
@ -578,9 +578,9 @@ There must be a valid current context.
|
|||
All procedures in this section require a valid current context.
|
||||
.TP
|
||||
\f[B]BclNumber\f[R]
|
||||
A handle to an arbitrary-precision number.
|
||||
A handle to an arbitrary\-precision number.
|
||||
The actual number type is not exposed; the \f[B]BclNumber\f[R] handle is
|
||||
the only way clients can refer to instances of arbitrary-precision
|
||||
the only way clients can refer to instances of arbitrary\-precision
|
||||
numbers.
|
||||
.TP
|
||||
\f[B]BclNumber bcl_num_create(\f[R]\f[I]void\f[R]\f[B])\f[R]
|
||||
|
@ -650,7 +650,7 @@ Parses a number string according to the current context\[cq]s
|
|||
\f[B]ibase\f[R] and returns the resulting number.
|
||||
.RS
|
||||
.PP
|
||||
\f[I]val\f[R] must be non-\f[B]NULL\f[R] and a valid string.
|
||||
\f[I]val\f[R] must be non\-\f[B]NULL\f[R] and a valid string.
|
||||
See \f[B]BCL_ERROR_PARSE_INVALID_STR\f[R] in the \f[B]ERRORS\f[R]
|
||||
section for more information.
|
||||
.PP
|
||||
|
@ -933,7 +933,7 @@ Possible errors include:
|
|||
.TP
|
||||
\f[B]BclNumber bcl_mod(BclNumber\f[R] \f[I]a\f[R]\f[B], BclNumber\f[R] \f[I]b\f[R]\f[B])\f[R]
|
||||
Divides \f[I]a\f[R] by \f[I]b\f[R] to the \f[I]scale\f[R] of the current
|
||||
context, computes the modulus \f[B]a-(a/b)*b\f[R], and returns the
|
||||
context, computes the modulus \f[B]a\-(a/b)*b\f[R], and returns the
|
||||
modulus.
|
||||
.RS
|
||||
.PP
|
||||
|
@ -960,7 +960,7 @@ Possible errors include:
|
|||
.TP
|
||||
\f[B]BclNumber bcl_mod_keep(BclNumber\f[R] \f[I]a\f[R]\f[B], BclNumber\f[R] \f[I]b\f[R]\f[B])\f[R]
|
||||
Divides \f[I]a\f[R] by \f[I]b\f[R] to the \f[I]scale\f[R] of the current
|
||||
context, computes the modulus \f[B]a-(a/b)*b\f[R], and returns the
|
||||
context, computes the modulus \f[B]a\-(a/b)*b\f[R], and returns the
|
||||
modulus.
|
||||
.RS
|
||||
.PP
|
||||
|
@ -985,7 +985,7 @@ Possible errors include:
|
|||
Calculates \f[I]a\f[R] to the power of \f[I]b\f[R] to the
|
||||
\f[I]scale\f[R] of the current context.
|
||||
\f[I]b\f[R] must be an integer, but can be negative.
|
||||
If it is negative, \f[I]a\f[R] must be non-zero.
|
||||
If it is negative, \f[I]a\f[R] must be non\-zero.
|
||||
.RS
|
||||
.PP
|
||||
\f[I]b\f[R] must be an integer.
|
||||
|
@ -1021,7 +1021,7 @@ Possible errors include:
|
|||
Calculates \f[I]a\f[R] to the power of \f[I]b\f[R] to the
|
||||
\f[I]scale\f[R] of the current context.
|
||||
\f[I]b\f[R] must be an integer, but can be negative.
|
||||
If it is negative, \f[I]a\f[R] must be non-zero.
|
||||
If it is negative, \f[I]a\f[R] must be non\-zero.
|
||||
.RS
|
||||
.PP
|
||||
\f[I]b\f[R] must be an integer.
|
||||
|
@ -1354,10 +1354,11 @@ Possible errors include:
|
|||
.IP \[bu] 2
|
||||
\f[B]BCL_ERROR_FATAL_ALLOC_ERR\f[R]
|
||||
.RE
|
||||
.SS Pseudo-Random Number Generator
|
||||
The pseudo-random number generator in bcl(3) is a \f[I]seeded\f[R] PRNG.
|
||||
.SS Pseudo\-Random Number Generator
|
||||
The pseudo\-random number generator in bcl(3) is a \f[I]seeded\f[R]
|
||||
PRNG.
|
||||
Given the same seed twice, it will produce the same sequence of
|
||||
pseudo-random numbers twice.
|
||||
pseudo\-random numbers twice.
|
||||
.PP
|
||||
By default, bcl(3) attempts to seed the PRNG with data from
|
||||
\f[B]/dev/urandom\f[R].
|
||||
|
@ -1384,7 +1385,7 @@ their name consume the given \f[B]BclNumber\f[R] arguments that are not
|
|||
given to pointer arguments.
|
||||
See the \f[B]Consumption and Propagation\f[R] subsection below.
|
||||
.PP
|
||||
The following items allow clients to use the pseudo-random number
|
||||
The following items allow clients to use the pseudo\-random number
|
||||
generator.
|
||||
All procedures require a valid current context.
|
||||
.TP
|
||||
|
@ -1414,7 +1415,7 @@ This is done by generating as many random numbers as necessary,
|
|||
multiplying them by certain exponents, and adding them all together.
|
||||
.RS
|
||||
.PP
|
||||
\f[I]a\f[R] must be an integer and non-negative.
|
||||
\f[I]a\f[R] must be an integer and non\-negative.
|
||||
.PP
|
||||
\f[I]a\f[R] is consumed; it cannot be used after the call.
|
||||
See the \f[B]Consumption and Propagation\f[R] subsection below.
|
||||
|
@ -1447,7 +1448,7 @@ This is done by generating as many random numbers as necessary,
|
|||
multiplying them by certain exponents, and adding them all together.
|
||||
.RS
|
||||
.PP
|
||||
\f[I]a\f[R] must be an integer and non-negative.
|
||||
\f[I]a\f[R] must be an integer and non\-negative.
|
||||
.PP
|
||||
This procedure requires a valid current context.
|
||||
.PP
|
||||
|
@ -1490,7 +1491,7 @@ decimal digits after the radix (decimal point).
|
|||
There are no limits on \f[I]a\f[R] or \f[I]places\f[R].
|
||||
.RS
|
||||
.PP
|
||||
\f[I]a\f[R] must be an integer and non-negative.
|
||||
\f[I]a\f[R] must be an integer and non\-negative.
|
||||
.PP
|
||||
\f[I]a\f[R] is consumed; it cannot be used after the call.
|
||||
See the \f[B]Consumption and Propagation\f[R] subsection below.
|
||||
|
@ -1518,7 +1519,7 @@ decimal digits after the radix (decimal point).
|
|||
There are no limits on \f[I]a\f[R] or \f[I]places\f[R].
|
||||
.RS
|
||||
.PP
|
||||
\f[I]a\f[R] must be an integer and non-negative.
|
||||
\f[I]a\f[R] must be an integer and non\-negative.
|
||||
.PP
|
||||
This procedure requires a valid current context.
|
||||
.PP
|
||||
|
@ -1670,8 +1671,8 @@ A negative number was given as an argument to a parameter that cannot
|
|||
accept negative numbers, such as for square roots.
|
||||
.TP
|
||||
\f[B]BCL_ERROR_MATH_NON_INTEGER\f[R]
|
||||
A non-integer was given as an argument to a parameter that cannot accept
|
||||
non-integer numbers, such as for the second parameter of
|
||||
A non\-integer was given as an argument to a parameter that cannot
|
||||
accept non\-integer numbers, such as for the second parameter of
|
||||
\f[B]bcl_num_pow()\f[R].
|
||||
.TP
|
||||
\f[B]BCL_ERROR_MATH_OVERFLOW\f[R]
|
||||
|
@ -1686,7 +1687,7 @@ An invalid number string was passed to a parsing function.
|
|||
.RS
|
||||
.PP
|
||||
A valid number string can only be one radix (period).
|
||||
In addition, any lowercase ASCII letters, symbols, or non-ASCII
|
||||
In addition, any lowercase ASCII letters, symbols, or non\-ASCII
|
||||
characters are invalid.
|
||||
It is allowed for the first character to be a dash.
|
||||
In that case, the number is considered to be negative.
|
||||
|
@ -1706,7 +1707,7 @@ of the current \f[B]ibase\f[R].
|
|||
For example, if \f[B]ibase\f[R] is \f[B]16\f[R] and bcl(3) is given the
|
||||
number string \f[B]FFeA\f[R], the resulting decimal number will be
|
||||
\f[B]2550000000000\f[R], and if bcl(3) is given the number string
|
||||
\f[B]10e-4\f[R], the resulting decimal number will be \f[B]0.0016\f[R].
|
||||
\f[B]10e\-4\f[R], the resulting decimal number will be \f[B]0.0016\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]BCL_ERROR_FATAL_ALLOC_ERR\f[R]
|
||||
|
@ -1739,12 +1740,12 @@ It is highly recommended that client libraries do \f[I]not\f[R] activate
|
|||
this behavior.
|
||||
.RE
|
||||
.SH ATTRIBUTES
|
||||
bcl(3) is \f[I]MT-Safe\f[R]: it is safe to call any functions from more
|
||||
bcl(3) is \f[I]MT\-Safe\f[R]: it is safe to call any functions from more
|
||||
than one thread.
|
||||
However, is is \f[I]not\f[R] safe to pass any data between threads
|
||||
except for strings returned by \f[B]bcl_string()\f[R].
|
||||
.PP
|
||||
bcl(3) is not \f[I]async-signal-safe\f[R].
|
||||
bcl(3) is not \f[I]async\-signal\-safe\f[R].
|
||||
It was not possible to make bcl(3) safe with signals and also make it
|
||||
safe with multiple threads.
|
||||
If it is necessary to be able to interrupt bcl(3), spawn a separate
|
||||
|
@ -1798,31 +1799,31 @@ Set at \f[B]BC_BASE_POW\f[R].
|
|||
.TP
|
||||
\f[B]BC_SCALE_MAX\f[R]
|
||||
The maximum \f[B]scale\f[R].
|
||||
Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]BC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]BC_NUM_MAX\f[R]
|
||||
The maximum length of a number (in decimal digits), which includes
|
||||
digits after the decimal point.
|
||||
Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]BC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]BC_RAND_MAX\f[R]
|
||||
The maximum integer (inclusive) returned by the \f[B]bcl_rand_int()\f[R]
|
||||
function.
|
||||
Set at \f[B]2\[ha]BC_LONG_BIT-1\f[R].
|
||||
Set at \f[B]2\[ha]BC_LONG_BIT\-1\f[R].
|
||||
.TP
|
||||
Exponent
|
||||
The maximum allowable exponent (positive or negative).
|
||||
Set at \f[B]BC_OVERFLOW_MAX\f[R].
|
||||
.PP
|
||||
These limits are meant to be effectively non-existent; the limits are so
|
||||
large (at least on 64-bit machines) that there should not be any point
|
||||
at which they become a problem.
|
||||
These limits are meant to be effectively non\-existent; the limits are
|
||||
so large (at least on 64\-bit machines) that there should not be any
|
||||
point at which they become a problem.
|
||||
In fact, memory should be exhausted before these limits should be hit.
|
||||
.SH SEE ALSO
|
||||
bc(1) and dc(1)
|
||||
.SH STANDARDS
|
||||
bcl(3) is compliant with the arithmetic defined in the IEEE Std
|
||||
1003.1-2017 (\[lq]POSIX.1-2017\[rq]) specification at
|
||||
1003.1\-2017 (\[lq]POSIX.1\-2017\[rq]) specification at
|
||||
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html for
|
||||
bc(1).
|
||||
.PP
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2024 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:
|
||||
|
@ -25,41 +25,41 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
|
||||
.nh
|
||||
.ad l
|
||||
.SH Name
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
dc \- arbitrary\-precision decimal reverse\-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
\f[B]dc\f[R] [\f[B]-cChiPRvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--digit-clamp\f[R]]
|
||||
[\f[B]--no-digit-clamp\f[R]] [\f[B]--interactive\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--no-read-prompt\f[R]]
|
||||
[\f[B]--extended-register\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...]
|
||||
[\f[B]-f\f[R] \f[I]file\f[R]\&...]
|
||||
[\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]dc\f[R] [\f[B]\-cChiPRvVx\f[R]] [\f[B]\-\-version\f[R]]
|
||||
[\f[B]\-\-help\f[R]] [\f[B]\-\-digit\-clamp\f[R]]
|
||||
[\f[B]\-\-no\-digit\-clamp\f[R]] [\f[B]\-\-interactive\f[R]]
|
||||
[\f[B]\-\-no\-prompt\f[R]] [\f[B]\-\-no\-read\-prompt\f[R]]
|
||||
[\f[B]\-\-extended\-register\f[R]] [\f[B]\-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\-\-expression\f[R]=\f[I]expr\f[R]\&...]
|
||||
[\f[B]\-f\f[R] \f[I]file\f[R]\&...]
|
||||
[\f[B]\-\-file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
dc(1) is an arbitrary-precision calculator.
|
||||
dc(1) is an arbitrary\-precision calculator.
|
||||
It uses a stack (reverse Polish notation) to store numbers and results
|
||||
of computations.
|
||||
Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line, then dc(1) reads from
|
||||
If no files are given on the command\-line, then dc(1) reads from
|
||||
\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
If a user wants to set up a standard environment, they can use
|
||||
\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
For example, if a user wants the \f[B]scale\f[R] always set to
|
||||
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
|
||||
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]\-e 10k\f[R],
|
||||
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
|
||||
.SH OPTIONS
|
||||
The following are the options that dc(1) accepts.
|
||||
.TP
|
||||
\f[B]-C\f[R], \f[B]--no-digit-clamp\f[R]
|
||||
\f[B]\-C\f[R], \f[B]\-\-no\-digit\-clamp\f[R]
|
||||
Disables clamping of digits greater than or equal to the current
|
||||
\f[B]ibase\f[R] when parsing numbers.
|
||||
.RS
|
||||
|
@ -69,17 +69,17 @@ digit\[cq]s value multiplied by the value of ibase raised to the power
|
|||
of the digit\[cq]s position, which starts from 0 at the least
|
||||
significant digit.
|
||||
.PP
|
||||
If this and/or the \f[B]-c\f[R] or \f[B]--digit-clamp\f[R] options are
|
||||
given multiple times, the last one given is used.
|
||||
If this and/or the \f[B]\-c\f[R] or \f[B]\-\-digit\-clamp\f[R] options
|
||||
are given multiple times, the last one given is used.
|
||||
.PP
|
||||
This option overrides the \f[B]DC_DIGIT_CLAMP\f[R] environment variable
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section) and the default, which
|
||||
can be queried with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
can be queried with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-c\f[R], \f[B]--digit-clamp\f[R]
|
||||
\f[B]\-c\f[R], \f[B]\-\-digit\-clamp\f[R]
|
||||
Enables clamping of digits greater than or equal to the current
|
||||
\f[B]ibase\f[R] when parsing numbers.
|
||||
.RS
|
||||
|
@ -90,17 +90,17 @@ all multiplied by the value of ibase raised to the power of the
|
|||
digit\[cq]s position, which starts from 0 at the least significant
|
||||
digit.
|
||||
.PP
|
||||
If this and/or the \f[B]-C\f[R] or \f[B]--no-digit-clamp\f[R] options
|
||||
are given multiple times, the last one given is used.
|
||||
If this and/or the \f[B]\-C\f[R] or \f[B]\-\-no\-digit\-clamp\f[R]
|
||||
options are given multiple times, the last one given is used.
|
||||
.PP
|
||||
This option overrides the \f[B]DC_DIGIT_CLAMP\f[R] environment variable
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section) and the default, which
|
||||
can be queried with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
can be queried with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]\-e\f[R] \f[I]expr\f[R], \f[B]\-\-expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
|
@ -109,44 +109,44 @@ This means that if a file is given before an expression, the file is
|
|||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
If this option is given on the command-line (i.e., not in
|
||||
If this option is given on the command\-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]\-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]\-f\f[R] or \f[B]\-\-file\f[R], whether on the command\-line or in
|
||||
\f[B]DC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, dc(1) will give a fatal error and
|
||||
exit.
|
||||
However, if any other \f[B]\-e\f[R], \f[B]\-\-expression\f[R],
|
||||
\f[B]\-f\f[R], or \f[B]\-\-file\f[R] arguments are given after
|
||||
\f[B]\-f\-\f[R] or equivalent is given, dc(1) will give a fatal error
|
||||
and exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
\f[B]\-f\f[R] \f[I]file\f[R], \f[B]\-\-file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
If this option is given on the command-line (i.e., not in
|
||||
If this option is given on the command\-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, dc(1) will give a fatal error and
|
||||
exit.
|
||||
\f[B]\-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]\-f\f[R] or \f[B]\-\-file\f[R].
|
||||
However, if any other \f[B]\-e\f[R], \f[B]\-\-expression\f[R],
|
||||
\f[B]\-f\f[R], or \f[B]\-\-file\f[R] arguments are given after
|
||||
\f[B]\-f\-\f[R] or equivalent is given, dc(1) will give a fatal error
|
||||
and exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
\f[B]\-h\f[R], \f[B]\-\-help\f[R]
|
||||
Prints a usage message and exits.
|
||||
.TP
|
||||
\f[B]-I\f[R] \f[I]ibase\f[R], \f[B]--ibase\f[R]=\f[I]ibase\f[R]
|
||||
\f[B]\-I\f[R] \f[I]ibase\f[R], \f[B]\-\-ibase\f[R]=\f[I]ibase\f[R]
|
||||
Sets the builtin variable \f[B]ibase\f[R] to the value \f[I]ibase\f[R]
|
||||
assuming that \f[I]ibase\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]ibase\f[R] is not a valid number.
|
||||
|
@ -154,28 +154,28 @@ It is a fatal error if \f[I]ibase\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
\f[B]\-i\f[R], \f[B]\-\-interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-L\f[R], \f[B]--no-line-length\f[R]
|
||||
\f[B]\-L\f[R], \f[B]\-\-no\-line\-length\f[R]
|
||||
Disables line length checking and prints numbers without backslashes and
|
||||
newlines.
|
||||
In other words, this option sets \f[B]BC_LINE_LENGTH\f[R] to \f[B]0\f[R]
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-O\f[R] \f[I]obase\f[R], \f[B]--obase\f[R]=\f[I]obase\f[R]
|
||||
\f[B]\-O\f[R] \f[I]obase\f[R], \f[B]\-\-obase\f[R]=\f[I]obase\f[R]
|
||||
Sets the builtin variable \f[B]obase\f[R] to the value \f[I]obase\f[R]
|
||||
assuming that \f[I]obase\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]obase\f[R] is not a valid number.
|
||||
|
@ -183,10 +183,10 @@ It is a fatal error if \f[I]obase\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
\f[B]\-P\f[R], \f[B]\-\-no\-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section.)
|
||||
|
@ -199,10 +199,10 @@ Most of those users would want to put this option in
|
|||
These options override the \f[B]DC_PROMPT\f[R] and \f[B]DC_TTY_MODE\f[R]
|
||||
environment variables (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
|
||||
\f[B]\-R\f[R], \f[B]\-\-no\-read\-prompt\f[R]
|
||||
Disables the read prompt in TTY mode.
|
||||
(The read prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section.)
|
||||
|
@ -221,10 +221,10 @@ These options \f[I]do\f[R] override the \f[B]DC_PROMPT\f[R] and
|
|||
\f[B]DC_TTY_MODE\f[R] environment variables (see the \f[B]ENVIRONMENT
|
||||
VARIABLES\f[R] section), but only for the read prompt.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-S\f[R] \f[I]scale\f[R], \f[B]--scale\f[R]=\f[I]scale\f[R]
|
||||
\f[B]\-S\f[R] \f[I]scale\f[R], \f[B]\-\-scale\f[R]=\f[I]scale\f[R]
|
||||
Sets the builtin variable \f[B]scale\f[R] to the value \f[I]scale\f[R]
|
||||
assuming that \f[I]scale\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]scale\f[R] is not a valid number.
|
||||
|
@ -232,34 +232,34 @@ It is a fatal error if \f[I]scale\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
\f[B]\-v\f[R], \f[B]\-V\f[R], \f[B]\-\-version\f[R]
|
||||
Print the version information (copyright header) and exits.
|
||||
.TP
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
\f[B]\-x\f[R] \f[B]\-\-extended\-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-z\f[R], \f[B]--leading-zeroes\f[R]
|
||||
Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than
|
||||
\f[B]\-z\f[R], \f[B]\-\-leading\-zeroes\f[R]
|
||||
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 is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.PP
|
||||
All long options are \f[B]non-portable extensions\f[R].
|
||||
All long options are \f[B]non\-portable extensions\f[R].
|
||||
.SH STDIN
|
||||
If no files are given on the command-line and no files or expressions
|
||||
are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
|
||||
\f[B]--expression\f[R] options, then dc(1) reads from \f[B]stdin\f[R].
|
||||
If no files are given on the command\-line and no files or expressions
|
||||
are given by the \f[B]\-f\f[R], \f[B]\-\-file\f[R], \f[B]\-e\f[R], or
|
||||
\f[B]\-\-expression\f[R] options, then dc(1) reads from \f[B]stdin\f[R].
|
||||
.PP
|
||||
However, there is a caveat to this.
|
||||
.PP
|
||||
|
@ -269,7 +269,7 @@ ended.
|
|||
This means that, except for escaped brackets, all brackets must be
|
||||
balanced before dc(1) parses and executes.
|
||||
.SH STDOUT
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
Any non\-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
|
@ -277,7 +277,7 @@ to \f[B]stdout\f[R].
|
|||
\f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
write to \f[B]stdout\f[R], so if \f[B]stdout\f[R] is closed, as in
|
||||
\f[B]dc >&-\f[R], it will quit with an error.
|
||||
\f[B]dc >&\-\f[R], it will quit with an error.
|
||||
This is done so that dc(1) can report problems when \f[B]stdout\f[R] is
|
||||
redirected to a file.
|
||||
.PP
|
||||
|
@ -290,7 +290,7 @@ Any error output is written to \f[B]stderr\f[R].
|
|||
\f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
write to \f[B]stderr\f[R], so if \f[B]stderr\f[R] is closed, as in
|
||||
\f[B]dc 2>&-\f[R], it will quit with an error.
|
||||
\f[B]dc 2>&\-\f[R], it will quit with an error.
|
||||
This is done so that dc(1) can exit with an error code when
|
||||
\f[B]stderr\f[R] is redirected to a file.
|
||||
.PP
|
||||
|
@ -333,7 +333,7 @@ The max allowable value for \f[B]scale\f[R] can be queried in dc(1)
|
|||
programs with the \f[B]V\f[R] command.
|
||||
.SS Comments
|
||||
Comments go from \f[B]#\f[R] until, and not including, the next newline.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.SH NUMBERS
|
||||
Numbers are strings made up of digits, uppercase letters up to
|
||||
\f[B]F\f[R], and at most \f[B]1\f[R] period for a radix.
|
||||
|
@ -344,12 +344,12 @@ alphabet (i.e., \f[B]A\f[R] equals \f[B]10\f[R], or \f[B]9+1\f[R]).
|
|||
If a digit or letter makes no sense with the current value of
|
||||
\f[B]ibase\f[R] (i.e., they are greater than or equal to the current
|
||||
value of \f[B]ibase\f[R]), then the behavior depends on the existence of
|
||||
the \f[B]-c\f[R]/\f[B]--digit-clamp\f[R] or
|
||||
\f[B]-C\f[R]/\f[B]--no-digit-clamp\f[R] options (see the
|
||||
the \f[B]\-c\f[R]/\f[B]\-\-digit\-clamp\f[R] or
|
||||
\f[B]\-C\f[R]/\f[B]\-\-no\-digit\-clamp\f[R] options (see the
|
||||
\f[B]OPTIONS\f[R] section), the existence and setting of the
|
||||
\f[B]DC_DIGIT_CLAMP\f[R] environment variable (see the \f[B]ENVIRONMENT
|
||||
VARIABLES\f[R] section), or the default, which can be queried with the
|
||||
\f[B]-h\f[R]/\f[B]--help\f[R] option.
|
||||
\f[B]\-h\f[R]/\f[B]\-\-help\f[R] option.
|
||||
.PP
|
||||
If clamping is off, then digits or letters that are greater than or
|
||||
equal to the current value of \f[B]ibase\f[R] are not changed.
|
||||
|
@ -367,7 +367,7 @@ This means that, with an \f[B]ibase\f[R] of \f[B]3\f[R], the number
|
|||
\f[B]AB\f[R] is equal to \f[B]3\[ha]1*2+3\[ha]0*2\f[R], which is
|
||||
\f[B]3\f[R] times \f[B]2\f[R] plus \f[B]2\f[R], or \f[B]8\f[R].
|
||||
.PP
|
||||
There is one exception to clamping: single-character numbers (i.e.,
|
||||
There is one exception to clamping: single\-character numbers (i.e.,
|
||||
\f[B]A\f[R] alone).
|
||||
Such numbers are never clamped and always take the value they would have
|
||||
in the highest possible \f[B]ibase\f[R].
|
||||
|
@ -403,12 +403,12 @@ Pops a value off the stack.
|
|||
.PP
|
||||
If the value is a number, it is truncated and the absolute value of the
|
||||
result is printed as though \f[B]obase\f[R] is \f[B]256\f[R] and each
|
||||
digit is interpreted as an 8-bit ASCII character, making it a byte
|
||||
digit is interpreted as an 8\-bit ASCII character, making it a byte
|
||||
stream.
|
||||
.PP
|
||||
If the value is a string, it is printed without a trailing newline.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]f\f[R]
|
||||
|
@ -427,7 +427,7 @@ pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to the max \f[I]scale\f[R] of
|
||||
both operands.
|
||||
.TP
|
||||
\f[B]-\f[R]
|
||||
\f[B]\-\f[R]
|
||||
The top two values are popped off the stack, subtracted, and the result
|
||||
is pushed onto the stack.
|
||||
The \f[I]scale\f[R] of the result is equal to the max \f[I]scale\f[R] of
|
||||
|
@ -448,7 +448,7 @@ pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
||||
.RS
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]%\f[R]
|
||||
|
@ -458,10 +458,10 @@ is pushed onto the stack.
|
|||
.PP
|
||||
Remaindering is equivalent to 1) Computing \f[B]a/b\f[R] to current
|
||||
\f[B]scale\f[R], and 2) Using the result of step 1 to calculate
|
||||
\f[B]a-(a/b)*b\f[R] to \f[I]scale\f[R]
|
||||
\f[B]a\-(a/b)*b\f[R] to \f[I]scale\f[R]
|
||||
\f[B]max(scale+scale(b),scale(a))\f[R].
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]\[ti]\f[R]
|
||||
|
@ -472,9 +472,9 @@ This is equivalent to \f[B]x y / x y %\f[R] except that \f[B]x\f[R] and
|
|||
\f[B]y\f[R] are only evaluated once.
|
||||
.RS
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]\[ha]\f[R]
|
||||
|
@ -485,7 +485,7 @@ The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
|||
.PP
|
||||
The first value popped off of the stack must be an integer, and if that
|
||||
value is negative, the second value popped off of the stack must be
|
||||
non-zero.
|
||||
non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]v\f[R]
|
||||
|
@ -494,7 +494,7 @@ the result is pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
||||
.RS
|
||||
.PP
|
||||
The value popped off of the stack must be non-negative.
|
||||
The value popped off of the stack must be non\-negative.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]_\f[R]
|
||||
|
@ -504,7 +504,7 @@ or other commands), then that number is input as a negative number.
|
|||
.PP
|
||||
Otherwise, the top value on the stack is popped and copied, and the copy
|
||||
is negated and pushed onto the stack.
|
||||
This behavior without a number is a \f[B]non-portable extension\f[R].
|
||||
This behavior without a number is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]b\f[R]
|
||||
|
@ -513,7 +513,7 @@ back onto the stack.
|
|||
Otherwise, its absolute value is pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]|\f[R]
|
||||
|
@ -522,12 +522,12 @@ is computed, and the result is pushed onto the stack.
|
|||
.RS
|
||||
.PP
|
||||
The first value popped is used as the reduction modulus and must be an
|
||||
integer and non-zero.
|
||||
integer and non\-zero.
|
||||
The second value popped is used as the exponent and must be an integer
|
||||
and non-negative.
|
||||
and non\-negative.
|
||||
The third value popped is the base and must be an integer.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]G\f[R]
|
||||
|
@ -535,7 +535,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]1\f[R] is pushed if they are equal, or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]N\f[R]
|
||||
|
@ -543,7 +543,7 @@ The top value is popped off of the stack, and if it a \f[B]0\f[R], a
|
|||
\f[B]1\f[R] is pushed; otherwise, a \f[B]0\f[R] is pushed.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B](\f[R]
|
||||
|
@ -552,7 +552,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]{\f[R]
|
||||
|
@ -561,7 +561,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B])\f[R]
|
||||
|
@ -570,7 +570,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]}\f[R]
|
||||
|
@ -579,33 +579,33 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
second, or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]M\f[R]
|
||||
The top two values are popped off of the stack.
|
||||
If they are both non-zero, a \f[B]1\f[R] is pushed onto the stack.
|
||||
If they are both non\-zero, a \f[B]1\f[R] is pushed onto the stack.
|
||||
If either of them is zero, or both of them are, then a \f[B]0\f[R] is
|
||||
pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is like the \f[B]&&\f[R] operator in bc(1), and it is \f[I]not\f[R]
|
||||
a short-circuit operator.
|
||||
a short\-circuit operator.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]m\f[R]
|
||||
The top two values are popped off of the stack.
|
||||
If at least one of them is non-zero, a \f[B]1\f[R] is pushed onto the
|
||||
If at least one of them is non\-zero, a \f[B]1\f[R] is pushed onto the
|
||||
stack.
|
||||
If both of them are zero, then a \f[B]0\f[R] is pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is like the \f[B]||\f[R] operator in bc(1), and it is \f[I]not\f[R]
|
||||
a short-circuit operator.
|
||||
a short\-circuit operator.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Stack Control
|
||||
These commands control the stack.
|
||||
|
@ -670,7 +670,7 @@ If the value on top of the stack has any \f[I]scale\f[R], the
|
|||
.TP
|
||||
\f[B]k\f[R]
|
||||
Pops the value off of the top of the stack and uses it to set
|
||||
\f[B]scale\f[R], which must be non-negative.
|
||||
\f[B]scale\f[R], which must be non\-negative.
|
||||
.RS
|
||||
.PP
|
||||
If the value on top of the stack has any \f[I]scale\f[R], the
|
||||
|
@ -691,7 +691,7 @@ Pushes the maximum allowable value of \f[B]ibase\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]U\f[R]
|
||||
|
@ -699,7 +699,7 @@ Pushes the maximum allowable value of \f[B]obase\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]V\f[R]
|
||||
|
@ -707,7 +707,7 @@ Pushes the maximum allowable value of \f[B]scale\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Strings
|
||||
The following commands control strings.
|
||||
|
@ -747,16 +747,16 @@ The value on top of the stack is popped.
|
|||
If it is a number, it is truncated and its absolute value is taken.
|
||||
The result mod \f[B]256\f[R] is calculated.
|
||||
If that result is \f[B]0\f[R], push an empty string; otherwise, push a
|
||||
one-character string where the character is the result of the mod
|
||||
one\-character string where the character is the result of the mod
|
||||
interpreted as an ASCII character.
|
||||
.PP
|
||||
If it is a string, then a new string is made.
|
||||
If the original string is empty, the new string is empty.
|
||||
If it is not, then the first character of the original string is used to
|
||||
create the new string as a one-character string.
|
||||
create the new string as a one\-character string.
|
||||
The new string is then pushed onto the stack.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]x\f[R]
|
||||
|
@ -792,7 +792,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!>\f[R]\f[I]r\f[R]
|
||||
|
@ -813,7 +813,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]<\f[R]\f[I]r\f[R]
|
||||
|
@ -834,7 +834,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!<\f[R]\f[I]r\f[R]
|
||||
|
@ -855,7 +855,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]=\f[R]\f[I]r\f[R]
|
||||
|
@ -876,7 +876,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!=\f[R]\f[I]r\f[R]
|
||||
|
@ -897,7 +897,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]?\f[R]
|
||||
|
@ -910,7 +910,7 @@ the execution of the macro that executed it.
|
|||
If there are no macros, or only one macro executing, dc(1) exits.
|
||||
.TP
|
||||
\f[B]Q\f[R]
|
||||
Pops a value from the stack which must be non-negative and is used the
|
||||
Pops a value from the stack which must be non\-negative and is used the
|
||||
number of macro executions to pop off of the execution stack.
|
||||
If the number of levels to pop is greater than the number of executing
|
||||
macros, dc(1) exits.
|
||||
|
@ -923,7 +923,7 @@ to make dc(1) exit with the \f[B]Q\f[R] command, so the sequence
|
|||
\f[B],Q\f[R] will make dc(1) exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Status
|
||||
These commands query status of the stack or its top value.
|
||||
|
@ -956,7 +956,7 @@ If the value is a number, this pushes \f[B]1\f[R] onto the stack.
|
|||
Otherwise (if it is a string), it pushes \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]t\f[R]
|
||||
|
@ -965,7 +965,7 @@ If the value is a string, this pushes \f[B]1\f[R] onto the stack.
|
|||
Otherwise (if it is a number), it pushes \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]z\f[R]
|
||||
|
@ -983,7 +983,7 @@ register\[cq]s stack must always have at least one item; dc(1) will give
|
|||
an error and reset otherwise (see the \f[B]RESET\f[R] section).
|
||||
This means that this command will never push \f[B]0\f[R].
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Arrays
|
||||
These commands manipulate arrays.
|
||||
|
@ -1002,7 +1002,7 @@ The selected value is then pushed onto the stack.
|
|||
Pushes the length of the array \f[I]r\f[R] onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Global Settings
|
||||
These commands retrieve global settings.
|
||||
|
@ -1024,8 +1024,8 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
|||
.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
|
||||
(see the \f[B]OPTIONS\f[R] section), non-zero otherwise.
|
||||
been enabled with the \f[B]\-z\f[R] or \f[B]\-\-leading\-zeroes\f[R]
|
||||
options (see the \f[B]OPTIONS\f[R] section), non\-zero otherwise.
|
||||
.SH REGISTERS
|
||||
Registers are names that can store strings, numbers, and arrays.
|
||||
(Number/string registers do not interfere with array registers.)
|
||||
|
@ -1036,7 +1036,7 @@ All registers, when first referenced, have one value (\f[B]0\f[R]) in
|
|||
their stack, and it is a runtime error to attempt to pop that item off
|
||||
of the register stack.
|
||||
.PP
|
||||
In non-extended register mode, a register name is just the single
|
||||
In non\-extended register mode, a register name is just the single
|
||||
character that follows any command that needs a register name.
|
||||
The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
|
||||
bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
|
||||
|
@ -1045,18 +1045,18 @@ bracket to be used as a register name.
|
|||
Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
If extended register mode is enabled (\f[B]\-x\f[R] or
|
||||
\f[B]\-\-extended\-register\f[R] command\-line arguments are given),
|
||||
then normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
(\f[B]`\[rs]n'\f[R]).
|
||||
.PP
|
||||
In that case, the register name is found according to the regex
|
||||
\f[B][a-z][a-z0-9_]*\f[R] (like bc(1) identifiers), and it is a parse
|
||||
error if the next non-space characters do not match that regex.
|
||||
\f[B][a\-z][a\-z0\-9_]*\f[R] (like bc(1) identifiers), and it is a parse
|
||||
error if the next non\-space characters do not match that regex.
|
||||
.SH RESET
|
||||
When dc(1) encounters an error or a signal that it has a non-default
|
||||
When dc(1) encounters an error or a signal that it has a non\-default
|
||||
handler for, it resets.
|
||||
This means that several things happen.
|
||||
.PP
|
||||
|
@ -1120,24 +1120,24 @@ Set at \f[B]DC_BASE_POW\f[R].
|
|||
.TP
|
||||
\f[B]DC_DIM_MAX\f[R]
|
||||
The maximum size of arrays.
|
||||
Set at \f[B]SIZE_MAX-1\f[R].
|
||||
Set at \f[B]SIZE_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_SCALE_MAX\f[R]
|
||||
The maximum \f[B]scale\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_STRING_MAX\f[R]
|
||||
The maximum length of strings.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_NAME_MAX\f[R]
|
||||
The maximum length of identifiers.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_NUM_MAX\f[R]
|
||||
The maximum length of a number (in decimal digits), which includes
|
||||
digits after the decimal point.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
Exponent
|
||||
The maximum allowable exponent (positive or negative).
|
||||
|
@ -1145,27 +1145,27 @@ Set at \f[B]DC_OVERFLOW_MAX\f[R].
|
|||
.TP
|
||||
Number of vars
|
||||
The maximum number of vars/arrays.
|
||||
Set at \f[B]SIZE_MAX-1\f[R].
|
||||
Set at \f[B]SIZE_MAX\-1\f[R].
|
||||
.PP
|
||||
These limits are meant to be effectively non-existent; the limits are so
|
||||
large (at least on 64-bit machines) that there should not be any point
|
||||
at which they become a problem.
|
||||
These limits are meant to be effectively non\-existent; the limits are
|
||||
so large (at least on 64\-bit machines) that there should not be any
|
||||
point at which they become a problem.
|
||||
In fact, memory should be exhausted before these limits should be hit.
|
||||
.SH ENVIRONMENT VARIABLES
|
||||
As \f[B]non-portable extensions\f[R], dc(1) recognizes the following
|
||||
As \f[B]non\-portable extensions\f[R], dc(1) recognizes the following
|
||||
environment variables:
|
||||
.TP
|
||||
\f[B]DC_ENV_ARGS\f[R]
|
||||
This is another way to give command-line arguments to dc(1).
|
||||
They should be in the same format as all other command-line arguments.
|
||||
This is another way to give command\-line arguments to dc(1).
|
||||
They should be in the same format as all other command\-line arguments.
|
||||
These are always processed first, so any files given in
|
||||
\f[B]DC_ENV_ARGS\f[R] will be processed before arguments and files given
|
||||
on the command-line.
|
||||
on the command\-line.
|
||||
This gives the user the ability to set up \[lq]standard\[rq] options and
|
||||
files to be used at every invocation.
|
||||
The most useful thing for such files to contain would be useful
|
||||
functions that the user might want every time dc(1) runs.
|
||||
Another use would be to use the \f[B]-e\f[R] option to set
|
||||
Another use would be to use the \f[B]\-e\f[R] option to set
|
||||
\f[B]scale\f[R] to a value other than \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
|
@ -1183,14 +1183,14 @@ you can use double quotes as the outside quotes, as in \f[B]\[lq]some
|
|||
quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
parsing, though such files are still supported on the command-line where
|
||||
the parsing is done by the shell.
|
||||
parsing, though such files are still supported on the command\-line
|
||||
where the parsing is done by the shell.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_LINE_LENGTH\f[R]
|
||||
If this environment variable exists and contains an integer that is
|
||||
greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
|
||||
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
|
||||
(\f[B]2\[ha]16\-1\f[R]), dc(1) will output lines to that length,
|
||||
including the backslash newline combo.
|
||||
The default line length is \f[B]70\f[R].
|
||||
.RS
|
||||
|
@ -1207,13 +1207,13 @@ exits on \f[B]SIGINT\f[R] when not in interactive mode.
|
|||
.RS
|
||||
.PP
|
||||
However, when dc(1) is in interactive mode, then if this environment
|
||||
variable exists and contains an integer, a non-zero value makes dc(1)
|
||||
variable exists and contains an integer, a non\-zero value makes dc(1)
|
||||
reset on \f[B]SIGINT\f[R], rather than exit, and zero makes dc(1) exit.
|
||||
If this environment variable exists and is \f[I]not\f[R] an integer,
|
||||
then dc(1) will exit on \f[B]SIGINT\f[R].
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_TTY_MODE\f[R]
|
||||
|
@ -1222,11 +1222,11 @@ section), then this environment variable has no effect.
|
|||
.RS
|
||||
.PP
|
||||
However, when TTY mode is available, then if this environment variable
|
||||
exists and contains an integer, then a non-zero value makes dc(1) use
|
||||
exists and contains an integer, then a non\-zero value makes dc(1) use
|
||||
TTY mode, and zero makes dc(1) not use TTY mode.
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_PROMPT\f[R]
|
||||
|
@ -1235,43 +1235,44 @@ section), then this environment variable has no effect.
|
|||
.RS
|
||||
.PP
|
||||
However, when TTY mode is available, then if this environment variable
|
||||
exists and contains an integer, a non-zero value makes dc(1) use a
|
||||
prompt, and zero or a non-integer makes dc(1) not use a prompt.
|
||||
exists and contains an integer, a non\-zero value makes dc(1) use a
|
||||
prompt, and zero or a non\-integer makes dc(1) not use a prompt.
|
||||
If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
|
||||
does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
|
||||
is used.
|
||||
.PP
|
||||
This environment variable and the \f[B]DC_TTY_MODE\f[R] environment
|
||||
variable override the default, which can be queried with the
|
||||
\f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
\f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_EXPR_EXIT\f[R]
|
||||
If any expressions or expression files are given on the command-line
|
||||
with \f[B]-e\f[R], \f[B]--expression\f[R], \f[B]-f\f[R], or
|
||||
\f[B]--file\f[R], then if this environment variable exists and contains
|
||||
an integer, a non-zero value makes dc(1) exit after executing the
|
||||
expressions and expression files, and a zero value makes dc(1) not exit.
|
||||
If any expressions or expression files are given on the command\-line
|
||||
with \f[B]\-e\f[R], \f[B]\-\-expression\f[R], \f[B]\-f\f[R], or
|
||||
\f[B]\-\-file\f[R], then if this environment variable exists and
|
||||
contains an integer, a non\-zero value makes dc(1) exit after executing
|
||||
the expressions and expression files, and a zero value makes dc(1) not
|
||||
exit.
|
||||
.RS
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_DIGIT_CLAMP\f[R]
|
||||
When parsing numbers and if this environment variable exists and
|
||||
contains an integer, a non-zero value makes dc(1) clamp digits that are
|
||||
contains an integer, a non\-zero value makes dc(1) clamp digits that are
|
||||
greater than or equal to the current \f[B]ibase\f[R] so that all such
|
||||
digits are considered equal to the \f[B]ibase\f[R] minus 1, and a zero
|
||||
value disables such clamping so that those digits are always equal to
|
||||
their value, which is multiplied by the power of the \f[B]ibase\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This never applies to single-digit numbers, as per the bc(1) standard
|
||||
This never applies to single\-digit numbers, as per the bc(1) standard
|
||||
(see the \f[B]STANDARDS\f[R] section).
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.SH EXIT STATUS
|
||||
dc(1) returns the following exit statuses:
|
||||
|
@ -1289,7 +1290,7 @@ Math errors include divide by \f[B]0\f[R], taking the square root of a
|
|||
negative number, attempting to convert a negative number to a hardware
|
||||
integer, overflow when converting a number to a hardware integer,
|
||||
overflow when calculating the size of a number, and attempting to use a
|
||||
non-integer where an integer is required.
|
||||
non\-integer where an integer is required.
|
||||
.PP
|
||||
Converting to a hardware integer happens for the second operand of the
|
||||
power (\f[B]\[ha]\f[R]) operator.
|
||||
|
@ -1323,7 +1324,7 @@ A fatal error occurred.
|
|||
Fatal errors include memory allocation errors, I/O errors, failing to
|
||||
open files, attempting to use files that do not have only ASCII
|
||||
characters (dc(1) only accepts ASCII characters), attempting to open a
|
||||
directory as a file, and giving invalid command-line options.
|
||||
directory as a file, and giving invalid command\-line options.
|
||||
.RE
|
||||
.PP
|
||||
The exit status \f[B]4\f[R] is special; when a fatal error occurs, dc(1)
|
||||
|
@ -1334,16 +1335,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
|||
dc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
\f[B]\-i\f[R] flag or \f[B]\-\-interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow dc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
\f[B]\-i\f[R] flag or \f[B]\-\-interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
Like bc(1), dc(1) has an interactive mode and a non-interactive mode.
|
||||
Like bc(1), dc(1) has an interactive mode and a non\-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]--interactive\f[R] option can turn it on in other situations.
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]\-i\f[R]
|
||||
flag and \f[B]\-\-interactive\f[R] option can turn it on in other
|
||||
situations.
|
||||
.PP
|
||||
In interactive mode, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
@ -1359,23 +1361,23 @@ settings.
|
|||
.PP
|
||||
If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
|
||||
environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
|
||||
that environment variable contains a non-zero integer, dc(1) will turn
|
||||
that environment variable contains a non\-zero integer, dc(1) will turn
|
||||
on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R]
|
||||
are all connected to a TTY.
|
||||
If the \f[B]DC_TTY_MODE\f[R] environment variable exists but is
|
||||
\f[I]not\f[R] a non-zero integer, then dc(1) will not turn TTY mode on.
|
||||
\f[I]not\f[R] a non\-zero integer, then dc(1) will not turn TTY mode on.
|
||||
.PP
|
||||
If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
|
||||
exist, the default setting is used.
|
||||
The default setting can be queried with the \f[B]-h\f[R] or
|
||||
\f[B]--help\f[R] options.
|
||||
The default setting can be queried with the \f[B]\-h\f[R] or
|
||||
\f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
TTY mode is different from interactive mode because interactive mode is
|
||||
required in the bc(1) specification (see the \f[B]STANDARDS\f[R]
|
||||
section), and interactive mode requires only \f[B]stdin\f[R] and
|
||||
\f[B]stdout\f[R] to be connected to a terminal.
|
||||
.SS Command-Line History
|
||||
Command-line history is only enabled if TTY mode is, i.e., that
|
||||
.SS Command\-Line History
|
||||
Command\-line history is only enabled if TTY mode is, i.e., that
|
||||
\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to
|
||||
a TTY and the \f[B]DC_TTY_MODE\f[R] environment variable (see the
|
||||
\f[B]ENVIRONMENT VARIABLES\f[R] section) and its default do not disable
|
||||
|
@ -1387,18 +1389,18 @@ Like TTY mode itself, it can be turned on or off with an environment
|
|||
variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
|
||||
section).
|
||||
.PP
|
||||
If the environment variable \f[B]DC_PROMPT\f[R] exists and is a non-zero
|
||||
integer, then the prompt is turned on when \f[B]stdin\f[R],
|
||||
If the environment variable \f[B]DC_PROMPT\f[R] exists and is a
|
||||
non\-zero integer, then the prompt is turned on when \f[B]stdin\f[R],
|
||||
\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
|
||||
\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
|
||||
\f[B]\-P\f[R] and \f[B]\-\-no\-prompt\f[R] options were not used.
|
||||
The read prompt will be turned on under the same conditions, except that
|
||||
the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
|
||||
used.
|
||||
the \f[B]\-R\f[R] and \f[B]\-\-no\-read\-prompt\f[R] options must also
|
||||
not be used.
|
||||
.PP
|
||||
However, if \f[B]DC_PROMPT\f[R] does not exist, the prompt can be
|
||||
enabled or disabled with the \f[B]DC_TTY_MODE\f[R] environment variable,
|
||||
the \f[B]-P\f[R] and \f[B]--no-prompt\f[R] options, and the \f[B]-R\f[R]
|
||||
and \f[B]--no-read-prompt\f[R] options.
|
||||
the \f[B]\-P\f[R] and \f[B]\-\-no\-prompt\f[R] options, and the
|
||||
\f[B]\-R\f[R] and \f[B]\-\-no\-read\-prompt\f[R] options.
|
||||
See the \f[B]ENVIRONMENT VARIABLES\f[R] and \f[B]OPTIONS\f[R] sections
|
||||
for more details.
|
||||
.SH SIGNAL HANDLING
|
||||
|
@ -1410,7 +1412,7 @@ section), or the \f[B]DC_SIGINT_RESET\f[R] environment variable (see the
|
|||
an integer or it is zero, dc(1) will exit.
|
||||
.PP
|
||||
However, if dc(1) is in interactive mode, and the
|
||||
\f[B]DC_SIGINT_RESET\f[R] or its default is an integer and non-zero,
|
||||
\f[B]DC_SIGINT_RESET\f[R] or its default is an integer and non\-zero,
|
||||
then dc(1) will stop executing the current input and reset (see the
|
||||
\f[B]RESET\f[R] section) upon receiving a \f[B]SIGINT\f[R].
|
||||
.PP
|
||||
|
@ -1436,11 +1438,11 @@ The one exception is \f[B]SIGHUP\f[R]; in that case, and only when dc(1)
|
|||
is in TTY mode (see the \f[B]TTY MODE\f[R] section), a \f[B]SIGHUP\f[R]
|
||||
will cause dc(1) to clean up and exit.
|
||||
.SH COMMAND LINE HISTORY
|
||||
dc(1) supports interactive command-line editing.
|
||||
dc(1) supports interactive command\-line editing.
|
||||
.PP
|
||||
If dc(1) can be in TTY mode (see the \f[B]TTY MODE\f[R] section),
|
||||
history can be enabled.
|
||||
This means that command-line history can only be enabled when
|
||||
This means that command\-line history can only be enabled when
|
||||
\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
|
||||
connected to a TTY.
|
||||
.PP
|
||||
|
@ -1456,7 +1458,7 @@ locales and thus, supports \f[B]LC_MESSAGES\f[R].
|
|||
bc(1)
|
||||
.SH STANDARDS
|
||||
The dc(1) utility operators and some behavior are compliant with the
|
||||
operators in the IEEE Std 1003.1-2017 (\[lq]POSIX.1-2017\[rq]) bc(1)
|
||||
operators in the IEEE Std 1003.1\-2017 (\[lq]POSIX.1\-2017\[rq]) bc(1)
|
||||
specification at
|
||||
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html .
|
||||
.SH BUGS
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2024 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:
|
||||
|
@ -25,41 +25,41 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
|
||||
.nh
|
||||
.ad l
|
||||
.SH Name
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
dc \- arbitrary\-precision decimal reverse\-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
\f[B]dc\f[R] [\f[B]-cChiPRvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--digit-clamp\f[R]]
|
||||
[\f[B]--no-digit-clamp\f[R]] [\f[B]--interactive\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--no-read-prompt\f[R]]
|
||||
[\f[B]--extended-register\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...]
|
||||
[\f[B]-f\f[R] \f[I]file\f[R]\&...]
|
||||
[\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]dc\f[R] [\f[B]\-cChiPRvVx\f[R]] [\f[B]\-\-version\f[R]]
|
||||
[\f[B]\-\-help\f[R]] [\f[B]\-\-digit\-clamp\f[R]]
|
||||
[\f[B]\-\-no\-digit\-clamp\f[R]] [\f[B]\-\-interactive\f[R]]
|
||||
[\f[B]\-\-no\-prompt\f[R]] [\f[B]\-\-no\-read\-prompt\f[R]]
|
||||
[\f[B]\-\-extended\-register\f[R]] [\f[B]\-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\-\-expression\f[R]=\f[I]expr\f[R]\&...]
|
||||
[\f[B]\-f\f[R] \f[I]file\f[R]\&...]
|
||||
[\f[B]\-\-file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
dc(1) is an arbitrary-precision calculator.
|
||||
dc(1) is an arbitrary\-precision calculator.
|
||||
It uses a stack (reverse Polish notation) to store numbers and results
|
||||
of computations.
|
||||
Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line, then dc(1) reads from
|
||||
If no files are given on the command\-line, then dc(1) reads from
|
||||
\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
If a user wants to set up a standard environment, they can use
|
||||
\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
For example, if a user wants the \f[B]scale\f[R] always set to
|
||||
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
|
||||
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]\-e 10k\f[R],
|
||||
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
|
||||
.SH OPTIONS
|
||||
The following are the options that dc(1) accepts.
|
||||
.TP
|
||||
\f[B]-C\f[R], \f[B]--no-digit-clamp\f[R]
|
||||
\f[B]\-C\f[R], \f[B]\-\-no\-digit\-clamp\f[R]
|
||||
Disables clamping of digits greater than or equal to the current
|
||||
\f[B]ibase\f[R] when parsing numbers.
|
||||
.RS
|
||||
|
@ -69,17 +69,17 @@ digit\[cq]s value multiplied by the value of ibase raised to the power
|
|||
of the digit\[cq]s position, which starts from 0 at the least
|
||||
significant digit.
|
||||
.PP
|
||||
If this and/or the \f[B]-c\f[R] or \f[B]--digit-clamp\f[R] options are
|
||||
given multiple times, the last one given is used.
|
||||
If this and/or the \f[B]\-c\f[R] or \f[B]\-\-digit\-clamp\f[R] options
|
||||
are given multiple times, the last one given is used.
|
||||
.PP
|
||||
This option overrides the \f[B]DC_DIGIT_CLAMP\f[R] environment variable
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section) and the default, which
|
||||
can be queried with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
can be queried with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-c\f[R], \f[B]--digit-clamp\f[R]
|
||||
\f[B]\-c\f[R], \f[B]\-\-digit\-clamp\f[R]
|
||||
Enables clamping of digits greater than or equal to the current
|
||||
\f[B]ibase\f[R] when parsing numbers.
|
||||
.RS
|
||||
|
@ -90,17 +90,17 @@ all multiplied by the value of ibase raised to the power of the
|
|||
digit\[cq]s position, which starts from 0 at the least significant
|
||||
digit.
|
||||
.PP
|
||||
If this and/or the \f[B]-C\f[R] or \f[B]--no-digit-clamp\f[R] options
|
||||
are given multiple times, the last one given is used.
|
||||
If this and/or the \f[B]\-C\f[R] or \f[B]\-\-no\-digit\-clamp\f[R]
|
||||
options are given multiple times, the last one given is used.
|
||||
.PP
|
||||
This option overrides the \f[B]DC_DIGIT_CLAMP\f[R] environment variable
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section) and the default, which
|
||||
can be queried with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
can be queried with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]\-e\f[R] \f[I]expr\f[R], \f[B]\-\-expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
|
@ -109,44 +109,44 @@ This means that if a file is given before an expression, the file is
|
|||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
If this option is given on the command-line (i.e., not in
|
||||
If this option is given on the command\-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]\-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]\-f\f[R] or \f[B]\-\-file\f[R], whether on the command\-line or in
|
||||
\f[B]DC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, dc(1) will give a fatal error and
|
||||
exit.
|
||||
However, if any other \f[B]\-e\f[R], \f[B]\-\-expression\f[R],
|
||||
\f[B]\-f\f[R], or \f[B]\-\-file\f[R] arguments are given after
|
||||
\f[B]\-f\-\f[R] or equivalent is given, dc(1) will give a fatal error
|
||||
and exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
\f[B]\-f\f[R] \f[I]file\f[R], \f[B]\-\-file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
If this option is given on the command-line (i.e., not in
|
||||
If this option is given on the command\-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, dc(1) will give a fatal error and
|
||||
exit.
|
||||
\f[B]\-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]\-f\f[R] or \f[B]\-\-file\f[R].
|
||||
However, if any other \f[B]\-e\f[R], \f[B]\-\-expression\f[R],
|
||||
\f[B]\-f\f[R], or \f[B]\-\-file\f[R] arguments are given after
|
||||
\f[B]\-f\-\f[R] or equivalent is given, dc(1) will give a fatal error
|
||||
and exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
\f[B]\-h\f[R], \f[B]\-\-help\f[R]
|
||||
Prints a usage message and exits.
|
||||
.TP
|
||||
\f[B]-I\f[R] \f[I]ibase\f[R], \f[B]--ibase\f[R]=\f[I]ibase\f[R]
|
||||
\f[B]\-I\f[R] \f[I]ibase\f[R], \f[B]\-\-ibase\f[R]=\f[I]ibase\f[R]
|
||||
Sets the builtin variable \f[B]ibase\f[R] to the value \f[I]ibase\f[R]
|
||||
assuming that \f[I]ibase\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]ibase\f[R] is not a valid number.
|
||||
|
@ -154,28 +154,28 @@ It is a fatal error if \f[I]ibase\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
\f[B]\-i\f[R], \f[B]\-\-interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-L\f[R], \f[B]--no-line-length\f[R]
|
||||
\f[B]\-L\f[R], \f[B]\-\-no\-line\-length\f[R]
|
||||
Disables line length checking and prints numbers without backslashes and
|
||||
newlines.
|
||||
In other words, this option sets \f[B]BC_LINE_LENGTH\f[R] to \f[B]0\f[R]
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-O\f[R] \f[I]obase\f[R], \f[B]--obase\f[R]=\f[I]obase\f[R]
|
||||
\f[B]\-O\f[R] \f[I]obase\f[R], \f[B]\-\-obase\f[R]=\f[I]obase\f[R]
|
||||
Sets the builtin variable \f[B]obase\f[R] to the value \f[I]obase\f[R]
|
||||
assuming that \f[I]obase\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]obase\f[R] is not a valid number.
|
||||
|
@ -183,10 +183,10 @@ It is a fatal error if \f[I]obase\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
\f[B]\-P\f[R], \f[B]\-\-no\-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section.)
|
||||
|
@ -199,10 +199,10 @@ Most of those users would want to put this option in
|
|||
These options override the \f[B]DC_PROMPT\f[R] and \f[B]DC_TTY_MODE\f[R]
|
||||
environment variables (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
|
||||
\f[B]\-R\f[R], \f[B]\-\-no\-read\-prompt\f[R]
|
||||
Disables the read prompt in TTY mode.
|
||||
(The read prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section.)
|
||||
|
@ -221,10 +221,10 @@ These options \f[I]do\f[R] override the \f[B]DC_PROMPT\f[R] and
|
|||
\f[B]DC_TTY_MODE\f[R] environment variables (see the \f[B]ENVIRONMENT
|
||||
VARIABLES\f[R] section), but only for the read prompt.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-S\f[R] \f[I]scale\f[R], \f[B]--scale\f[R]=\f[I]scale\f[R]
|
||||
\f[B]\-S\f[R] \f[I]scale\f[R], \f[B]\-\-scale\f[R]=\f[I]scale\f[R]
|
||||
Sets the builtin variable \f[B]scale\f[R] to the value \f[I]scale\f[R]
|
||||
assuming that \f[I]scale\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]scale\f[R] is not a valid number.
|
||||
|
@ -232,34 +232,34 @@ It is a fatal error if \f[I]scale\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
\f[B]\-v\f[R], \f[B]\-V\f[R], \f[B]\-\-version\f[R]
|
||||
Print the version information (copyright header) and exits.
|
||||
.TP
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
\f[B]\-x\f[R] \f[B]\-\-extended\-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-z\f[R], \f[B]--leading-zeroes\f[R]
|
||||
Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than
|
||||
\f[B]\-z\f[R], \f[B]\-\-leading\-zeroes\f[R]
|
||||
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 is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.PP
|
||||
All long options are \f[B]non-portable extensions\f[R].
|
||||
All long options are \f[B]non\-portable extensions\f[R].
|
||||
.SH STDIN
|
||||
If no files are given on the command-line and no files or expressions
|
||||
are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
|
||||
\f[B]--expression\f[R] options, then dc(1) reads from \f[B]stdin\f[R].
|
||||
If no files are given on the command\-line and no files or expressions
|
||||
are given by the \f[B]\-f\f[R], \f[B]\-\-file\f[R], \f[B]\-e\f[R], or
|
||||
\f[B]\-\-expression\f[R] options, then dc(1) reads from \f[B]stdin\f[R].
|
||||
.PP
|
||||
However, there is a caveat to this.
|
||||
.PP
|
||||
|
@ -269,7 +269,7 @@ ended.
|
|||
This means that, except for escaped brackets, all brackets must be
|
||||
balanced before dc(1) parses and executes.
|
||||
.SH STDOUT
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
Any non\-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
|
@ -277,7 +277,7 @@ to \f[B]stdout\f[R].
|
|||
\f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
write to \f[B]stdout\f[R], so if \f[B]stdout\f[R] is closed, as in
|
||||
\f[B]dc >&-\f[R], it will quit with an error.
|
||||
\f[B]dc >&\-\f[R], it will quit with an error.
|
||||
This is done so that dc(1) can report problems when \f[B]stdout\f[R] is
|
||||
redirected to a file.
|
||||
.PP
|
||||
|
@ -290,7 +290,7 @@ Any error output is written to \f[B]stderr\f[R].
|
|||
\f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
write to \f[B]stderr\f[R], so if \f[B]stderr\f[R] is closed, as in
|
||||
\f[B]dc 2>&-\f[R], it will quit with an error.
|
||||
\f[B]dc 2>&\-\f[R], it will quit with an error.
|
||||
This is done so that dc(1) can exit with an error code when
|
||||
\f[B]stderr\f[R] is redirected to a file.
|
||||
.PP
|
||||
|
@ -333,7 +333,7 @@ The max allowable value for \f[B]scale\f[R] can be queried in dc(1)
|
|||
programs with the \f[B]V\f[R] command.
|
||||
.SS Comments
|
||||
Comments go from \f[B]#\f[R] until, and not including, the next newline.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.SH NUMBERS
|
||||
Numbers are strings made up of digits, uppercase letters up to
|
||||
\f[B]F\f[R], and at most \f[B]1\f[R] period for a radix.
|
||||
|
@ -344,12 +344,12 @@ alphabet (i.e., \f[B]A\f[R] equals \f[B]10\f[R], or \f[B]9+1\f[R]).
|
|||
If a digit or letter makes no sense with the current value of
|
||||
\f[B]ibase\f[R] (i.e., they are greater than or equal to the current
|
||||
value of \f[B]ibase\f[R]), then the behavior depends on the existence of
|
||||
the \f[B]-c\f[R]/\f[B]--digit-clamp\f[R] or
|
||||
\f[B]-C\f[R]/\f[B]--no-digit-clamp\f[R] options (see the
|
||||
the \f[B]\-c\f[R]/\f[B]\-\-digit\-clamp\f[R] or
|
||||
\f[B]\-C\f[R]/\f[B]\-\-no\-digit\-clamp\f[R] options (see the
|
||||
\f[B]OPTIONS\f[R] section), the existence and setting of the
|
||||
\f[B]DC_DIGIT_CLAMP\f[R] environment variable (see the \f[B]ENVIRONMENT
|
||||
VARIABLES\f[R] section), or the default, which can be queried with the
|
||||
\f[B]-h\f[R]/\f[B]--help\f[R] option.
|
||||
\f[B]\-h\f[R]/\f[B]\-\-help\f[R] option.
|
||||
.PP
|
||||
If clamping is off, then digits or letters that are greater than or
|
||||
equal to the current value of \f[B]ibase\f[R] are not changed.
|
||||
|
@ -367,7 +367,7 @@ This means that, with an \f[B]ibase\f[R] of \f[B]3\f[R], the number
|
|||
\f[B]AB\f[R] is equal to \f[B]3\[ha]1*2+3\[ha]0*2\f[R], which is
|
||||
\f[B]3\f[R] times \f[B]2\f[R] plus \f[B]2\f[R], or \f[B]8\f[R].
|
||||
.PP
|
||||
There is one exception to clamping: single-character numbers (i.e.,
|
||||
There is one exception to clamping: single\-character numbers (i.e.,
|
||||
\f[B]A\f[R] alone).
|
||||
Such numbers are never clamped and always take the value they would have
|
||||
in the highest possible \f[B]ibase\f[R].
|
||||
|
@ -403,12 +403,12 @@ Pops a value off the stack.
|
|||
.PP
|
||||
If the value is a number, it is truncated and the absolute value of the
|
||||
result is printed as though \f[B]obase\f[R] is \f[B]256\f[R] and each
|
||||
digit is interpreted as an 8-bit ASCII character, making it a byte
|
||||
digit is interpreted as an 8\-bit ASCII character, making it a byte
|
||||
stream.
|
||||
.PP
|
||||
If the value is a string, it is printed without a trailing newline.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]f\f[R]
|
||||
|
@ -427,7 +427,7 @@ pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to the max \f[I]scale\f[R] of
|
||||
both operands.
|
||||
.TP
|
||||
\f[B]-\f[R]
|
||||
\f[B]\-\f[R]
|
||||
The top two values are popped off the stack, subtracted, and the result
|
||||
is pushed onto the stack.
|
||||
The \f[I]scale\f[R] of the result is equal to the max \f[I]scale\f[R] of
|
||||
|
@ -448,7 +448,7 @@ pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
||||
.RS
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]%\f[R]
|
||||
|
@ -458,10 +458,10 @@ is pushed onto the stack.
|
|||
.PP
|
||||
Remaindering is equivalent to 1) Computing \f[B]a/b\f[R] to current
|
||||
\f[B]scale\f[R], and 2) Using the result of step 1 to calculate
|
||||
\f[B]a-(a/b)*b\f[R] to \f[I]scale\f[R]
|
||||
\f[B]a\-(a/b)*b\f[R] to \f[I]scale\f[R]
|
||||
\f[B]max(scale+scale(b),scale(a))\f[R].
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]\[ti]\f[R]
|
||||
|
@ -472,9 +472,9 @@ This is equivalent to \f[B]x y / x y %\f[R] except that \f[B]x\f[R] and
|
|||
\f[B]y\f[R] are only evaluated once.
|
||||
.RS
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]\[ha]\f[R]
|
||||
|
@ -485,7 +485,7 @@ The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
|||
.PP
|
||||
The first value popped off of the stack must be an integer, and if that
|
||||
value is negative, the second value popped off of the stack must be
|
||||
non-zero.
|
||||
non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]v\f[R]
|
||||
|
@ -494,7 +494,7 @@ the result is pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
||||
.RS
|
||||
.PP
|
||||
The value popped off of the stack must be non-negative.
|
||||
The value popped off of the stack must be non\-negative.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]_\f[R]
|
||||
|
@ -504,7 +504,7 @@ or other commands), then that number is input as a negative number.
|
|||
.PP
|
||||
Otherwise, the top value on the stack is popped and copied, and the copy
|
||||
is negated and pushed onto the stack.
|
||||
This behavior without a number is a \f[B]non-portable extension\f[R].
|
||||
This behavior without a number is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]b\f[R]
|
||||
|
@ -513,7 +513,7 @@ back onto the stack.
|
|||
Otherwise, its absolute value is pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]|\f[R]
|
||||
|
@ -522,12 +522,12 @@ is computed, and the result is pushed onto the stack.
|
|||
.RS
|
||||
.PP
|
||||
The first value popped is used as the reduction modulus and must be an
|
||||
integer and non-zero.
|
||||
integer and non\-zero.
|
||||
The second value popped is used as the exponent and must be an integer
|
||||
and non-negative.
|
||||
and non\-negative.
|
||||
The third value popped is the base and must be an integer.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]G\f[R]
|
||||
|
@ -535,7 +535,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]1\f[R] is pushed if they are equal, or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]N\f[R]
|
||||
|
@ -543,7 +543,7 @@ The top value is popped off of the stack, and if it a \f[B]0\f[R], a
|
|||
\f[B]1\f[R] is pushed; otherwise, a \f[B]0\f[R] is pushed.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B](\f[R]
|
||||
|
@ -552,7 +552,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]{\f[R]
|
||||
|
@ -561,7 +561,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B])\f[R]
|
||||
|
@ -570,7 +570,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]}\f[R]
|
||||
|
@ -579,33 +579,33 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
second, or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]M\f[R]
|
||||
The top two values are popped off of the stack.
|
||||
If they are both non-zero, a \f[B]1\f[R] is pushed onto the stack.
|
||||
If they are both non\-zero, a \f[B]1\f[R] is pushed onto the stack.
|
||||
If either of them is zero, or both of them are, then a \f[B]0\f[R] is
|
||||
pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is like the \f[B]&&\f[R] operator in bc(1), and it is \f[I]not\f[R]
|
||||
a short-circuit operator.
|
||||
a short\-circuit operator.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]m\f[R]
|
||||
The top two values are popped off of the stack.
|
||||
If at least one of them is non-zero, a \f[B]1\f[R] is pushed onto the
|
||||
If at least one of them is non\-zero, a \f[B]1\f[R] is pushed onto the
|
||||
stack.
|
||||
If both of them are zero, then a \f[B]0\f[R] is pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is like the \f[B]||\f[R] operator in bc(1), and it is \f[I]not\f[R]
|
||||
a short-circuit operator.
|
||||
a short\-circuit operator.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Stack Control
|
||||
These commands control the stack.
|
||||
|
@ -670,7 +670,7 @@ If the value on top of the stack has any \f[I]scale\f[R], the
|
|||
.TP
|
||||
\f[B]k\f[R]
|
||||
Pops the value off of the top of the stack and uses it to set
|
||||
\f[B]scale\f[R], which must be non-negative.
|
||||
\f[B]scale\f[R], which must be non\-negative.
|
||||
.RS
|
||||
.PP
|
||||
If the value on top of the stack has any \f[I]scale\f[R], the
|
||||
|
@ -691,7 +691,7 @@ Pushes the maximum allowable value of \f[B]ibase\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]U\f[R]
|
||||
|
@ -699,7 +699,7 @@ Pushes the maximum allowable value of \f[B]obase\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]V\f[R]
|
||||
|
@ -707,7 +707,7 @@ Pushes the maximum allowable value of \f[B]scale\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Strings
|
||||
The following commands control strings.
|
||||
|
@ -747,16 +747,16 @@ The value on top of the stack is popped.
|
|||
If it is a number, it is truncated and its absolute value is taken.
|
||||
The result mod \f[B]256\f[R] is calculated.
|
||||
If that result is \f[B]0\f[R], push an empty string; otherwise, push a
|
||||
one-character string where the character is the result of the mod
|
||||
one\-character string where the character is the result of the mod
|
||||
interpreted as an ASCII character.
|
||||
.PP
|
||||
If it is a string, then a new string is made.
|
||||
If the original string is empty, the new string is empty.
|
||||
If it is not, then the first character of the original string is used to
|
||||
create the new string as a one-character string.
|
||||
create the new string as a one\-character string.
|
||||
The new string is then pushed onto the stack.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]x\f[R]
|
||||
|
@ -792,7 +792,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!>\f[R]\f[I]r\f[R]
|
||||
|
@ -813,7 +813,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]<\f[R]\f[I]r\f[R]
|
||||
|
@ -834,7 +834,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!<\f[R]\f[I]r\f[R]
|
||||
|
@ -855,7 +855,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]=\f[R]\f[I]r\f[R]
|
||||
|
@ -876,7 +876,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!=\f[R]\f[I]r\f[R]
|
||||
|
@ -897,7 +897,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]?\f[R]
|
||||
|
@ -910,7 +910,7 @@ the execution of the macro that executed it.
|
|||
If there are no macros, or only one macro executing, dc(1) exits.
|
||||
.TP
|
||||
\f[B]Q\f[R]
|
||||
Pops a value from the stack which must be non-negative and is used the
|
||||
Pops a value from the stack which must be non\-negative and is used the
|
||||
number of macro executions to pop off of the execution stack.
|
||||
If the number of levels to pop is greater than the number of executing
|
||||
macros, dc(1) exits.
|
||||
|
@ -923,7 +923,7 @@ to make dc(1) exit with the \f[B]Q\f[R] command, so the sequence
|
|||
\f[B],Q\f[R] will make dc(1) exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Status
|
||||
These commands query status of the stack or its top value.
|
||||
|
@ -956,7 +956,7 @@ If the value is a number, this pushes \f[B]1\f[R] onto the stack.
|
|||
Otherwise (if it is a string), it pushes \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]t\f[R]
|
||||
|
@ -965,7 +965,7 @@ If the value is a string, this pushes \f[B]1\f[R] onto the stack.
|
|||
Otherwise (if it is a number), it pushes \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]z\f[R]
|
||||
|
@ -983,7 +983,7 @@ register\[cq]s stack must always have at least one item; dc(1) will give
|
|||
an error and reset otherwise (see the \f[B]RESET\f[R] section).
|
||||
This means that this command will never push \f[B]0\f[R].
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Arrays
|
||||
These commands manipulate arrays.
|
||||
|
@ -1002,7 +1002,7 @@ The selected value is then pushed onto the stack.
|
|||
Pushes the length of the array \f[I]r\f[R] onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Global Settings
|
||||
These commands retrieve global settings.
|
||||
|
@ -1024,8 +1024,8 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
|||
.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
|
||||
(see the \f[B]OPTIONS\f[R] section), non-zero otherwise.
|
||||
been enabled with the \f[B]\-z\f[R] or \f[B]\-\-leading\-zeroes\f[R]
|
||||
options (see the \f[B]OPTIONS\f[R] section), non\-zero otherwise.
|
||||
.SH REGISTERS
|
||||
Registers are names that can store strings, numbers, and arrays.
|
||||
(Number/string registers do not interfere with array registers.)
|
||||
|
@ -1036,7 +1036,7 @@ All registers, when first referenced, have one value (\f[B]0\f[R]) in
|
|||
their stack, and it is a runtime error to attempt to pop that item off
|
||||
of the register stack.
|
||||
.PP
|
||||
In non-extended register mode, a register name is just the single
|
||||
In non\-extended register mode, a register name is just the single
|
||||
character that follows any command that needs a register name.
|
||||
The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
|
||||
bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
|
||||
|
@ -1045,18 +1045,18 @@ bracket to be used as a register name.
|
|||
Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
If extended register mode is enabled (\f[B]\-x\f[R] or
|
||||
\f[B]\-\-extended\-register\f[R] command\-line arguments are given),
|
||||
then normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
(\f[B]`\[rs]n'\f[R]).
|
||||
.PP
|
||||
In that case, the register name is found according to the regex
|
||||
\f[B][a-z][a-z0-9_]*\f[R] (like bc(1) identifiers), and it is a parse
|
||||
error if the next non-space characters do not match that regex.
|
||||
\f[B][a\-z][a\-z0\-9_]*\f[R] (like bc(1) identifiers), and it is a parse
|
||||
error if the next non\-space characters do not match that regex.
|
||||
.SH RESET
|
||||
When dc(1) encounters an error or a signal that it has a non-default
|
||||
When dc(1) encounters an error or a signal that it has a non\-default
|
||||
handler for, it resets.
|
||||
This means that several things happen.
|
||||
.PP
|
||||
|
@ -1120,24 +1120,24 @@ Set at \f[B]DC_BASE_POW\f[R].
|
|||
.TP
|
||||
\f[B]DC_DIM_MAX\f[R]
|
||||
The maximum size of arrays.
|
||||
Set at \f[B]SIZE_MAX-1\f[R].
|
||||
Set at \f[B]SIZE_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_SCALE_MAX\f[R]
|
||||
The maximum \f[B]scale\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_STRING_MAX\f[R]
|
||||
The maximum length of strings.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_NAME_MAX\f[R]
|
||||
The maximum length of identifiers.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_NUM_MAX\f[R]
|
||||
The maximum length of a number (in decimal digits), which includes
|
||||
digits after the decimal point.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
Exponent
|
||||
The maximum allowable exponent (positive or negative).
|
||||
|
@ -1145,27 +1145,27 @@ Set at \f[B]DC_OVERFLOW_MAX\f[R].
|
|||
.TP
|
||||
Number of vars
|
||||
The maximum number of vars/arrays.
|
||||
Set at \f[B]SIZE_MAX-1\f[R].
|
||||
Set at \f[B]SIZE_MAX\-1\f[R].
|
||||
.PP
|
||||
These limits are meant to be effectively non-existent; the limits are so
|
||||
large (at least on 64-bit machines) that there should not be any point
|
||||
at which they become a problem.
|
||||
These limits are meant to be effectively non\-existent; the limits are
|
||||
so large (at least on 64\-bit machines) that there should not be any
|
||||
point at which they become a problem.
|
||||
In fact, memory should be exhausted before these limits should be hit.
|
||||
.SH ENVIRONMENT VARIABLES
|
||||
As \f[B]non-portable extensions\f[R], dc(1) recognizes the following
|
||||
As \f[B]non\-portable extensions\f[R], dc(1) recognizes the following
|
||||
environment variables:
|
||||
.TP
|
||||
\f[B]DC_ENV_ARGS\f[R]
|
||||
This is another way to give command-line arguments to dc(1).
|
||||
They should be in the same format as all other command-line arguments.
|
||||
This is another way to give command\-line arguments to dc(1).
|
||||
They should be in the same format as all other command\-line arguments.
|
||||
These are always processed first, so any files given in
|
||||
\f[B]DC_ENV_ARGS\f[R] will be processed before arguments and files given
|
||||
on the command-line.
|
||||
on the command\-line.
|
||||
This gives the user the ability to set up \[lq]standard\[rq] options and
|
||||
files to be used at every invocation.
|
||||
The most useful thing for such files to contain would be useful
|
||||
functions that the user might want every time dc(1) runs.
|
||||
Another use would be to use the \f[B]-e\f[R] option to set
|
||||
Another use would be to use the \f[B]\-e\f[R] option to set
|
||||
\f[B]scale\f[R] to a value other than \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
|
@ -1183,14 +1183,14 @@ you can use double quotes as the outside quotes, as in \f[B]\[lq]some
|
|||
quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
parsing, though such files are still supported on the command-line where
|
||||
the parsing is done by the shell.
|
||||
parsing, though such files are still supported on the command\-line
|
||||
where the parsing is done by the shell.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_LINE_LENGTH\f[R]
|
||||
If this environment variable exists and contains an integer that is
|
||||
greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
|
||||
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
|
||||
(\f[B]2\[ha]16\-1\f[R]), dc(1) will output lines to that length,
|
||||
including the backslash newline combo.
|
||||
The default line length is \f[B]70\f[R].
|
||||
.RS
|
||||
|
@ -1207,13 +1207,13 @@ exits on \f[B]SIGINT\f[R] when not in interactive mode.
|
|||
.RS
|
||||
.PP
|
||||
However, when dc(1) is in interactive mode, then if this environment
|
||||
variable exists and contains an integer, a non-zero value makes dc(1)
|
||||
variable exists and contains an integer, a non\-zero value makes dc(1)
|
||||
reset on \f[B]SIGINT\f[R], rather than exit, and zero makes dc(1) exit.
|
||||
If this environment variable exists and is \f[I]not\f[R] an integer,
|
||||
then dc(1) will exit on \f[B]SIGINT\f[R].
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_TTY_MODE\f[R]
|
||||
|
@ -1222,11 +1222,11 @@ section), then this environment variable has no effect.
|
|||
.RS
|
||||
.PP
|
||||
However, when TTY mode is available, then if this environment variable
|
||||
exists and contains an integer, then a non-zero value makes dc(1) use
|
||||
exists and contains an integer, then a non\-zero value makes dc(1) use
|
||||
TTY mode, and zero makes dc(1) not use TTY mode.
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_PROMPT\f[R]
|
||||
|
@ -1235,43 +1235,44 @@ section), then this environment variable has no effect.
|
|||
.RS
|
||||
.PP
|
||||
However, when TTY mode is available, then if this environment variable
|
||||
exists and contains an integer, a non-zero value makes dc(1) use a
|
||||
prompt, and zero or a non-integer makes dc(1) not use a prompt.
|
||||
exists and contains an integer, a non\-zero value makes dc(1) use a
|
||||
prompt, and zero or a non\-integer makes dc(1) not use a prompt.
|
||||
If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
|
||||
does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
|
||||
is used.
|
||||
.PP
|
||||
This environment variable and the \f[B]DC_TTY_MODE\f[R] environment
|
||||
variable override the default, which can be queried with the
|
||||
\f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
\f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_EXPR_EXIT\f[R]
|
||||
If any expressions or expression files are given on the command-line
|
||||
with \f[B]-e\f[R], \f[B]--expression\f[R], \f[B]-f\f[R], or
|
||||
\f[B]--file\f[R], then if this environment variable exists and contains
|
||||
an integer, a non-zero value makes dc(1) exit after executing the
|
||||
expressions and expression files, and a zero value makes dc(1) not exit.
|
||||
If any expressions or expression files are given on the command\-line
|
||||
with \f[B]\-e\f[R], \f[B]\-\-expression\f[R], \f[B]\-f\f[R], or
|
||||
\f[B]\-\-file\f[R], then if this environment variable exists and
|
||||
contains an integer, a non\-zero value makes dc(1) exit after executing
|
||||
the expressions and expression files, and a zero value makes dc(1) not
|
||||
exit.
|
||||
.RS
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_DIGIT_CLAMP\f[R]
|
||||
When parsing numbers and if this environment variable exists and
|
||||
contains an integer, a non-zero value makes dc(1) clamp digits that are
|
||||
contains an integer, a non\-zero value makes dc(1) clamp digits that are
|
||||
greater than or equal to the current \f[B]ibase\f[R] so that all such
|
||||
digits are considered equal to the \f[B]ibase\f[R] minus 1, and a zero
|
||||
value disables such clamping so that those digits are always equal to
|
||||
their value, which is multiplied by the power of the \f[B]ibase\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This never applies to single-digit numbers, as per the bc(1) standard
|
||||
This never applies to single\-digit numbers, as per the bc(1) standard
|
||||
(see the \f[B]STANDARDS\f[R] section).
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.SH EXIT STATUS
|
||||
dc(1) returns the following exit statuses:
|
||||
|
@ -1289,7 +1290,7 @@ Math errors include divide by \f[B]0\f[R], taking the square root of a
|
|||
negative number, attempting to convert a negative number to a hardware
|
||||
integer, overflow when converting a number to a hardware integer,
|
||||
overflow when calculating the size of a number, and attempting to use a
|
||||
non-integer where an integer is required.
|
||||
non\-integer where an integer is required.
|
||||
.PP
|
||||
Converting to a hardware integer happens for the second operand of the
|
||||
power (\f[B]\[ha]\f[R]) operator.
|
||||
|
@ -1323,7 +1324,7 @@ A fatal error occurred.
|
|||
Fatal errors include memory allocation errors, I/O errors, failing to
|
||||
open files, attempting to use files that do not have only ASCII
|
||||
characters (dc(1) only accepts ASCII characters), attempting to open a
|
||||
directory as a file, and giving invalid command-line options.
|
||||
directory as a file, and giving invalid command\-line options.
|
||||
.RE
|
||||
.PP
|
||||
The exit status \f[B]4\f[R] is special; when a fatal error occurs, dc(1)
|
||||
|
@ -1334,16 +1335,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
|||
dc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
\f[B]\-i\f[R] flag or \f[B]\-\-interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow dc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
\f[B]\-i\f[R] flag or \f[B]\-\-interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
Like bc(1), dc(1) has an interactive mode and a non-interactive mode.
|
||||
Like bc(1), dc(1) has an interactive mode and a non\-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]--interactive\f[R] option can turn it on in other situations.
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]\-i\f[R]
|
||||
flag and \f[B]\-\-interactive\f[R] option can turn it on in other
|
||||
situations.
|
||||
.PP
|
||||
In interactive mode, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
@ -1359,16 +1361,16 @@ settings.
|
|||
.PP
|
||||
If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
|
||||
environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
|
||||
that environment variable contains a non-zero integer, dc(1) will turn
|
||||
that environment variable contains a non\-zero integer, dc(1) will turn
|
||||
on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R]
|
||||
are all connected to a TTY.
|
||||
If the \f[B]DC_TTY_MODE\f[R] environment variable exists but is
|
||||
\f[I]not\f[R] a non-zero integer, then dc(1) will not turn TTY mode on.
|
||||
\f[I]not\f[R] a non\-zero integer, then dc(1) will not turn TTY mode on.
|
||||
.PP
|
||||
If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
|
||||
exist, the default setting is used.
|
||||
The default setting can be queried with the \f[B]-h\f[R] or
|
||||
\f[B]--help\f[R] options.
|
||||
The default setting can be queried with the \f[B]\-h\f[R] or
|
||||
\f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
TTY mode is different from interactive mode because interactive mode is
|
||||
required in the bc(1) specification (see the \f[B]STANDARDS\f[R]
|
||||
|
@ -1380,18 +1382,18 @@ Like TTY mode itself, it can be turned on or off with an environment
|
|||
variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
|
||||
section).
|
||||
.PP
|
||||
If the environment variable \f[B]DC_PROMPT\f[R] exists and is a non-zero
|
||||
integer, then the prompt is turned on when \f[B]stdin\f[R],
|
||||
If the environment variable \f[B]DC_PROMPT\f[R] exists and is a
|
||||
non\-zero integer, then the prompt is turned on when \f[B]stdin\f[R],
|
||||
\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
|
||||
\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
|
||||
\f[B]\-P\f[R] and \f[B]\-\-no\-prompt\f[R] options were not used.
|
||||
The read prompt will be turned on under the same conditions, except that
|
||||
the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
|
||||
used.
|
||||
the \f[B]\-R\f[R] and \f[B]\-\-no\-read\-prompt\f[R] options must also
|
||||
not be used.
|
||||
.PP
|
||||
However, if \f[B]DC_PROMPT\f[R] does not exist, the prompt can be
|
||||
enabled or disabled with the \f[B]DC_TTY_MODE\f[R] environment variable,
|
||||
the \f[B]-P\f[R] and \f[B]--no-prompt\f[R] options, and the \f[B]-R\f[R]
|
||||
and \f[B]--no-read-prompt\f[R] options.
|
||||
the \f[B]\-P\f[R] and \f[B]\-\-no\-prompt\f[R] options, and the
|
||||
\f[B]\-R\f[R] and \f[B]\-\-no\-read\-prompt\f[R] options.
|
||||
See the \f[B]ENVIRONMENT VARIABLES\f[R] and \f[B]OPTIONS\f[R] sections
|
||||
for more details.
|
||||
.SH SIGNAL HANDLING
|
||||
|
@ -1403,7 +1405,7 @@ section), or the \f[B]DC_SIGINT_RESET\f[R] environment variable (see the
|
|||
an integer or it is zero, dc(1) will exit.
|
||||
.PP
|
||||
However, if dc(1) is in interactive mode, and the
|
||||
\f[B]DC_SIGINT_RESET\f[R] or its default is an integer and non-zero,
|
||||
\f[B]DC_SIGINT_RESET\f[R] or its default is an integer and non\-zero,
|
||||
then dc(1) will stop executing the current input and reset (see the
|
||||
\f[B]RESET\f[R] section) upon receiving a \f[B]SIGINT\f[R].
|
||||
.PP
|
||||
|
@ -1432,7 +1434,7 @@ locales and thus, supports \f[B]LC_MESSAGES\f[R].
|
|||
bc(1)
|
||||
.SH STANDARDS
|
||||
The dc(1) utility operators and some behavior are compliant with the
|
||||
operators in the IEEE Std 1003.1-2017 (\[lq]POSIX.1-2017\[rq]) bc(1)
|
||||
operators in the IEEE Std 1003.1\-2017 (\[lq]POSIX.1\-2017\[rq]) bc(1)
|
||||
specification at
|
||||
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html .
|
||||
.SH BUGS
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2024 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:
|
||||
|
@ -25,41 +25,41 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
|
||||
.nh
|
||||
.ad l
|
||||
.SH Name
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
dc \- arbitrary\-precision decimal reverse\-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
\f[B]dc\f[R] [\f[B]-cChiPRvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--digit-clamp\f[R]]
|
||||
[\f[B]--no-digit-clamp\f[R]] [\f[B]--interactive\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--no-read-prompt\f[R]]
|
||||
[\f[B]--extended-register\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...]
|
||||
[\f[B]-f\f[R] \f[I]file\f[R]\&...]
|
||||
[\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]dc\f[R] [\f[B]\-cChiPRvVx\f[R]] [\f[B]\-\-version\f[R]]
|
||||
[\f[B]\-\-help\f[R]] [\f[B]\-\-digit\-clamp\f[R]]
|
||||
[\f[B]\-\-no\-digit\-clamp\f[R]] [\f[B]\-\-interactive\f[R]]
|
||||
[\f[B]\-\-no\-prompt\f[R]] [\f[B]\-\-no\-read\-prompt\f[R]]
|
||||
[\f[B]\-\-extended\-register\f[R]] [\f[B]\-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\-\-expression\f[R]=\f[I]expr\f[R]\&...]
|
||||
[\f[B]\-f\f[R] \f[I]file\f[R]\&...]
|
||||
[\f[B]\-\-file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
dc(1) is an arbitrary-precision calculator.
|
||||
dc(1) is an arbitrary\-precision calculator.
|
||||
It uses a stack (reverse Polish notation) to store numbers and results
|
||||
of computations.
|
||||
Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line, then dc(1) reads from
|
||||
If no files are given on the command\-line, then dc(1) reads from
|
||||
\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
If a user wants to set up a standard environment, they can use
|
||||
\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
For example, if a user wants the \f[B]scale\f[R] always set to
|
||||
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
|
||||
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]\-e 10k\f[R],
|
||||
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
|
||||
.SH OPTIONS
|
||||
The following are the options that dc(1) accepts.
|
||||
.TP
|
||||
\f[B]-C\f[R], \f[B]--no-digit-clamp\f[R]
|
||||
\f[B]\-C\f[R], \f[B]\-\-no\-digit\-clamp\f[R]
|
||||
Disables clamping of digits greater than or equal to the current
|
||||
\f[B]ibase\f[R] when parsing numbers.
|
||||
.RS
|
||||
|
@ -69,17 +69,17 @@ digit\[cq]s value multiplied by the value of ibase raised to the power
|
|||
of the digit\[cq]s position, which starts from 0 at the least
|
||||
significant digit.
|
||||
.PP
|
||||
If this and/or the \f[B]-c\f[R] or \f[B]--digit-clamp\f[R] options are
|
||||
given multiple times, the last one given is used.
|
||||
If this and/or the \f[B]\-c\f[R] or \f[B]\-\-digit\-clamp\f[R] options
|
||||
are given multiple times, the last one given is used.
|
||||
.PP
|
||||
This option overrides the \f[B]DC_DIGIT_CLAMP\f[R] environment variable
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section) and the default, which
|
||||
can be queried with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
can be queried with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-c\f[R], \f[B]--digit-clamp\f[R]
|
||||
\f[B]\-c\f[R], \f[B]\-\-digit\-clamp\f[R]
|
||||
Enables clamping of digits greater than or equal to the current
|
||||
\f[B]ibase\f[R] when parsing numbers.
|
||||
.RS
|
||||
|
@ -90,17 +90,17 @@ all multiplied by the value of ibase raised to the power of the
|
|||
digit\[cq]s position, which starts from 0 at the least significant
|
||||
digit.
|
||||
.PP
|
||||
If this and/or the \f[B]-C\f[R] or \f[B]--no-digit-clamp\f[R] options
|
||||
are given multiple times, the last one given is used.
|
||||
If this and/or the \f[B]\-C\f[R] or \f[B]\-\-no\-digit\-clamp\f[R]
|
||||
options are given multiple times, the last one given is used.
|
||||
.PP
|
||||
This option overrides the \f[B]DC_DIGIT_CLAMP\f[R] environment variable
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section) and the default, which
|
||||
can be queried with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
can be queried with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]\-e\f[R] \f[I]expr\f[R], \f[B]\-\-expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
|
@ -109,44 +109,44 @@ This means that if a file is given before an expression, the file is
|
|||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
If this option is given on the command-line (i.e., not in
|
||||
If this option is given on the command\-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]\-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]\-f\f[R] or \f[B]\-\-file\f[R], whether on the command\-line or in
|
||||
\f[B]DC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, dc(1) will give a fatal error and
|
||||
exit.
|
||||
However, if any other \f[B]\-e\f[R], \f[B]\-\-expression\f[R],
|
||||
\f[B]\-f\f[R], or \f[B]\-\-file\f[R] arguments are given after
|
||||
\f[B]\-f\-\f[R] or equivalent is given, dc(1) will give a fatal error
|
||||
and exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
\f[B]\-f\f[R] \f[I]file\f[R], \f[B]\-\-file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
If this option is given on the command-line (i.e., not in
|
||||
If this option is given on the command\-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, dc(1) will give a fatal error and
|
||||
exit.
|
||||
\f[B]\-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]\-f\f[R] or \f[B]\-\-file\f[R].
|
||||
However, if any other \f[B]\-e\f[R], \f[B]\-\-expression\f[R],
|
||||
\f[B]\-f\f[R], or \f[B]\-\-file\f[R] arguments are given after
|
||||
\f[B]\-f\-\f[R] or equivalent is given, dc(1) will give a fatal error
|
||||
and exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
\f[B]\-h\f[R], \f[B]\-\-help\f[R]
|
||||
Prints a usage message and exits.
|
||||
.TP
|
||||
\f[B]-I\f[R] \f[I]ibase\f[R], \f[B]--ibase\f[R]=\f[I]ibase\f[R]
|
||||
\f[B]\-I\f[R] \f[I]ibase\f[R], \f[B]\-\-ibase\f[R]=\f[I]ibase\f[R]
|
||||
Sets the builtin variable \f[B]ibase\f[R] to the value \f[I]ibase\f[R]
|
||||
assuming that \f[I]ibase\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]ibase\f[R] is not a valid number.
|
||||
|
@ -154,28 +154,28 @@ It is a fatal error if \f[I]ibase\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
\f[B]\-i\f[R], \f[B]\-\-interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-L\f[R], \f[B]--no-line-length\f[R]
|
||||
\f[B]\-L\f[R], \f[B]\-\-no\-line\-length\f[R]
|
||||
Disables line length checking and prints numbers without backslashes and
|
||||
newlines.
|
||||
In other words, this option sets \f[B]BC_LINE_LENGTH\f[R] to \f[B]0\f[R]
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-O\f[R] \f[I]obase\f[R], \f[B]--obase\f[R]=\f[I]obase\f[R]
|
||||
\f[B]\-O\f[R] \f[I]obase\f[R], \f[B]\-\-obase\f[R]=\f[I]obase\f[R]
|
||||
Sets the builtin variable \f[B]obase\f[R] to the value \f[I]obase\f[R]
|
||||
assuming that \f[I]obase\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]obase\f[R] is not a valid number.
|
||||
|
@ -183,10 +183,10 @@ It is a fatal error if \f[I]obase\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
\f[B]\-P\f[R], \f[B]\-\-no\-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section.)
|
||||
|
@ -199,10 +199,10 @@ Most of those users would want to put this option in
|
|||
These options override the \f[B]DC_PROMPT\f[R] and \f[B]DC_TTY_MODE\f[R]
|
||||
environment variables (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
|
||||
\f[B]\-R\f[R], \f[B]\-\-no\-read\-prompt\f[R]
|
||||
Disables the read prompt in TTY mode.
|
||||
(The read prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section.)
|
||||
|
@ -221,10 +221,10 @@ These options \f[I]do\f[R] override the \f[B]DC_PROMPT\f[R] and
|
|||
\f[B]DC_TTY_MODE\f[R] environment variables (see the \f[B]ENVIRONMENT
|
||||
VARIABLES\f[R] section), but only for the read prompt.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-S\f[R] \f[I]scale\f[R], \f[B]--scale\f[R]=\f[I]scale\f[R]
|
||||
\f[B]\-S\f[R] \f[I]scale\f[R], \f[B]\-\-scale\f[R]=\f[I]scale\f[R]
|
||||
Sets the builtin variable \f[B]scale\f[R] to the value \f[I]scale\f[R]
|
||||
assuming that \f[I]scale\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]scale\f[R] is not a valid number.
|
||||
|
@ -232,34 +232,34 @@ It is a fatal error if \f[I]scale\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
\f[B]\-v\f[R], \f[B]\-V\f[R], \f[B]\-\-version\f[R]
|
||||
Print the version information (copyright header) and exits.
|
||||
.TP
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
\f[B]\-x\f[R] \f[B]\-\-extended\-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-z\f[R], \f[B]--leading-zeroes\f[R]
|
||||
Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than
|
||||
\f[B]\-z\f[R], \f[B]\-\-leading\-zeroes\f[R]
|
||||
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 is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.PP
|
||||
All long options are \f[B]non-portable extensions\f[R].
|
||||
All long options are \f[B]non\-portable extensions\f[R].
|
||||
.SH STDIN
|
||||
If no files are given on the command-line and no files or expressions
|
||||
are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
|
||||
\f[B]--expression\f[R] options, then dc(1) reads from \f[B]stdin\f[R].
|
||||
If no files are given on the command\-line and no files or expressions
|
||||
are given by the \f[B]\-f\f[R], \f[B]\-\-file\f[R], \f[B]\-e\f[R], or
|
||||
\f[B]\-\-expression\f[R] options, then dc(1) reads from \f[B]stdin\f[R].
|
||||
.PP
|
||||
However, there is a caveat to this.
|
||||
.PP
|
||||
|
@ -269,7 +269,7 @@ ended.
|
|||
This means that, except for escaped brackets, all brackets must be
|
||||
balanced before dc(1) parses and executes.
|
||||
.SH STDOUT
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
Any non\-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
|
@ -277,7 +277,7 @@ to \f[B]stdout\f[R].
|
|||
\f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
write to \f[B]stdout\f[R], so if \f[B]stdout\f[R] is closed, as in
|
||||
\f[B]dc >&-\f[R], it will quit with an error.
|
||||
\f[B]dc >&\-\f[R], it will quit with an error.
|
||||
This is done so that dc(1) can report problems when \f[B]stdout\f[R] is
|
||||
redirected to a file.
|
||||
.PP
|
||||
|
@ -290,7 +290,7 @@ Any error output is written to \f[B]stderr\f[R].
|
|||
\f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
write to \f[B]stderr\f[R], so if \f[B]stderr\f[R] is closed, as in
|
||||
\f[B]dc 2>&-\f[R], it will quit with an error.
|
||||
\f[B]dc 2>&\-\f[R], it will quit with an error.
|
||||
This is done so that dc(1) can exit with an error code when
|
||||
\f[B]stderr\f[R] is redirected to a file.
|
||||
.PP
|
||||
|
@ -333,7 +333,7 @@ The max allowable value for \f[B]scale\f[R] can be queried in dc(1)
|
|||
programs with the \f[B]V\f[R] command.
|
||||
.SS Comments
|
||||
Comments go from \f[B]#\f[R] until, and not including, the next newline.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.SH NUMBERS
|
||||
Numbers are strings made up of digits, uppercase letters up to
|
||||
\f[B]F\f[R], and at most \f[B]1\f[R] period for a radix.
|
||||
|
@ -344,12 +344,12 @@ alphabet (i.e., \f[B]A\f[R] equals \f[B]10\f[R], or \f[B]9+1\f[R]).
|
|||
If a digit or letter makes no sense with the current value of
|
||||
\f[B]ibase\f[R] (i.e., they are greater than or equal to the current
|
||||
value of \f[B]ibase\f[R]), then the behavior depends on the existence of
|
||||
the \f[B]-c\f[R]/\f[B]--digit-clamp\f[R] or
|
||||
\f[B]-C\f[R]/\f[B]--no-digit-clamp\f[R] options (see the
|
||||
the \f[B]\-c\f[R]/\f[B]\-\-digit\-clamp\f[R] or
|
||||
\f[B]\-C\f[R]/\f[B]\-\-no\-digit\-clamp\f[R] options (see the
|
||||
\f[B]OPTIONS\f[R] section), the existence and setting of the
|
||||
\f[B]DC_DIGIT_CLAMP\f[R] environment variable (see the \f[B]ENVIRONMENT
|
||||
VARIABLES\f[R] section), or the default, which can be queried with the
|
||||
\f[B]-h\f[R]/\f[B]--help\f[R] option.
|
||||
\f[B]\-h\f[R]/\f[B]\-\-help\f[R] option.
|
||||
.PP
|
||||
If clamping is off, then digits or letters that are greater than or
|
||||
equal to the current value of \f[B]ibase\f[R] are not changed.
|
||||
|
@ -367,7 +367,7 @@ This means that, with an \f[B]ibase\f[R] of \f[B]3\f[R], the number
|
|||
\f[B]AB\f[R] is equal to \f[B]3\[ha]1*2+3\[ha]0*2\f[R], which is
|
||||
\f[B]3\f[R] times \f[B]2\f[R] plus \f[B]2\f[R], or \f[B]8\f[R].
|
||||
.PP
|
||||
There is one exception to clamping: single-character numbers (i.e.,
|
||||
There is one exception to clamping: single\-character numbers (i.e.,
|
||||
\f[B]A\f[R] alone).
|
||||
Such numbers are never clamped and always take the value they would have
|
||||
in the highest possible \f[B]ibase\f[R].
|
||||
|
@ -403,12 +403,12 @@ Pops a value off the stack.
|
|||
.PP
|
||||
If the value is a number, it is truncated and the absolute value of the
|
||||
result is printed as though \f[B]obase\f[R] is \f[B]256\f[R] and each
|
||||
digit is interpreted as an 8-bit ASCII character, making it a byte
|
||||
digit is interpreted as an 8\-bit ASCII character, making it a byte
|
||||
stream.
|
||||
.PP
|
||||
If the value is a string, it is printed without a trailing newline.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]f\f[R]
|
||||
|
@ -427,7 +427,7 @@ pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to the max \f[I]scale\f[R] of
|
||||
both operands.
|
||||
.TP
|
||||
\f[B]-\f[R]
|
||||
\f[B]\-\f[R]
|
||||
The top two values are popped off the stack, subtracted, and the result
|
||||
is pushed onto the stack.
|
||||
The \f[I]scale\f[R] of the result is equal to the max \f[I]scale\f[R] of
|
||||
|
@ -448,7 +448,7 @@ pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
||||
.RS
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]%\f[R]
|
||||
|
@ -458,10 +458,10 @@ is pushed onto the stack.
|
|||
.PP
|
||||
Remaindering is equivalent to 1) Computing \f[B]a/b\f[R] to current
|
||||
\f[B]scale\f[R], and 2) Using the result of step 1 to calculate
|
||||
\f[B]a-(a/b)*b\f[R] to \f[I]scale\f[R]
|
||||
\f[B]a\-(a/b)*b\f[R] to \f[I]scale\f[R]
|
||||
\f[B]max(scale+scale(b),scale(a))\f[R].
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]\[ti]\f[R]
|
||||
|
@ -472,9 +472,9 @@ This is equivalent to \f[B]x y / x y %\f[R] except that \f[B]x\f[R] and
|
|||
\f[B]y\f[R] are only evaluated once.
|
||||
.RS
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]\[ha]\f[R]
|
||||
|
@ -485,7 +485,7 @@ The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
|||
.PP
|
||||
The first value popped off of the stack must be an integer, and if that
|
||||
value is negative, the second value popped off of the stack must be
|
||||
non-zero.
|
||||
non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]v\f[R]
|
||||
|
@ -494,7 +494,7 @@ the result is pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
||||
.RS
|
||||
.PP
|
||||
The value popped off of the stack must be non-negative.
|
||||
The value popped off of the stack must be non\-negative.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]_\f[R]
|
||||
|
@ -504,7 +504,7 @@ or other commands), then that number is input as a negative number.
|
|||
.PP
|
||||
Otherwise, the top value on the stack is popped and copied, and the copy
|
||||
is negated and pushed onto the stack.
|
||||
This behavior without a number is a \f[B]non-portable extension\f[R].
|
||||
This behavior without a number is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]b\f[R]
|
||||
|
@ -513,7 +513,7 @@ back onto the stack.
|
|||
Otherwise, its absolute value is pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]|\f[R]
|
||||
|
@ -522,12 +522,12 @@ is computed, and the result is pushed onto the stack.
|
|||
.RS
|
||||
.PP
|
||||
The first value popped is used as the reduction modulus and must be an
|
||||
integer and non-zero.
|
||||
integer and non\-zero.
|
||||
The second value popped is used as the exponent and must be an integer
|
||||
and non-negative.
|
||||
and non\-negative.
|
||||
The third value popped is the base and must be an integer.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]G\f[R]
|
||||
|
@ -535,7 +535,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]1\f[R] is pushed if they are equal, or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]N\f[R]
|
||||
|
@ -543,7 +543,7 @@ The top value is popped off of the stack, and if it a \f[B]0\f[R], a
|
|||
\f[B]1\f[R] is pushed; otherwise, a \f[B]0\f[R] is pushed.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B](\f[R]
|
||||
|
@ -552,7 +552,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]{\f[R]
|
||||
|
@ -561,7 +561,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B])\f[R]
|
||||
|
@ -570,7 +570,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]}\f[R]
|
||||
|
@ -579,33 +579,33 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
second, or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]M\f[R]
|
||||
The top two values are popped off of the stack.
|
||||
If they are both non-zero, a \f[B]1\f[R] is pushed onto the stack.
|
||||
If they are both non\-zero, a \f[B]1\f[R] is pushed onto the stack.
|
||||
If either of them is zero, or both of them are, then a \f[B]0\f[R] is
|
||||
pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is like the \f[B]&&\f[R] operator in bc(1), and it is \f[I]not\f[R]
|
||||
a short-circuit operator.
|
||||
a short\-circuit operator.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]m\f[R]
|
||||
The top two values are popped off of the stack.
|
||||
If at least one of them is non-zero, a \f[B]1\f[R] is pushed onto the
|
||||
If at least one of them is non\-zero, a \f[B]1\f[R] is pushed onto the
|
||||
stack.
|
||||
If both of them are zero, then a \f[B]0\f[R] is pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is like the \f[B]||\f[R] operator in bc(1), and it is \f[I]not\f[R]
|
||||
a short-circuit operator.
|
||||
a short\-circuit operator.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Stack Control
|
||||
These commands control the stack.
|
||||
|
@ -670,7 +670,7 @@ If the value on top of the stack has any \f[I]scale\f[R], the
|
|||
.TP
|
||||
\f[B]k\f[R]
|
||||
Pops the value off of the top of the stack and uses it to set
|
||||
\f[B]scale\f[R], which must be non-negative.
|
||||
\f[B]scale\f[R], which must be non\-negative.
|
||||
.RS
|
||||
.PP
|
||||
If the value on top of the stack has any \f[I]scale\f[R], the
|
||||
|
@ -691,7 +691,7 @@ Pushes the maximum allowable value of \f[B]ibase\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]U\f[R]
|
||||
|
@ -699,7 +699,7 @@ Pushes the maximum allowable value of \f[B]obase\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]V\f[R]
|
||||
|
@ -707,7 +707,7 @@ Pushes the maximum allowable value of \f[B]scale\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Strings
|
||||
The following commands control strings.
|
||||
|
@ -747,16 +747,16 @@ The value on top of the stack is popped.
|
|||
If it is a number, it is truncated and its absolute value is taken.
|
||||
The result mod \f[B]256\f[R] is calculated.
|
||||
If that result is \f[B]0\f[R], push an empty string; otherwise, push a
|
||||
one-character string where the character is the result of the mod
|
||||
one\-character string where the character is the result of the mod
|
||||
interpreted as an ASCII character.
|
||||
.PP
|
||||
If it is a string, then a new string is made.
|
||||
If the original string is empty, the new string is empty.
|
||||
If it is not, then the first character of the original string is used to
|
||||
create the new string as a one-character string.
|
||||
create the new string as a one\-character string.
|
||||
The new string is then pushed onto the stack.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]x\f[R]
|
||||
|
@ -792,7 +792,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!>\f[R]\f[I]r\f[R]
|
||||
|
@ -813,7 +813,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]<\f[R]\f[I]r\f[R]
|
||||
|
@ -834,7 +834,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!<\f[R]\f[I]r\f[R]
|
||||
|
@ -855,7 +855,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]=\f[R]\f[I]r\f[R]
|
||||
|
@ -876,7 +876,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!=\f[R]\f[I]r\f[R]
|
||||
|
@ -897,7 +897,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]?\f[R]
|
||||
|
@ -910,7 +910,7 @@ the execution of the macro that executed it.
|
|||
If there are no macros, or only one macro executing, dc(1) exits.
|
||||
.TP
|
||||
\f[B]Q\f[R]
|
||||
Pops a value from the stack which must be non-negative and is used the
|
||||
Pops a value from the stack which must be non\-negative and is used the
|
||||
number of macro executions to pop off of the execution stack.
|
||||
If the number of levels to pop is greater than the number of executing
|
||||
macros, dc(1) exits.
|
||||
|
@ -923,7 +923,7 @@ to make dc(1) exit with the \f[B]Q\f[R] command, so the sequence
|
|||
\f[B],Q\f[R] will make dc(1) exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Status
|
||||
These commands query status of the stack or its top value.
|
||||
|
@ -956,7 +956,7 @@ If the value is a number, this pushes \f[B]1\f[R] onto the stack.
|
|||
Otherwise (if it is a string), it pushes \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]t\f[R]
|
||||
|
@ -965,7 +965,7 @@ If the value is a string, this pushes \f[B]1\f[R] onto the stack.
|
|||
Otherwise (if it is a number), it pushes \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]z\f[R]
|
||||
|
@ -983,7 +983,7 @@ register\[cq]s stack must always have at least one item; dc(1) will give
|
|||
an error and reset otherwise (see the \f[B]RESET\f[R] section).
|
||||
This means that this command will never push \f[B]0\f[R].
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Arrays
|
||||
These commands manipulate arrays.
|
||||
|
@ -1002,7 +1002,7 @@ The selected value is then pushed onto the stack.
|
|||
Pushes the length of the array \f[I]r\f[R] onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Global Settings
|
||||
These commands retrieve global settings.
|
||||
|
@ -1024,8 +1024,8 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
|||
.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
|
||||
(see the \f[B]OPTIONS\f[R] section), non-zero otherwise.
|
||||
been enabled with the \f[B]\-z\f[R] or \f[B]\-\-leading\-zeroes\f[R]
|
||||
options (see the \f[B]OPTIONS\f[R] section), non\-zero otherwise.
|
||||
.SH REGISTERS
|
||||
Registers are names that can store strings, numbers, and arrays.
|
||||
(Number/string registers do not interfere with array registers.)
|
||||
|
@ -1036,7 +1036,7 @@ All registers, when first referenced, have one value (\f[B]0\f[R]) in
|
|||
their stack, and it is a runtime error to attempt to pop that item off
|
||||
of the register stack.
|
||||
.PP
|
||||
In non-extended register mode, a register name is just the single
|
||||
In non\-extended register mode, a register name is just the single
|
||||
character that follows any command that needs a register name.
|
||||
The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
|
||||
bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
|
||||
|
@ -1045,18 +1045,18 @@ bracket to be used as a register name.
|
|||
Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
If extended register mode is enabled (\f[B]\-x\f[R] or
|
||||
\f[B]\-\-extended\-register\f[R] command\-line arguments are given),
|
||||
then normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
(\f[B]`\[rs]n'\f[R]).
|
||||
.PP
|
||||
In that case, the register name is found according to the regex
|
||||
\f[B][a-z][a-z0-9_]*\f[R] (like bc(1) identifiers), and it is a parse
|
||||
error if the next non-space characters do not match that regex.
|
||||
\f[B][a\-z][a\-z0\-9_]*\f[R] (like bc(1) identifiers), and it is a parse
|
||||
error if the next non\-space characters do not match that regex.
|
||||
.SH RESET
|
||||
When dc(1) encounters an error or a signal that it has a non-default
|
||||
When dc(1) encounters an error or a signal that it has a non\-default
|
||||
handler for, it resets.
|
||||
This means that several things happen.
|
||||
.PP
|
||||
|
@ -1120,24 +1120,24 @@ Set at \f[B]DC_BASE_POW\f[R].
|
|||
.TP
|
||||
\f[B]DC_DIM_MAX\f[R]
|
||||
The maximum size of arrays.
|
||||
Set at \f[B]SIZE_MAX-1\f[R].
|
||||
Set at \f[B]SIZE_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_SCALE_MAX\f[R]
|
||||
The maximum \f[B]scale\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_STRING_MAX\f[R]
|
||||
The maximum length of strings.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_NAME_MAX\f[R]
|
||||
The maximum length of identifiers.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_NUM_MAX\f[R]
|
||||
The maximum length of a number (in decimal digits), which includes
|
||||
digits after the decimal point.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
Exponent
|
||||
The maximum allowable exponent (positive or negative).
|
||||
|
@ -1145,27 +1145,27 @@ Set at \f[B]DC_OVERFLOW_MAX\f[R].
|
|||
.TP
|
||||
Number of vars
|
||||
The maximum number of vars/arrays.
|
||||
Set at \f[B]SIZE_MAX-1\f[R].
|
||||
Set at \f[B]SIZE_MAX\-1\f[R].
|
||||
.PP
|
||||
These limits are meant to be effectively non-existent; the limits are so
|
||||
large (at least on 64-bit machines) that there should not be any point
|
||||
at which they become a problem.
|
||||
These limits are meant to be effectively non\-existent; the limits are
|
||||
so large (at least on 64\-bit machines) that there should not be any
|
||||
point at which they become a problem.
|
||||
In fact, memory should be exhausted before these limits should be hit.
|
||||
.SH ENVIRONMENT VARIABLES
|
||||
As \f[B]non-portable extensions\f[R], dc(1) recognizes the following
|
||||
As \f[B]non\-portable extensions\f[R], dc(1) recognizes the following
|
||||
environment variables:
|
||||
.TP
|
||||
\f[B]DC_ENV_ARGS\f[R]
|
||||
This is another way to give command-line arguments to dc(1).
|
||||
They should be in the same format as all other command-line arguments.
|
||||
This is another way to give command\-line arguments to dc(1).
|
||||
They should be in the same format as all other command\-line arguments.
|
||||
These are always processed first, so any files given in
|
||||
\f[B]DC_ENV_ARGS\f[R] will be processed before arguments and files given
|
||||
on the command-line.
|
||||
on the command\-line.
|
||||
This gives the user the ability to set up \[lq]standard\[rq] options and
|
||||
files to be used at every invocation.
|
||||
The most useful thing for such files to contain would be useful
|
||||
functions that the user might want every time dc(1) runs.
|
||||
Another use would be to use the \f[B]-e\f[R] option to set
|
||||
Another use would be to use the \f[B]\-e\f[R] option to set
|
||||
\f[B]scale\f[R] to a value other than \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
|
@ -1183,14 +1183,14 @@ you can use double quotes as the outside quotes, as in \f[B]\[lq]some
|
|||
quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
parsing, though such files are still supported on the command-line where
|
||||
the parsing is done by the shell.
|
||||
parsing, though such files are still supported on the command\-line
|
||||
where the parsing is done by the shell.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_LINE_LENGTH\f[R]
|
||||
If this environment variable exists and contains an integer that is
|
||||
greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
|
||||
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
|
||||
(\f[B]2\[ha]16\-1\f[R]), dc(1) will output lines to that length,
|
||||
including the backslash newline combo.
|
||||
The default line length is \f[B]70\f[R].
|
||||
.RS
|
||||
|
@ -1207,13 +1207,13 @@ exits on \f[B]SIGINT\f[R] when not in interactive mode.
|
|||
.RS
|
||||
.PP
|
||||
However, when dc(1) is in interactive mode, then if this environment
|
||||
variable exists and contains an integer, a non-zero value makes dc(1)
|
||||
variable exists and contains an integer, a non\-zero value makes dc(1)
|
||||
reset on \f[B]SIGINT\f[R], rather than exit, and zero makes dc(1) exit.
|
||||
If this environment variable exists and is \f[I]not\f[R] an integer,
|
||||
then dc(1) will exit on \f[B]SIGINT\f[R].
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_TTY_MODE\f[R]
|
||||
|
@ -1222,11 +1222,11 @@ section), then this environment variable has no effect.
|
|||
.RS
|
||||
.PP
|
||||
However, when TTY mode is available, then if this environment variable
|
||||
exists and contains an integer, then a non-zero value makes dc(1) use
|
||||
exists and contains an integer, then a non\-zero value makes dc(1) use
|
||||
TTY mode, and zero makes dc(1) not use TTY mode.
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_PROMPT\f[R]
|
||||
|
@ -1235,43 +1235,44 @@ section), then this environment variable has no effect.
|
|||
.RS
|
||||
.PP
|
||||
However, when TTY mode is available, then if this environment variable
|
||||
exists and contains an integer, a non-zero value makes dc(1) use a
|
||||
prompt, and zero or a non-integer makes dc(1) not use a prompt.
|
||||
exists and contains an integer, a non\-zero value makes dc(1) use a
|
||||
prompt, and zero or a non\-integer makes dc(1) not use a prompt.
|
||||
If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
|
||||
does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
|
||||
is used.
|
||||
.PP
|
||||
This environment variable and the \f[B]DC_TTY_MODE\f[R] environment
|
||||
variable override the default, which can be queried with the
|
||||
\f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
\f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_EXPR_EXIT\f[R]
|
||||
If any expressions or expression files are given on the command-line
|
||||
with \f[B]-e\f[R], \f[B]--expression\f[R], \f[B]-f\f[R], or
|
||||
\f[B]--file\f[R], then if this environment variable exists and contains
|
||||
an integer, a non-zero value makes dc(1) exit after executing the
|
||||
expressions and expression files, and a zero value makes dc(1) not exit.
|
||||
If any expressions or expression files are given on the command\-line
|
||||
with \f[B]\-e\f[R], \f[B]\-\-expression\f[R], \f[B]\-f\f[R], or
|
||||
\f[B]\-\-file\f[R], then if this environment variable exists and
|
||||
contains an integer, a non\-zero value makes dc(1) exit after executing
|
||||
the expressions and expression files, and a zero value makes dc(1) not
|
||||
exit.
|
||||
.RS
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_DIGIT_CLAMP\f[R]
|
||||
When parsing numbers and if this environment variable exists and
|
||||
contains an integer, a non-zero value makes dc(1) clamp digits that are
|
||||
contains an integer, a non\-zero value makes dc(1) clamp digits that are
|
||||
greater than or equal to the current \f[B]ibase\f[R] so that all such
|
||||
digits are considered equal to the \f[B]ibase\f[R] minus 1, and a zero
|
||||
value disables such clamping so that those digits are always equal to
|
||||
their value, which is multiplied by the power of the \f[B]ibase\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This never applies to single-digit numbers, as per the bc(1) standard
|
||||
This never applies to single\-digit numbers, as per the bc(1) standard
|
||||
(see the \f[B]STANDARDS\f[R] section).
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.SH EXIT STATUS
|
||||
dc(1) returns the following exit statuses:
|
||||
|
@ -1289,7 +1290,7 @@ Math errors include divide by \f[B]0\f[R], taking the square root of a
|
|||
negative number, attempting to convert a negative number to a hardware
|
||||
integer, overflow when converting a number to a hardware integer,
|
||||
overflow when calculating the size of a number, and attempting to use a
|
||||
non-integer where an integer is required.
|
||||
non\-integer where an integer is required.
|
||||
.PP
|
||||
Converting to a hardware integer happens for the second operand of the
|
||||
power (\f[B]\[ha]\f[R]) operator.
|
||||
|
@ -1323,7 +1324,7 @@ A fatal error occurred.
|
|||
Fatal errors include memory allocation errors, I/O errors, failing to
|
||||
open files, attempting to use files that do not have only ASCII
|
||||
characters (dc(1) only accepts ASCII characters), attempting to open a
|
||||
directory as a file, and giving invalid command-line options.
|
||||
directory as a file, and giving invalid command\-line options.
|
||||
.RE
|
||||
.PP
|
||||
The exit status \f[B]4\f[R] is special; when a fatal error occurs, dc(1)
|
||||
|
@ -1334,16 +1335,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
|||
dc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
\f[B]\-i\f[R] flag or \f[B]\-\-interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow dc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
\f[B]\-i\f[R] flag or \f[B]\-\-interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
Like bc(1), dc(1) has an interactive mode and a non-interactive mode.
|
||||
Like bc(1), dc(1) has an interactive mode and a non\-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]--interactive\f[R] option can turn it on in other situations.
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]\-i\f[R]
|
||||
flag and \f[B]\-\-interactive\f[R] option can turn it on in other
|
||||
situations.
|
||||
.PP
|
||||
In interactive mode, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
@ -1359,16 +1361,16 @@ settings.
|
|||
.PP
|
||||
If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
|
||||
environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
|
||||
that environment variable contains a non-zero integer, dc(1) will turn
|
||||
that environment variable contains a non\-zero integer, dc(1) will turn
|
||||
on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R]
|
||||
are all connected to a TTY.
|
||||
If the \f[B]DC_TTY_MODE\f[R] environment variable exists but is
|
||||
\f[I]not\f[R] a non-zero integer, then dc(1) will not turn TTY mode on.
|
||||
\f[I]not\f[R] a non\-zero integer, then dc(1) will not turn TTY mode on.
|
||||
.PP
|
||||
If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
|
||||
exist, the default setting is used.
|
||||
The default setting can be queried with the \f[B]-h\f[R] or
|
||||
\f[B]--help\f[R] options.
|
||||
The default setting can be queried with the \f[B]\-h\f[R] or
|
||||
\f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
TTY mode is different from interactive mode because interactive mode is
|
||||
required in the bc(1) specification (see the \f[B]STANDARDS\f[R]
|
||||
|
@ -1380,18 +1382,18 @@ Like TTY mode itself, it can be turned on or off with an environment
|
|||
variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
|
||||
section).
|
||||
.PP
|
||||
If the environment variable \f[B]DC_PROMPT\f[R] exists and is a non-zero
|
||||
integer, then the prompt is turned on when \f[B]stdin\f[R],
|
||||
If the environment variable \f[B]DC_PROMPT\f[R] exists and is a
|
||||
non\-zero integer, then the prompt is turned on when \f[B]stdin\f[R],
|
||||
\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
|
||||
\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
|
||||
\f[B]\-P\f[R] and \f[B]\-\-no\-prompt\f[R] options were not used.
|
||||
The read prompt will be turned on under the same conditions, except that
|
||||
the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
|
||||
used.
|
||||
the \f[B]\-R\f[R] and \f[B]\-\-no\-read\-prompt\f[R] options must also
|
||||
not be used.
|
||||
.PP
|
||||
However, if \f[B]DC_PROMPT\f[R] does not exist, the prompt can be
|
||||
enabled or disabled with the \f[B]DC_TTY_MODE\f[R] environment variable,
|
||||
the \f[B]-P\f[R] and \f[B]--no-prompt\f[R] options, and the \f[B]-R\f[R]
|
||||
and \f[B]--no-read-prompt\f[R] options.
|
||||
the \f[B]\-P\f[R] and \f[B]\-\-no\-prompt\f[R] options, and the
|
||||
\f[B]\-R\f[R] and \f[B]\-\-no\-read\-prompt\f[R] options.
|
||||
See the \f[B]ENVIRONMENT VARIABLES\f[R] and \f[B]OPTIONS\f[R] sections
|
||||
for more details.
|
||||
.SH SIGNAL HANDLING
|
||||
|
@ -1403,7 +1405,7 @@ section), or the \f[B]DC_SIGINT_RESET\f[R] environment variable (see the
|
|||
an integer or it is zero, dc(1) will exit.
|
||||
.PP
|
||||
However, if dc(1) is in interactive mode, and the
|
||||
\f[B]DC_SIGINT_RESET\f[R] or its default is an integer and non-zero,
|
||||
\f[B]DC_SIGINT_RESET\f[R] or its default is an integer and non\-zero,
|
||||
then dc(1) will stop executing the current input and reset (see the
|
||||
\f[B]RESET\f[R] section) upon receiving a \f[B]SIGINT\f[R].
|
||||
.PP
|
||||
|
@ -1429,7 +1431,7 @@ exit, and it uses the default handler for all other signals.
|
|||
bc(1)
|
||||
.SH STANDARDS
|
||||
The dc(1) utility operators and some behavior are compliant with the
|
||||
operators in the IEEE Std 1003.1-2017 (\[lq]POSIX.1-2017\[rq]) bc(1)
|
||||
operators in the IEEE Std 1003.1\-2017 (\[lq]POSIX.1\-2017\[rq]) bc(1)
|
||||
specification at
|
||||
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html .
|
||||
.SH BUGS
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2024 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:
|
||||
|
@ -25,41 +25,41 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "February 2023" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
|
||||
.nh
|
||||
.ad l
|
||||
.SH Name
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
dc \- arbitrary\-precision decimal reverse\-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
\f[B]dc\f[R] [\f[B]-cChiPRvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--digit-clamp\f[R]]
|
||||
[\f[B]--no-digit-clamp\f[R]] [\f[B]--interactive\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--no-read-prompt\f[R]]
|
||||
[\f[B]--extended-register\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...]
|
||||
[\f[B]-f\f[R] \f[I]file\f[R]\&...]
|
||||
[\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]dc\f[R] [\f[B]\-cChiPRvVx\f[R]] [\f[B]\-\-version\f[R]]
|
||||
[\f[B]\-\-help\f[R]] [\f[B]\-\-digit\-clamp\f[R]]
|
||||
[\f[B]\-\-no\-digit\-clamp\f[R]] [\f[B]\-\-interactive\f[R]]
|
||||
[\f[B]\-\-no\-prompt\f[R]] [\f[B]\-\-no\-read\-prompt\f[R]]
|
||||
[\f[B]\-\-extended\-register\f[R]] [\f[B]\-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\-\-expression\f[R]=\f[I]expr\f[R]\&...]
|
||||
[\f[B]\-f\f[R] \f[I]file\f[R]\&...]
|
||||
[\f[B]\-\-file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
dc(1) is an arbitrary-precision calculator.
|
||||
dc(1) is an arbitrary\-precision calculator.
|
||||
It uses a stack (reverse Polish notation) to store numbers and results
|
||||
of computations.
|
||||
Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line, then dc(1) reads from
|
||||
If no files are given on the command\-line, then dc(1) reads from
|
||||
\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
If a user wants to set up a standard environment, they can use
|
||||
\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
For example, if a user wants the \f[B]scale\f[R] always set to
|
||||
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
|
||||
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]\-e 10k\f[R],
|
||||
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
|
||||
.SH OPTIONS
|
||||
The following are the options that dc(1) accepts.
|
||||
.TP
|
||||
\f[B]-C\f[R], \f[B]--no-digit-clamp\f[R]
|
||||
\f[B]\-C\f[R], \f[B]\-\-no\-digit\-clamp\f[R]
|
||||
Disables clamping of digits greater than or equal to the current
|
||||
\f[B]ibase\f[R] when parsing numbers.
|
||||
.RS
|
||||
|
@ -69,17 +69,17 @@ digit\[cq]s value multiplied by the value of ibase raised to the power
|
|||
of the digit\[cq]s position, which starts from 0 at the least
|
||||
significant digit.
|
||||
.PP
|
||||
If this and/or the \f[B]-c\f[R] or \f[B]--digit-clamp\f[R] options are
|
||||
given multiple times, the last one given is used.
|
||||
If this and/or the \f[B]\-c\f[R] or \f[B]\-\-digit\-clamp\f[R] options
|
||||
are given multiple times, the last one given is used.
|
||||
.PP
|
||||
This option overrides the \f[B]DC_DIGIT_CLAMP\f[R] environment variable
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section) and the default, which
|
||||
can be queried with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
can be queried with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-c\f[R], \f[B]--digit-clamp\f[R]
|
||||
\f[B]\-c\f[R], \f[B]\-\-digit\-clamp\f[R]
|
||||
Enables clamping of digits greater than or equal to the current
|
||||
\f[B]ibase\f[R] when parsing numbers.
|
||||
.RS
|
||||
|
@ -90,17 +90,17 @@ all multiplied by the value of ibase raised to the power of the
|
|||
digit\[cq]s position, which starts from 0 at the least significant
|
||||
digit.
|
||||
.PP
|
||||
If this and/or the \f[B]-C\f[R] or \f[B]--no-digit-clamp\f[R] options
|
||||
are given multiple times, the last one given is used.
|
||||
If this and/or the \f[B]\-C\f[R] or \f[B]\-\-no\-digit\-clamp\f[R]
|
||||
options are given multiple times, the last one given is used.
|
||||
.PP
|
||||
This option overrides the \f[B]DC_DIGIT_CLAMP\f[R] environment variable
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section) and the default, which
|
||||
can be queried with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
can be queried with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]\-e\f[R] \f[I]expr\f[R], \f[B]\-\-expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
|
@ -109,44 +109,44 @@ This means that if a file is given before an expression, the file is
|
|||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
If this option is given on the command-line (i.e., not in
|
||||
If this option is given on the command\-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]\-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]\-f\f[R] or \f[B]\-\-file\f[R], whether on the command\-line or in
|
||||
\f[B]DC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, dc(1) will give a fatal error and
|
||||
exit.
|
||||
However, if any other \f[B]\-e\f[R], \f[B]\-\-expression\f[R],
|
||||
\f[B]\-f\f[R], or \f[B]\-\-file\f[R] arguments are given after
|
||||
\f[B]\-f\-\f[R] or equivalent is given, dc(1) will give a fatal error
|
||||
and exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
\f[B]\-f\f[R] \f[I]file\f[R], \f[B]\-\-file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
If this option is given on the command-line (i.e., not in
|
||||
If this option is given on the command\-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, dc(1) will give a fatal error and
|
||||
exit.
|
||||
\f[B]\-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]\-f\f[R] or \f[B]\-\-file\f[R].
|
||||
However, if any other \f[B]\-e\f[R], \f[B]\-\-expression\f[R],
|
||||
\f[B]\-f\f[R], or \f[B]\-\-file\f[R] arguments are given after
|
||||
\f[B]\-f\-\f[R] or equivalent is given, dc(1) will give a fatal error
|
||||
and exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
\f[B]\-h\f[R], \f[B]\-\-help\f[R]
|
||||
Prints a usage message and exits.
|
||||
.TP
|
||||
\f[B]-I\f[R] \f[I]ibase\f[R], \f[B]--ibase\f[R]=\f[I]ibase\f[R]
|
||||
\f[B]\-I\f[R] \f[I]ibase\f[R], \f[B]\-\-ibase\f[R]=\f[I]ibase\f[R]
|
||||
Sets the builtin variable \f[B]ibase\f[R] to the value \f[I]ibase\f[R]
|
||||
assuming that \f[I]ibase\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]ibase\f[R] is not a valid number.
|
||||
|
@ -154,28 +154,28 @@ It is a fatal error if \f[I]ibase\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
\f[B]\-i\f[R], \f[B]\-\-interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-L\f[R], \f[B]--no-line-length\f[R]
|
||||
\f[B]\-L\f[R], \f[B]\-\-no\-line\-length\f[R]
|
||||
Disables line length checking and prints numbers without backslashes and
|
||||
newlines.
|
||||
In other words, this option sets \f[B]BC_LINE_LENGTH\f[R] to \f[B]0\f[R]
|
||||
(see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-O\f[R] \f[I]obase\f[R], \f[B]--obase\f[R]=\f[I]obase\f[R]
|
||||
\f[B]\-O\f[R] \f[I]obase\f[R], \f[B]\-\-obase\f[R]=\f[I]obase\f[R]
|
||||
Sets the builtin variable \f[B]obase\f[R] to the value \f[I]obase\f[R]
|
||||
assuming that \f[I]obase\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]obase\f[R] is not a valid number.
|
||||
|
@ -183,10 +183,10 @@ It is a fatal error if \f[I]obase\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
\f[B]\-P\f[R], \f[B]\-\-no\-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section.)
|
||||
|
@ -199,10 +199,10 @@ Most of those users would want to put this option in
|
|||
These options override the \f[B]DC_PROMPT\f[R] and \f[B]DC_TTY_MODE\f[R]
|
||||
environment variables (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
|
||||
\f[B]\-R\f[R], \f[B]\-\-no\-read\-prompt\f[R]
|
||||
Disables the read prompt in TTY mode.
|
||||
(The read prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section.)
|
||||
|
@ -221,10 +221,10 @@ These options \f[I]do\f[R] override the \f[B]DC_PROMPT\f[R] and
|
|||
\f[B]DC_TTY_MODE\f[R] environment variables (see the \f[B]ENVIRONMENT
|
||||
VARIABLES\f[R] section), but only for the read prompt.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-S\f[R] \f[I]scale\f[R], \f[B]--scale\f[R]=\f[I]scale\f[R]
|
||||
\f[B]\-S\f[R] \f[I]scale\f[R], \f[B]\-\-scale\f[R]=\f[I]scale\f[R]
|
||||
Sets the builtin variable \f[B]scale\f[R] to the value \f[I]scale\f[R]
|
||||
assuming that \f[I]scale\f[R] is in base 10.
|
||||
It is a fatal error if \f[I]scale\f[R] is not a valid number.
|
||||
|
@ -232,34 +232,34 @@ It is a fatal error if \f[I]scale\f[R] is not a valid number.
|
|||
.PP
|
||||
If multiple instances of this option are given, the last is used.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
\f[B]\-v\f[R], \f[B]\-V\f[R], \f[B]\-\-version\f[R]
|
||||
Print the version information (copyright header) and exits.
|
||||
.TP
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
\f[B]\-x\f[R] \f[B]\-\-extended\-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-z\f[R], \f[B]--leading-zeroes\f[R]
|
||||
Makes dc(1) print all numbers greater than \f[B]-1\f[R] and less than
|
||||
\f[B]\-z\f[R], \f[B]\-\-leading\-zeroes\f[R]
|
||||
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 is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.PP
|
||||
All long options are \f[B]non-portable extensions\f[R].
|
||||
All long options are \f[B]non\-portable extensions\f[R].
|
||||
.SH STDIN
|
||||
If no files are given on the command-line and no files or expressions
|
||||
are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
|
||||
\f[B]--expression\f[R] options, then dc(1) reads from \f[B]stdin\f[R].
|
||||
If no files are given on the command\-line and no files or expressions
|
||||
are given by the \f[B]\-f\f[R], \f[B]\-\-file\f[R], \f[B]\-e\f[R], or
|
||||
\f[B]\-\-expression\f[R] options, then dc(1) reads from \f[B]stdin\f[R].
|
||||
.PP
|
||||
However, there is a caveat to this.
|
||||
.PP
|
||||
|
@ -269,7 +269,7 @@ ended.
|
|||
This means that, except for escaped brackets, all brackets must be
|
||||
balanced before dc(1) parses and executes.
|
||||
.SH STDOUT
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
Any non\-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
|
@ -277,7 +277,7 @@ to \f[B]stdout\f[R].
|
|||
\f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
write to \f[B]stdout\f[R], so if \f[B]stdout\f[R] is closed, as in
|
||||
\f[B]dc >&-\f[R], it will quit with an error.
|
||||
\f[B]dc >&\-\f[R], it will quit with an error.
|
||||
This is done so that dc(1) can report problems when \f[B]stdout\f[R] is
|
||||
redirected to a file.
|
||||
.PP
|
||||
|
@ -290,7 +290,7 @@ Any error output is written to \f[B]stderr\f[R].
|
|||
\f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
write to \f[B]stderr\f[R], so if \f[B]stderr\f[R] is closed, as in
|
||||
\f[B]dc 2>&-\f[R], it will quit with an error.
|
||||
\f[B]dc 2>&\-\f[R], it will quit with an error.
|
||||
This is done so that dc(1) can exit with an error code when
|
||||
\f[B]stderr\f[R] is redirected to a file.
|
||||
.PP
|
||||
|
@ -333,7 +333,7 @@ The max allowable value for \f[B]scale\f[R] can be queried in dc(1)
|
|||
programs with the \f[B]V\f[R] command.
|
||||
.SS Comments
|
||||
Comments go from \f[B]#\f[R] until, and not including, the next newline.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.SH NUMBERS
|
||||
Numbers are strings made up of digits, uppercase letters up to
|
||||
\f[B]F\f[R], and at most \f[B]1\f[R] period for a radix.
|
||||
|
@ -344,12 +344,12 @@ alphabet (i.e., \f[B]A\f[R] equals \f[B]10\f[R], or \f[B]9+1\f[R]).
|
|||
If a digit or letter makes no sense with the current value of
|
||||
\f[B]ibase\f[R] (i.e., they are greater than or equal to the current
|
||||
value of \f[B]ibase\f[R]), then the behavior depends on the existence of
|
||||
the \f[B]-c\f[R]/\f[B]--digit-clamp\f[R] or
|
||||
\f[B]-C\f[R]/\f[B]--no-digit-clamp\f[R] options (see the
|
||||
the \f[B]\-c\f[R]/\f[B]\-\-digit\-clamp\f[R] or
|
||||
\f[B]\-C\f[R]/\f[B]\-\-no\-digit\-clamp\f[R] options (see the
|
||||
\f[B]OPTIONS\f[R] section), the existence and setting of the
|
||||
\f[B]DC_DIGIT_CLAMP\f[R] environment variable (see the \f[B]ENVIRONMENT
|
||||
VARIABLES\f[R] section), or the default, which can be queried with the
|
||||
\f[B]-h\f[R]/\f[B]--help\f[R] option.
|
||||
\f[B]\-h\f[R]/\f[B]\-\-help\f[R] option.
|
||||
.PP
|
||||
If clamping is off, then digits or letters that are greater than or
|
||||
equal to the current value of \f[B]ibase\f[R] are not changed.
|
||||
|
@ -367,7 +367,7 @@ This means that, with an \f[B]ibase\f[R] of \f[B]3\f[R], the number
|
|||
\f[B]AB\f[R] is equal to \f[B]3\[ha]1*2+3\[ha]0*2\f[R], which is
|
||||
\f[B]3\f[R] times \f[B]2\f[R] plus \f[B]2\f[R], or \f[B]8\f[R].
|
||||
.PP
|
||||
There is one exception to clamping: single-character numbers (i.e.,
|
||||
There is one exception to clamping: single\-character numbers (i.e.,
|
||||
\f[B]A\f[R] alone).
|
||||
Such numbers are never clamped and always take the value they would have
|
||||
in the highest possible \f[B]ibase\f[R].
|
||||
|
@ -403,12 +403,12 @@ Pops a value off the stack.
|
|||
.PP
|
||||
If the value is a number, it is truncated and the absolute value of the
|
||||
result is printed as though \f[B]obase\f[R] is \f[B]256\f[R] and each
|
||||
digit is interpreted as an 8-bit ASCII character, making it a byte
|
||||
digit is interpreted as an 8\-bit ASCII character, making it a byte
|
||||
stream.
|
||||
.PP
|
||||
If the value is a string, it is printed without a trailing newline.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]f\f[R]
|
||||
|
@ -427,7 +427,7 @@ pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to the max \f[I]scale\f[R] of
|
||||
both operands.
|
||||
.TP
|
||||
\f[B]-\f[R]
|
||||
\f[B]\-\f[R]
|
||||
The top two values are popped off the stack, subtracted, and the result
|
||||
is pushed onto the stack.
|
||||
The \f[I]scale\f[R] of the result is equal to the max \f[I]scale\f[R] of
|
||||
|
@ -448,7 +448,7 @@ pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
||||
.RS
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]%\f[R]
|
||||
|
@ -458,10 +458,10 @@ is pushed onto the stack.
|
|||
.PP
|
||||
Remaindering is equivalent to 1) Computing \f[B]a/b\f[R] to current
|
||||
\f[B]scale\f[R], and 2) Using the result of step 1 to calculate
|
||||
\f[B]a-(a/b)*b\f[R] to \f[I]scale\f[R]
|
||||
\f[B]a\-(a/b)*b\f[R] to \f[I]scale\f[R]
|
||||
\f[B]max(scale+scale(b),scale(a))\f[R].
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]\[ti]\f[R]
|
||||
|
@ -472,9 +472,9 @@ This is equivalent to \f[B]x y / x y %\f[R] except that \f[B]x\f[R] and
|
|||
\f[B]y\f[R] are only evaluated once.
|
||||
.RS
|
||||
.PP
|
||||
The first value popped off of the stack must be non-zero.
|
||||
The first value popped off of the stack must be non\-zero.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]\[ha]\f[R]
|
||||
|
@ -485,7 +485,7 @@ The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
|||
.PP
|
||||
The first value popped off of the stack must be an integer, and if that
|
||||
value is negative, the second value popped off of the stack must be
|
||||
non-zero.
|
||||
non\-zero.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]v\f[R]
|
||||
|
@ -494,7 +494,7 @@ the result is pushed onto the stack.
|
|||
The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
|
||||
.RS
|
||||
.PP
|
||||
The value popped off of the stack must be non-negative.
|
||||
The value popped off of the stack must be non\-negative.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]_\f[R]
|
||||
|
@ -504,7 +504,7 @@ or other commands), then that number is input as a negative number.
|
|||
.PP
|
||||
Otherwise, the top value on the stack is popped and copied, and the copy
|
||||
is negated and pushed onto the stack.
|
||||
This behavior without a number is a \f[B]non-portable extension\f[R].
|
||||
This behavior without a number is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]b\f[R]
|
||||
|
@ -513,7 +513,7 @@ back onto the stack.
|
|||
Otherwise, its absolute value is pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]|\f[R]
|
||||
|
@ -522,12 +522,12 @@ is computed, and the result is pushed onto the stack.
|
|||
.RS
|
||||
.PP
|
||||
The first value popped is used as the reduction modulus and must be an
|
||||
integer and non-zero.
|
||||
integer and non\-zero.
|
||||
The second value popped is used as the exponent and must be an integer
|
||||
and non-negative.
|
||||
and non\-negative.
|
||||
The third value popped is the base and must be an integer.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]G\f[R]
|
||||
|
@ -535,7 +535,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]1\f[R] is pushed if they are equal, or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]N\f[R]
|
||||
|
@ -543,7 +543,7 @@ The top value is popped off of the stack, and if it a \f[B]0\f[R], a
|
|||
\f[B]1\f[R] is pushed; otherwise, a \f[B]0\f[R] is pushed.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B](\f[R]
|
||||
|
@ -552,7 +552,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]{\f[R]
|
||||
|
@ -561,7 +561,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B])\f[R]
|
||||
|
@ -570,7 +570,7 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
\f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]}\f[R]
|
||||
|
@ -579,33 +579,33 @@ The top two values are popped off of the stack, they are compared, and a
|
|||
second, or \f[B]0\f[R] otherwise.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]M\f[R]
|
||||
The top two values are popped off of the stack.
|
||||
If they are both non-zero, a \f[B]1\f[R] is pushed onto the stack.
|
||||
If they are both non\-zero, a \f[B]1\f[R] is pushed onto the stack.
|
||||
If either of them is zero, or both of them are, then a \f[B]0\f[R] is
|
||||
pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is like the \f[B]&&\f[R] operator in bc(1), and it is \f[I]not\f[R]
|
||||
a short-circuit operator.
|
||||
a short\-circuit operator.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]m\f[R]
|
||||
The top two values are popped off of the stack.
|
||||
If at least one of them is non-zero, a \f[B]1\f[R] is pushed onto the
|
||||
If at least one of them is non\-zero, a \f[B]1\f[R] is pushed onto the
|
||||
stack.
|
||||
If both of them are zero, then a \f[B]0\f[R] is pushed onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is like the \f[B]||\f[R] operator in bc(1), and it is \f[I]not\f[R]
|
||||
a short-circuit operator.
|
||||
a short\-circuit operator.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Stack Control
|
||||
These commands control the stack.
|
||||
|
@ -670,7 +670,7 @@ If the value on top of the stack has any \f[I]scale\f[R], the
|
|||
.TP
|
||||
\f[B]k\f[R]
|
||||
Pops the value off of the top of the stack and uses it to set
|
||||
\f[B]scale\f[R], which must be non-negative.
|
||||
\f[B]scale\f[R], which must be non\-negative.
|
||||
.RS
|
||||
.PP
|
||||
If the value on top of the stack has any \f[I]scale\f[R], the
|
||||
|
@ -691,7 +691,7 @@ Pushes the maximum allowable value of \f[B]ibase\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]U\f[R]
|
||||
|
@ -699,7 +699,7 @@ Pushes the maximum allowable value of \f[B]obase\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]V\f[R]
|
||||
|
@ -707,7 +707,7 @@ Pushes the maximum allowable value of \f[B]scale\f[R] onto the main
|
|||
stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Strings
|
||||
The following commands control strings.
|
||||
|
@ -747,16 +747,16 @@ The value on top of the stack is popped.
|
|||
If it is a number, it is truncated and its absolute value is taken.
|
||||
The result mod \f[B]256\f[R] is calculated.
|
||||
If that result is \f[B]0\f[R], push an empty string; otherwise, push a
|
||||
one-character string where the character is the result of the mod
|
||||
one\-character string where the character is the result of the mod
|
||||
interpreted as an ASCII character.
|
||||
.PP
|
||||
If it is a string, then a new string is made.
|
||||
If the original string is empty, the new string is empty.
|
||||
If it is not, then the first character of the original string is used to
|
||||
create the new string as a one-character string.
|
||||
create the new string as a one\-character string.
|
||||
The new string is then pushed onto the stack.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]x\f[R]
|
||||
|
@ -792,7 +792,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!>\f[R]\f[I]r\f[R]
|
||||
|
@ -813,7 +813,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]<\f[R]\f[I]r\f[R]
|
||||
|
@ -834,7 +834,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!<\f[R]\f[I]r\f[R]
|
||||
|
@ -855,7 +855,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]=\f[R]\f[I]r\f[R]
|
||||
|
@ -876,7 +876,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]!=\f[R]\f[I]r\f[R]
|
||||
|
@ -897,7 +897,7 @@ fails.
|
|||
If either or both of the values are not numbers, dc(1) will raise an
|
||||
error and reset (see the \f[B]RESET\f[R] section).
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]?\f[R]
|
||||
|
@ -910,7 +910,7 @@ the execution of the macro that executed it.
|
|||
If there are no macros, or only one macro executing, dc(1) exits.
|
||||
.TP
|
||||
\f[B]Q\f[R]
|
||||
Pops a value from the stack which must be non-negative and is used the
|
||||
Pops a value from the stack which must be non\-negative and is used the
|
||||
number of macro executions to pop off of the execution stack.
|
||||
If the number of levels to pop is greater than the number of executing
|
||||
macros, dc(1) exits.
|
||||
|
@ -923,7 +923,7 @@ to make dc(1) exit with the \f[B]Q\f[R] command, so the sequence
|
|||
\f[B],Q\f[R] will make dc(1) exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Status
|
||||
These commands query status of the stack or its top value.
|
||||
|
@ -956,7 +956,7 @@ If the value is a number, this pushes \f[B]1\f[R] onto the stack.
|
|||
Otherwise (if it is a string), it pushes \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]t\f[R]
|
||||
|
@ -965,7 +965,7 @@ If the value is a string, this pushes \f[B]1\f[R] onto the stack.
|
|||
Otherwise (if it is a number), it pushes \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]z\f[R]
|
||||
|
@ -983,7 +983,7 @@ register\[cq]s stack must always have at least one item; dc(1) will give
|
|||
an error and reset otherwise (see the \f[B]RESET\f[R] section).
|
||||
This means that this command will never push \f[B]0\f[R].
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Arrays
|
||||
These commands manipulate arrays.
|
||||
|
@ -1002,7 +1002,7 @@ The selected value is then pushed onto the stack.
|
|||
Pushes the length of the array \f[I]r\f[R] onto the stack.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
This is a \f[B]non\-portable extension\f[R].
|
||||
.RE
|
||||
.SS Global Settings
|
||||
These commands retrieve global settings.
|
||||
|
@ -1024,8 +1024,8 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
|||
.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
|
||||
(see the \f[B]OPTIONS\f[R] section), non-zero otherwise.
|
||||
been enabled with the \f[B]\-z\f[R] or \f[B]\-\-leading\-zeroes\f[R]
|
||||
options (see the \f[B]OPTIONS\f[R] section), non\-zero otherwise.
|
||||
.SH REGISTERS
|
||||
Registers are names that can store strings, numbers, and arrays.
|
||||
(Number/string registers do not interfere with array registers.)
|
||||
|
@ -1036,7 +1036,7 @@ All registers, when first referenced, have one value (\f[B]0\f[R]) in
|
|||
their stack, and it is a runtime error to attempt to pop that item off
|
||||
of the register stack.
|
||||
.PP
|
||||
In non-extended register mode, a register name is just the single
|
||||
In non\-extended register mode, a register name is just the single
|
||||
character that follows any command that needs a register name.
|
||||
The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
|
||||
bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
|
||||
|
@ -1045,18 +1045,18 @@ bracket to be used as a register name.
|
|||
Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
If extended register mode is enabled (\f[B]\-x\f[R] or
|
||||
\f[B]\-\-extended\-register\f[R] command\-line arguments are given),
|
||||
then normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
(\f[B]`\[rs]n'\f[R]).
|
||||
.PP
|
||||
In that case, the register name is found according to the regex
|
||||
\f[B][a-z][a-z0-9_]*\f[R] (like bc(1) identifiers), and it is a parse
|
||||
error if the next non-space characters do not match that regex.
|
||||
\f[B][a\-z][a\-z0\-9_]*\f[R] (like bc(1) identifiers), and it is a parse
|
||||
error if the next non\-space characters do not match that regex.
|
||||
.SH RESET
|
||||
When dc(1) encounters an error or a signal that it has a non-default
|
||||
When dc(1) encounters an error or a signal that it has a non\-default
|
||||
handler for, it resets.
|
||||
This means that several things happen.
|
||||
.PP
|
||||
|
@ -1120,24 +1120,24 @@ Set at \f[B]DC_BASE_POW\f[R].
|
|||
.TP
|
||||
\f[B]DC_DIM_MAX\f[R]
|
||||
The maximum size of arrays.
|
||||
Set at \f[B]SIZE_MAX-1\f[R].
|
||||
Set at \f[B]SIZE_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_SCALE_MAX\f[R]
|
||||
The maximum \f[B]scale\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_STRING_MAX\f[R]
|
||||
The maximum length of strings.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_NAME_MAX\f[R]
|
||||
The maximum length of identifiers.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
\f[B]DC_NUM_MAX\f[R]
|
||||
The maximum length of a number (in decimal digits), which includes
|
||||
digits after the decimal point.
|
||||
Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
|
||||
Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
|
||||
.TP
|
||||
Exponent
|
||||
The maximum allowable exponent (positive or negative).
|
||||
|
@ -1145,27 +1145,27 @@ Set at \f[B]DC_OVERFLOW_MAX\f[R].
|
|||
.TP
|
||||
Number of vars
|
||||
The maximum number of vars/arrays.
|
||||
Set at \f[B]SIZE_MAX-1\f[R].
|
||||
Set at \f[B]SIZE_MAX\-1\f[R].
|
||||
.PP
|
||||
These limits are meant to be effectively non-existent; the limits are so
|
||||
large (at least on 64-bit machines) that there should not be any point
|
||||
at which they become a problem.
|
||||
These limits are meant to be effectively non\-existent; the limits are
|
||||
so large (at least on 64\-bit machines) that there should not be any
|
||||
point at which they become a problem.
|
||||
In fact, memory should be exhausted before these limits should be hit.
|
||||
.SH ENVIRONMENT VARIABLES
|
||||
As \f[B]non-portable extensions\f[R], dc(1) recognizes the following
|
||||
As \f[B]non\-portable extensions\f[R], dc(1) recognizes the following
|
||||
environment variables:
|
||||
.TP
|
||||
\f[B]DC_ENV_ARGS\f[R]
|
||||
This is another way to give command-line arguments to dc(1).
|
||||
They should be in the same format as all other command-line arguments.
|
||||
This is another way to give command\-line arguments to dc(1).
|
||||
They should be in the same format as all other command\-line arguments.
|
||||
These are always processed first, so any files given in
|
||||
\f[B]DC_ENV_ARGS\f[R] will be processed before arguments and files given
|
||||
on the command-line.
|
||||
on the command\-line.
|
||||
This gives the user the ability to set up \[lq]standard\[rq] options and
|
||||
files to be used at every invocation.
|
||||
The most useful thing for such files to contain would be useful
|
||||
functions that the user might want every time dc(1) runs.
|
||||
Another use would be to use the \f[B]-e\f[R] option to set
|
||||
Another use would be to use the \f[B]\-e\f[R] option to set
|
||||
\f[B]scale\f[R] to a value other than \f[B]0\f[R].
|
||||
.RS
|
||||
.PP
|
||||
|
@ -1183,14 +1183,14 @@ you can use double quotes as the outside quotes, as in \f[B]\[lq]some
|
|||
quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
parsing, though such files are still supported on the command-line where
|
||||
the parsing is done by the shell.
|
||||
parsing, though such files are still supported on the command\-line
|
||||
where the parsing is done by the shell.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_LINE_LENGTH\f[R]
|
||||
If this environment variable exists and contains an integer that is
|
||||
greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
|
||||
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
|
||||
(\f[B]2\[ha]16\-1\f[R]), dc(1) will output lines to that length,
|
||||
including the backslash newline combo.
|
||||
The default line length is \f[B]70\f[R].
|
||||
.RS
|
||||
|
@ -1207,13 +1207,13 @@ exits on \f[B]SIGINT\f[R] when not in interactive mode.
|
|||
.RS
|
||||
.PP
|
||||
However, when dc(1) is in interactive mode, then if this environment
|
||||
variable exists and contains an integer, a non-zero value makes dc(1)
|
||||
variable exists and contains an integer, a non\-zero value makes dc(1)
|
||||
reset on \f[B]SIGINT\f[R], rather than exit, and zero makes dc(1) exit.
|
||||
If this environment variable exists and is \f[I]not\f[R] an integer,
|
||||
then dc(1) will exit on \f[B]SIGINT\f[R].
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_TTY_MODE\f[R]
|
||||
|
@ -1222,11 +1222,11 @@ section), then this environment variable has no effect.
|
|||
.RS
|
||||
.PP
|
||||
However, when TTY mode is available, then if this environment variable
|
||||
exists and contains an integer, then a non-zero value makes dc(1) use
|
||||
exists and contains an integer, then a non\-zero value makes dc(1) use
|
||||
TTY mode, and zero makes dc(1) not use TTY mode.
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_PROMPT\f[R]
|
||||
|
@ -1235,43 +1235,44 @@ section), then this environment variable has no effect.
|
|||
.RS
|
||||
.PP
|
||||
However, when TTY mode is available, then if this environment variable
|
||||
exists and contains an integer, a non-zero value makes dc(1) use a
|
||||
prompt, and zero or a non-integer makes dc(1) not use a prompt.
|
||||
exists and contains an integer, a non\-zero value makes dc(1) use a
|
||||
prompt, and zero or a non\-integer makes dc(1) not use a prompt.
|
||||
If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
|
||||
does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
|
||||
is used.
|
||||
.PP
|
||||
This environment variable and the \f[B]DC_TTY_MODE\f[R] environment
|
||||
variable override the default, which can be queried with the
|
||||
\f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
\f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_EXPR_EXIT\f[R]
|
||||
If any expressions or expression files are given on the command-line
|
||||
with \f[B]-e\f[R], \f[B]--expression\f[R], \f[B]-f\f[R], or
|
||||
\f[B]--file\f[R], then if this environment variable exists and contains
|
||||
an integer, a non-zero value makes dc(1) exit after executing the
|
||||
expressions and expression files, and a zero value makes dc(1) not exit.
|
||||
If any expressions or expression files are given on the command\-line
|
||||
with \f[B]\-e\f[R], \f[B]\-\-expression\f[R], \f[B]\-f\f[R], or
|
||||
\f[B]\-\-file\f[R], then if this environment variable exists and
|
||||
contains an integer, a non\-zero value makes dc(1) exit after executing
|
||||
the expressions and expression files, and a zero value makes dc(1) not
|
||||
exit.
|
||||
.RS
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]DC_DIGIT_CLAMP\f[R]
|
||||
When parsing numbers and if this environment variable exists and
|
||||
contains an integer, a non-zero value makes dc(1) clamp digits that are
|
||||
contains an integer, a non\-zero value makes dc(1) clamp digits that are
|
||||
greater than or equal to the current \f[B]ibase\f[R] so that all such
|
||||
digits are considered equal to the \f[B]ibase\f[R] minus 1, and a zero
|
||||
value disables such clamping so that those digits are always equal to
|
||||
their value, which is multiplied by the power of the \f[B]ibase\f[R].
|
||||
.RS
|
||||
.PP
|
||||
This never applies to single-digit numbers, as per the bc(1) standard
|
||||
This never applies to single\-digit numbers, as per the bc(1) standard
|
||||
(see the \f[B]STANDARDS\f[R] section).
|
||||
.PP
|
||||
This environment variable overrides the default, which can be queried
|
||||
with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
|
||||
with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
|
||||
.RE
|
||||
.SH EXIT STATUS
|
||||
dc(1) returns the following exit statuses:
|
||||
|
@ -1289,7 +1290,7 @@ Math errors include divide by \f[B]0\f[R], taking the square root of a
|
|||
negative number, attempting to convert a negative number to a hardware
|
||||
integer, overflow when converting a number to a hardware integer,
|
||||
overflow when calculating the size of a number, and attempting to use a
|
||||
non-integer where an integer is required.
|
||||
non\-integer where an integer is required.
|
||||
.PP
|
||||
Converting to a hardware integer happens for the second operand of the
|
||||
power (\f[B]\[ha]\f[R]) operator.
|
||||
|
@ -1323,7 +1324,7 @@ A fatal error occurred.
|
|||
Fatal errors include memory allocation errors, I/O errors, failing to
|
||||
open files, attempting to use files that do not have only ASCII
|
||||
characters (dc(1) only accepts ASCII characters), attempting to open a
|
||||
directory as a file, and giving invalid command-line options.
|
||||
directory as a file, and giving invalid command\-line options.
|
||||
.RE
|
||||
.PP
|
||||
The exit status \f[B]4\f[R] is special; when a fatal error occurs, dc(1)
|
||||
|
@ -1334,16 +1335,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
|||
dc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
\f[B]\-i\f[R] flag or \f[B]\-\-interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow dc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
\f[B]\-i\f[R] flag or \f[B]\-\-interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
Like bc(1), dc(1) has an interactive mode and a non-interactive mode.
|
||||
Like bc(1), dc(1) has an interactive mode and a non\-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]--interactive\f[R] option can turn it on in other situations.
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]\-i\f[R]
|
||||
flag and \f[B]\-\-interactive\f[R] option can turn it on in other
|
||||
situations.
|
||||
.PP
|
||||
In interactive mode, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
@ -1359,23 +1361,23 @@ settings.
|
|||
.PP
|
||||
If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
|
||||
environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
|
||||
that environment variable contains a non-zero integer, dc(1) will turn
|
||||
that environment variable contains a non\-zero integer, dc(1) will turn
|
||||
on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R]
|
||||
are all connected to a TTY.
|
||||
If the \f[B]DC_TTY_MODE\f[R] environment variable exists but is
|
||||
\f[I]not\f[R] a non-zero integer, then dc(1) will not turn TTY mode on.
|
||||
\f[I]not\f[R] a non\-zero integer, then dc(1) will not turn TTY mode on.
|
||||
.PP
|
||||
If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
|
||||
exist, the default setting is used.
|
||||
The default setting can be queried with the \f[B]-h\f[R] or
|
||||
\f[B]--help\f[R] options.
|
||||
The default setting can be queried with the \f[B]\-h\f[R] or
|
||||
\f[B]\-\-help\f[R] options.
|
||||
.PP
|
||||
TTY mode is different from interactive mode because interactive mode is
|
||||
required in the bc(1) specification (see the \f[B]STANDARDS\f[R]
|
||||
section), and interactive mode requires only \f[B]stdin\f[R] and
|
||||
\f[B]stdout\f[R] to be connected to a terminal.
|
||||
.SS Command-Line History
|
||||
Command-line history is only enabled if TTY mode is, i.e., that
|
||||
.SS Command\-Line History
|
||||
Command\-line history is only enabled if TTY mode is, i.e., that
|
||||
\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to
|
||||
a TTY and the \f[B]DC_TTY_MODE\f[R] environment variable (see the
|
||||
\f[B]ENVIRONMENT VARIABLES\f[R] section) and its default do not disable
|
||||
|
@ -1387,18 +1389,18 @@ Like TTY mode itself, it can be turned on or off with an environment
|
|||
variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
|
||||
section).
|
||||
.PP
|
||||
If the environment variable \f[B]DC_PROMPT\f[R] exists and is a non-zero
|
||||
integer, then the prompt is turned on when \f[B]stdin\f[R],
|
||||
If the environment variable \f[B]DC_PROMPT\f[R] exists and is a
|
||||
non\-zero integer, then the prompt is turned on when \f[B]stdin\f[R],
|
||||
\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
|
||||
\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
|
||||
\f[B]\-P\f[R] and \f[B]\-\-no\-prompt\f[R] options were not used.
|
||||
The read prompt will be turned on under the same conditions, except that
|
||||
the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
|
||||
used.
|
||||
the \f[B]\-R\f[R] and \f[B]\-\-no\-read\-prompt\f[R] options must also
|
||||
not be used.
|
||||
.PP
|
||||
However, if \f[B]DC_PROMPT\f[R] does not exist, the prompt can be
|
||||
enabled or disabled with the \f[B]DC_TTY_MODE\f[R] environment variable,
|
||||
the \f[B]-P\f[R] and \f[B]--no-prompt\f[R] options, and the \f[B]-R\f[R]
|
||||
and \f[B]--no-read-prompt\f[R] options.
|
||||
the \f[B]\-P\f[R] and \f[B]\-\-no\-prompt\f[R] options, and the
|
||||
\f[B]\-R\f[R] and \f[B]\-\-no\-read\-prompt\f[R] options.
|
||||
See the \f[B]ENVIRONMENT VARIABLES\f[R] and \f[B]OPTIONS\f[R] sections
|
||||
for more details.
|
||||
.SH SIGNAL HANDLING
|
||||
|
@ -1410,7 +1412,7 @@ section), or the \f[B]DC_SIGINT_RESET\f[R] environment variable (see the
|
|||
an integer or it is zero, dc(1) will exit.
|
||||
.PP
|
||||
However, if dc(1) is in interactive mode, and the
|
||||
\f[B]DC_SIGINT_RESET\f[R] or its default is an integer and non-zero,
|
||||
\f[B]DC_SIGINT_RESET\f[R] or its default is an integer and non\-zero,
|
||||
then dc(1) will stop executing the current input and reset (see the
|
||||
\f[B]RESET\f[R] section) upon receiving a \f[B]SIGINT\f[R].
|
||||
.PP
|
||||
|
@ -1436,11 +1438,11 @@ The one exception is \f[B]SIGHUP\f[R]; in that case, and only when dc(1)
|
|||
is in TTY mode (see the \f[B]TTY MODE\f[R] section), a \f[B]SIGHUP\f[R]
|
||||
will cause dc(1) to clean up and exit.
|
||||
.SH COMMAND LINE HISTORY
|
||||
dc(1) supports interactive command-line editing.
|
||||
dc(1) supports interactive command\-line editing.
|
||||
.PP
|
||||
If dc(1) can be in TTY mode (see the \f[B]TTY MODE\f[R] section),
|
||||
history can be enabled.
|
||||
This means that command-line history can only be enabled when
|
||||
This means that command\-line history can only be enabled when
|
||||
\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
|
||||
connected to a TTY.
|
||||
.PP
|
||||
|
@ -1453,7 +1455,7 @@ section).
|
|||
bc(1)
|
||||
.SH STANDARDS
|
||||
The dc(1) utility operators and some behavior are compliant with the
|
||||
operators in the IEEE Std 1003.1-2017 (\[lq]POSIX.1-2017\[rq]) bc(1)
|
||||
operators in the IEEE Std 1003.1\-2017 (\[lq]POSIX.1\-2017\[rq]) bc(1)
|
||||
specification at
|
||||
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html .
|
||||
.SH BUGS
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2023 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2024 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:
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue