git: 90ea553a0d30 - stable/14 - vendor/bc: upgrade to version 7.0.2
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Sep 2024 16:34:31 UTC
The branch stable/14 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=90ea553a0d309acc3bdb50a3fe2ed0449c8d7e4c commit 90ea553a0d309acc3bdb50a3fe2ed0449c8d7e4c Author: Stefan Eßer <se@FreeBSD.org> AuthorDate: 2024-09-18 05:55:46 +0000 Commit: Stefan Eßer <se@FreeBSD.org> CommitDate: 2024-09-24 16:33:30 +0000 vendor/bc: upgrade to version 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. Reported by: mack@macktronics.com (cherry picked from commit c2c85f88902d18d2e9702381f1628112e15a5c3c) (cherry picked from commit 9b04aee86ccd58a6f3c936e0cd95bb9305a69848) --- contrib/bc/NEWS.md | 8 ++++++++ contrib/bc/include/history.h | 24 ++++++++++++++++++++++++ contrib/bc/include/version.h | 2 +- contrib/bc/manuals/bc/A.1 | 6 +++--- contrib/bc/manuals/bc/A.1.md | 4 ++-- contrib/bc/manuals/bc/E.1 | 2 +- contrib/bc/manuals/bc/EH.1 | 2 +- contrib/bc/manuals/bc/EHN.1 | 2 +- contrib/bc/manuals/bc/EN.1 | 2 +- contrib/bc/manuals/bc/H.1 | 6 +++--- contrib/bc/manuals/bc/H.1.md | 4 ++-- contrib/bc/manuals/bc/HN.1 | 6 +++--- contrib/bc/manuals/bc/HN.1.md | 4 ++-- contrib/bc/manuals/bc/N.1 | 6 +++--- contrib/bc/manuals/bc/N.1.md | 4 ++-- contrib/bc/src/history.c | 13 ++++++++++++- 16 files changed, 69 insertions(+), 26 deletions(-) diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md index 8156b673ce04..e3b1f9ecb7bc 100644 --- a/contrib/bc/NEWS.md +++ b/contrib/bc/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/contrib/bc/include/history.h b/contrib/bc/include/history.h index 460524bd7b87..13f6dc6e985c 100644 --- a/contrib/bc/include/history.h +++ b/contrib/bc/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/contrib/bc/include/version.h b/contrib/bc/include/version.h index 4d2f6acfb433..a4fb8def5024 100644 --- a/contrib/bc/include/version.h +++ b/contrib/bc/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/contrib/bc/manuals/bc/A.1 b/contrib/bc/manuals/bc/A.1 index 4750598b55fc..adeb62f82e6a 100644 --- a/contrib/bc/manuals/bc/A.1 +++ b/contrib/bc/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/contrib/bc/manuals/bc/A.1.md b/contrib/bc/manuals/bc/A.1.md index 56f7c52fb2cd..e89305b1af44 100644 --- a/contrib/bc/manuals/bc/A.1.md +++ b/contrib/bc/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/contrib/bc/manuals/bc/E.1 b/contrib/bc/manuals/bc/E.1 index 62b18165fe92..e2f1b034e69a 100644 --- a/contrib/bc/manuals/bc/E.1 +++ b/contrib/bc/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/contrib/bc/manuals/bc/EH.1 b/contrib/bc/manuals/bc/EH.1 index 69f28e875990..c132a0b76a49 100644 --- a/contrib/bc/manuals/bc/EH.1 +++ b/contrib/bc/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/contrib/bc/manuals/bc/EHN.1 b/contrib/bc/manuals/bc/EHN.1 index fb453b05363d..e3395b1cc20d 100644 --- a/contrib/bc/manuals/bc/EHN.1 +++ b/contrib/bc/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/contrib/bc/manuals/bc/EN.1 b/contrib/bc/manuals/bc/EN.1 index 4833e3e70ddc..c1ccbec567ec 100644 --- a/contrib/bc/manuals/bc/EN.1 +++ b/contrib/bc/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/contrib/bc/manuals/bc/H.1 b/contrib/bc/manuals/bc/H.1 index 4787435ae052..9dc46ee50dee 100644 --- a/contrib/bc/manuals/bc/H.1 +++ b/contrib/bc/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/contrib/bc/manuals/bc/H.1.md b/contrib/bc/manuals/bc/H.1.md index aa313cd14b63..fbc0658d8171 100644 --- a/contrib/bc/manuals/bc/H.1.md +++ b/contrib/bc/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/contrib/bc/manuals/bc/HN.1 b/contrib/bc/manuals/bc/HN.1 index 73c243310d5c..7b4577f2dbd3 100644 --- a/contrib/bc/manuals/bc/HN.1 +++ b/contrib/bc/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/contrib/bc/manuals/bc/HN.1.md b/contrib/bc/manuals/bc/HN.1.md index dc537ffe4cfa..015035c14daf 100644 --- a/contrib/bc/manuals/bc/HN.1.md +++ b/contrib/bc/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/contrib/bc/manuals/bc/N.1 b/contrib/bc/manuals/bc/N.1 index f66ae06d9c3a..193e0d15f6fb 100644 --- a/contrib/bc/manuals/bc/N.1 +++ b/contrib/bc/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/contrib/bc/manuals/bc/N.1.md b/contrib/bc/manuals/bc/N.1.md index ad1e603392ae..859c32e3e774 100644 --- a/contrib/bc/manuals/bc/N.1.md +++ b/contrib/bc/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/contrib/bc/src/history.c b/contrib/bc/src/history.c index 6ae9785d9a79..32a19f71d777 100644 --- a/contrib/bc/src/history.c +++ b/contrib/bc/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;