[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "-M" option does not work with "+" "-" characters
From: |
arnold |
Subject: |
Re: "-M" option does not work with "+" "-" characters |
Date: |
Sun, 05 Jul 2020 11:56:45 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Hyunho Cho<mug896@naver.com> wrote:
> ### with "-M" option "+" "-" characters do not print
And also the earlier report about switch/case.
Thanks for the reports. The patch below fixes both issues.
Arnold
-------------------------------------------
diff --git a/mpfr.c b/mpfr.c
index e1712863..be2b81b5 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -293,6 +293,14 @@ force_mpnum(NODE *n, int do_nondec, int use_locale)
else
cp1 = cp;
+ /*
+ * Maybe "+" or "-" was the field. mpg_strtoui
+ * won't check for that and set errno, so we have
+ * to check manually.
+ */
+ if (*cp1 == '\0')
+ return false;
+
if (do_nondec)
base = get_numbase(cp1, cpend - cp1, use_locale);
diff --git a/node.c b/node.c
index bcb9a4a5..04a90adc 100644
--- a/node.c
+++ b/node.c
@@ -316,11 +316,13 @@ r_dupnode(NODE *n)
r = mpg_integer();
mpz_set(r->mpg_i, n->mpg_i);
r->flags = n->flags;
+ r->strndmode = MPFR_round_mode;
} else if ((n->flags & MPFN) != 0) {
r = mpg_float();
int tval = mpfr_set(r->mpg_numbr, n->mpg_numbr, ROUND_MODE);
IEEE_FMT(r->mpg_numbr, tval);
r->flags = n->flags;
+ r->strndmode = MPFR_round_mode;
} else {
#endif
getnode(r);
@@ -343,6 +345,7 @@ r_dupnode(NODE *n)
emalloc(r->stptr, char *, n->stlen + 1, "r_dupnode");
memcpy(r->stptr, n->stptr, n->stlen);
r->stptr[n->stlen] = '\0';
+ r->stlen = n->stlen;
if ((n->flags & WSTRCUR) != 0) {
r->wstlen = n->wstlen;
emalloc(r->wstptr, wchar_t *, sizeof(wchar_t) *
(n->wstlen + 1), "r_dupnode");