aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2024-09-18 05:55:46 +0000
committerStefan Eßer <se@FreeBSD.org>2024-09-18 05:55:46 +0000
commitc2c85f88902d18d2e9702381f1628112e15a5c3c (patch)
tree50666ca2f52a79094e8694094037213e84145c84
parent1e19146fc7692f59e8dfc5da7957e938cd0b81b8 (diff)
vendor/bc: upgrade to version 7.0.2vendor/bc/7.0.2
This update fixes exiting from an interactive bc session with ^D on FreeBSD and Linux when using editline. This bug was caused by the macOS fix for editline in version 7.0.0, which has been reverted in this version.
-rw-r--r--NEWS.md8
-rw-r--r--include/history.h24
-rw-r--r--include/version.h2
-rw-r--r--manuals/bc/A.16
-rw-r--r--manuals/bc/A.1.md4
-rw-r--r--manuals/bc/E.12
-rw-r--r--manuals/bc/EH.12
-rw-r--r--manuals/bc/EHN.12
-rw-r--r--manuals/bc/EN.12
-rw-r--r--manuals/bc/H.16
-rw-r--r--manuals/bc/H.1.md4
-rw-r--r--manuals/bc/HN.16
-rw-r--r--manuals/bc/HN.1.md4
-rw-r--r--manuals/bc/N.16
-rw-r--r--manuals/bc/N.1.md4
-rw-r--r--src/history.c13
16 files changed, 69 insertions, 26 deletions
diff --git a/NEWS.md b/NEWS.md
index 8156b673ce04..e3b1f9ecb7bc 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,13 @@
# News
+## 7.0.2
+
+This is a production release that fixes `Ctrl+d` on FreeBSD and Linux when using
+`editline`.
+
+This bug was caused by the macOS fix in `7.0.0`. Unfortunately, this means that
+macOS does not respond properly to `Ctrl+d`.
+
## 7.0.1
This is a production release that fixes a warning using GCC on FreeBSD.
diff --git a/include/history.h b/include/history.h
index 460524bd7b87..13f6dc6e985c 100644
--- a/include/history.h
+++ b/include/history.h
@@ -120,6 +120,30 @@ typedef struct BcHistory
extern const char bc_history_editrc[];
extern const size_t bc_history_editrc_len;
+#ifdef __APPLE__
+
+/**
+ * Returns true if the line is a valid line, false otherwise.
+ * @param line The line.
+ * @param len The length of the line.
+ * @return True if the line is valid, false otherwise.
+ */
+#define BC_HISTORY_INVALID_LINE(line, len) \
+ ((line) == NULL && ((len) == -1 || errno == EINTR))
+
+#else // __APPLE__
+
+/**
+ * Returns true if the line is a valid line, false otherwise.
+ * @param line The line.
+ * @param len The length of the line.
+ * @return True if the line is valid, false otherwise.
+ */
+#define BC_HISTORY_INVALID_LINE(line, len) \
+ ((line) == NULL && (len) == -1 && errno == EINTR)
+
+#endif // __APPLE__
+
#else // BC_ENABLE_EDITLINE
#if BC_ENABLE_READLINE
diff --git a/include/version.h b/include/version.h
index 4d2f6acfb433..a4fb8def5024 100644
--- a/include/version.h
+++ b/include/version.h
@@ -37,6 +37,6 @@
#define BC_VERSION_H
/// The current version.
-#define VERSION 7.0.1
+#define VERSION 7.0.2
#endif // BC_VERSION_H
diff --git a/manuals/bc/A.1 b/manuals/bc/A.1
index 4750598b55fc..adeb62f82e6a 100644
--- a/manuals/bc/A.1
+++ b/manuals/bc/A.1
@@ -25,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.TH "BC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
+.TH "BC" "1" "August 2024" "Gavin D. Howard" "General Commands Manual"
.nh
.ad l
.SH NAME
@@ -1731,7 +1731,7 @@ Functions\f[R] subsection below).
.RE
.TP
\f[B]frand(p)\f[R]
-Generates a pseudo\-random integer between \f[B]0\f[R] (inclusive) and
+Generates a pseudo\-random number between \f[B]0\f[R] (inclusive) and
\f[B]1\f[R] (exclusive) with the number of decimal digits after the
decimal point equal to the truncated absolute value of \f[B]p\f[R].
If \f[B]p\f[R] is not \f[B]0\f[R], then calling this function will
@@ -1740,7 +1740,7 @@ If \f[B]p\f[R] is \f[B]0\f[R], then \f[B]0\f[R] is returned, and
\f[B]seed\f[R] is \f[I]not\f[R] changed.
.TP
\f[B]ifrand(i, p)\f[R]
-Generates a pseudo\-random integer that is between \f[B]0\f[R]
+Generates a pseudo\-random number that is between \f[B]0\f[R]
(inclusive) and the truncated absolute value of \f[B]i\f[R] (exclusive)
with the number of decimal digits after the decimal point equal to the
truncated absolute value of \f[B]p\f[R].
diff --git a/manuals/bc/A.1.md b/manuals/bc/A.1.md
index 56f7c52fb2cd..e89305b1af44 100644
--- a/manuals/bc/A.1.md
+++ b/manuals/bc/A.1.md
@@ -1433,7 +1433,7 @@ The extended library is a **non-portable extension**.
**frand(p)**
-: Generates a pseudo-random integer between **0** (inclusive) and **1**
+: Generates a pseudo-random number between **0** (inclusive) and **1**
(exclusive) with the number of decimal digits after the decimal point equal
to the truncated absolute value of **p**. If **p** is not **0**, then
calling this function will change the value of **seed**. If **p** is **0**,
@@ -1441,7 +1441,7 @@ The extended library is a **non-portable extension**.
**ifrand(i, p)**
-: Generates a pseudo-random integer that is between **0** (inclusive) and the
+: Generates a pseudo-random number that is between **0** (inclusive) and the
truncated absolute value of **i** (exclusive) with the number of decimal
digits after the decimal point equal to the truncated absolute value of
**p**. If the absolute value of **i** is greater than or equal to **2**, and
diff --git a/manuals/bc/E.1 b/manuals/bc/E.1
index 62b18165fe92..e2f1b034e69a 100644
--- a/manuals/bc/E.1
+++ b/manuals/bc/E.1
@@ -25,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.TH "BC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
+.TH "BC" "1" "August 2024" "Gavin D. Howard" "General Commands Manual"
.nh
.ad l
.SH NAME
diff --git a/manuals/bc/EH.1 b/manuals/bc/EH.1
index 69f28e875990..c132a0b76a49 100644
--- a/manuals/bc/EH.1
+++ b/manuals/bc/EH.1
@@ -25,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.TH "BC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
+.TH "BC" "1" "August 2024" "Gavin D. Howard" "General Commands Manual"
.nh
.ad l
.SH NAME
diff --git a/manuals/bc/EHN.1 b/manuals/bc/EHN.1
index fb453b05363d..e3395b1cc20d 100644
--- a/manuals/bc/EHN.1
+++ b/manuals/bc/EHN.1
@@ -25,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.TH "BC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
+.TH "BC" "1" "August 2024" "Gavin D. Howard" "General Commands Manual"
.nh
.ad l
.SH NAME
diff --git a/manuals/bc/EN.1 b/manuals/bc/EN.1
index 4833e3e70ddc..c1ccbec567ec 100644
--- a/manuals/bc/EN.1
+++ b/manuals/bc/EN.1
@@ -25,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.TH "BC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
+.TH "BC" "1" "August 2024" "Gavin D. Howard" "General Commands Manual"
.nh
.ad l
.SH NAME
diff --git a/manuals/bc/H.1 b/manuals/bc/H.1
index 4787435ae052..9dc46ee50dee 100644
--- a/manuals/bc/H.1
+++ b/manuals/bc/H.1
@@ -25,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.TH "BC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
+.TH "BC" "1" "August 2024" "Gavin D. Howard" "General Commands Manual"
.nh
.ad l
.SH NAME
@@ -1731,7 +1731,7 @@ Functions\f[R] subsection below).
.RE
.TP
\f[B]frand(p)\f[R]
-Generates a pseudo\-random integer between \f[B]0\f[R] (inclusive) and
+Generates a pseudo\-random number between \f[B]0\f[R] (inclusive) and
\f[B]1\f[R] (exclusive) with the number of decimal digits after the
decimal point equal to the truncated absolute value of \f[B]p\f[R].
If \f[B]p\f[R] is not \f[B]0\f[R], then calling this function will
@@ -1740,7 +1740,7 @@ If \f[B]p\f[R] is \f[B]0\f[R], then \f[B]0\f[R] is returned, and
\f[B]seed\f[R] is \f[I]not\f[R] changed.
.TP
\f[B]ifrand(i, p)\f[R]
-Generates a pseudo\-random integer that is between \f[B]0\f[R]
+Generates a pseudo\-random number that is between \f[B]0\f[R]
(inclusive) and the truncated absolute value of \f[B]i\f[R] (exclusive)
with the number of decimal digits after the decimal point equal to the
truncated absolute value of \f[B]p\f[R].
diff --git a/manuals/bc/H.1.md b/manuals/bc/H.1.md
index aa313cd14b63..fbc0658d8171 100644
--- a/manuals/bc/H.1.md
+++ b/manuals/bc/H.1.md
@@ -1433,7 +1433,7 @@ The extended library is a **non-portable extension**.
**frand(p)**
-: Generates a pseudo-random integer between **0** (inclusive) and **1**
+: Generates a pseudo-random number between **0** (inclusive) and **1**
(exclusive) with the number of decimal digits after the decimal point equal
to the truncated absolute value of **p**. If **p** is not **0**, then
calling this function will change the value of **seed**. If **p** is **0**,
@@ -1441,7 +1441,7 @@ The extended library is a **non-portable extension**.
**ifrand(i, p)**
-: Generates a pseudo-random integer that is between **0** (inclusive) and the
+: Generates a pseudo-random number that is between **0** (inclusive) and the
truncated absolute value of **i** (exclusive) with the number of decimal
digits after the decimal point equal to the truncated absolute value of
**p**. If the absolute value of **i** is greater than or equal to **2**, and
diff --git a/manuals/bc/HN.1 b/manuals/bc/HN.1
index 73c243310d5c..7b4577f2dbd3 100644
--- a/manuals/bc/HN.1
+++ b/manuals/bc/HN.1
@@ -25,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.TH "BC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
+.TH "BC" "1" "August 2024" "Gavin D. Howard" "General Commands Manual"
.nh
.ad l
.SH NAME
@@ -1731,7 +1731,7 @@ Functions\f[R] subsection below).
.RE
.TP
\f[B]frand(p)\f[R]
-Generates a pseudo\-random integer between \f[B]0\f[R] (inclusive) and
+Generates a pseudo\-random number between \f[B]0\f[R] (inclusive) and
\f[B]1\f[R] (exclusive) with the number of decimal digits after the
decimal point equal to the truncated absolute value of \f[B]p\f[R].
If \f[B]p\f[R] is not \f[B]0\f[R], then calling this function will
@@ -1740,7 +1740,7 @@ If \f[B]p\f[R] is \f[B]0\f[R], then \f[B]0\f[R] is returned, and
\f[B]seed\f[R] is \f[I]not\f[R] changed.
.TP
\f[B]ifrand(i, p)\f[R]
-Generates a pseudo\-random integer that is between \f[B]0\f[R]
+Generates a pseudo\-random number that is between \f[B]0\f[R]
(inclusive) and the truncated absolute value of \f[B]i\f[R] (exclusive)
with the number of decimal digits after the decimal point equal to the
truncated absolute value of \f[B]p\f[R].
diff --git a/manuals/bc/HN.1.md b/manuals/bc/HN.1.md
index dc537ffe4cfa..015035c14daf 100644
--- a/manuals/bc/HN.1.md
+++ b/manuals/bc/HN.1.md
@@ -1433,7 +1433,7 @@ The extended library is a **non-portable extension**.
**frand(p)**
-: Generates a pseudo-random integer between **0** (inclusive) and **1**
+: Generates a pseudo-random number between **0** (inclusive) and **1**
(exclusive) with the number of decimal digits after the decimal point equal
to the truncated absolute value of **p**. If **p** is not **0**, then
calling this function will change the value of **seed**. If **p** is **0**,
@@ -1441,7 +1441,7 @@ The extended library is a **non-portable extension**.
**ifrand(i, p)**
-: Generates a pseudo-random integer that is between **0** (inclusive) and the
+: Generates a pseudo-random number that is between **0** (inclusive) and the
truncated absolute value of **i** (exclusive) with the number of decimal
digits after the decimal point equal to the truncated absolute value of
**p**. If the absolute value of **i** is greater than or equal to **2**, and
diff --git a/manuals/bc/N.1 b/manuals/bc/N.1
index f66ae06d9c3a..193e0d15f6fb 100644
--- a/manuals/bc/N.1
+++ b/manuals/bc/N.1
@@ -25,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.TH "BC" "1" "January 2024" "Gavin D. Howard" "General Commands Manual"
+.TH "BC" "1" "August 2024" "Gavin D. Howard" "General Commands Manual"
.nh
.ad l
.SH NAME
@@ -1731,7 +1731,7 @@ Functions\f[R] subsection below).
.RE
.TP
\f[B]frand(p)\f[R]
-Generates a pseudo\-random integer between \f[B]0\f[R] (inclusive) and
+Generates a pseudo\-random number between \f[B]0\f[R] (inclusive) and
\f[B]1\f[R] (exclusive) with the number of decimal digits after the
decimal point equal to the truncated absolute value of \f[B]p\f[R].
If \f[B]p\f[R] is not \f[B]0\f[R], then calling this function will
@@ -1740,7 +1740,7 @@ If \f[B]p\f[R] is \f[B]0\f[R], then \f[B]0\f[R] is returned, and
\f[B]seed\f[R] is \f[I]not\f[R] changed.
.TP
\f[B]ifrand(i, p)\f[R]
-Generates a pseudo\-random integer that is between \f[B]0\f[R]
+Generates a pseudo\-random number that is between \f[B]0\f[R]
(inclusive) and the truncated absolute value of \f[B]i\f[R] (exclusive)
with the number of decimal digits after the decimal point equal to the
truncated absolute value of \f[B]p\f[R].
diff --git a/manuals/bc/N.1.md b/manuals/bc/N.1.md
index ad1e603392ae..859c32e3e774 100644
--- a/manuals/bc/N.1.md
+++ b/manuals/bc/N.1.md
@@ -1433,7 +1433,7 @@ The extended library is a **non-portable extension**.
**frand(p)**
-: Generates a pseudo-random integer between **0** (inclusive) and **1**
+: Generates a pseudo-random number between **0** (inclusive) and **1**
(exclusive) with the number of decimal digits after the decimal point equal
to the truncated absolute value of **p**. If **p** is not **0**, then
calling this function will change the value of **seed**. If **p** is **0**,
@@ -1441,7 +1441,7 @@ The extended library is a **non-portable extension**.
**ifrand(i, p)**
-: Generates a pseudo-random integer that is between **0** (inclusive) and the
+: Generates a pseudo-random number that is between **0** (inclusive) and the
truncated absolute value of **i** (exclusive) with the number of decimal
digits after the decimal point equal to the truncated absolute value of
**p**. If the absolute value of **i** is greater than or equal to **2**, and
diff --git a/src/history.c b/src/history.c
index 6ae9785d9a79..32a19f71d777 100644
--- a/src/history.c
+++ b/src/history.c
@@ -264,7 +264,18 @@ bc_history_line(BcHistory* h, BcVec* vec, const char* prompt)
errno = EINTR;
// Get the line.
- while (line == NULL && (len == -1 || errno == EINTR))
+ //
+ // XXX: Why have a macro here? Because macOS needs to be special. Honestly,
+ // it's starting to feel special like Windows at this point. Anyway, the
+ // second SIGWINCH signal of multiple will return a valid line length on
+ // macOS, so we need to allow for that on macOS. However, FreeBSD's editline
+ // is different and will mess up the terminal if we do it that way.
+ //
+ // There is one limitation with this, however: Ctrl+D won't work on macOS.
+ // But it's because of macOS that this problem exists, and I can't really do
+ // anything about it. So macOS should fix their broken editline; once they
+ // do, I'll fix Ctrl+D on macOS.
+ while (BC_HISTORY_INVALID_LINE(line, len))
{
line = el_gets(h->el, &len);
bc_history_use_prompt = false;