[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] fix problem with uconvert
From: |
Isabella Bosia |
Subject: |
Re: [PATCH] fix problem with uconvert |
Date: |
Tue, 25 Oct 2022 07:24:51 +0100 |
Dunno if it's "considerably easier", my patch just added 1 sign argument to
1 function and fixed up a couple of call sites.
Your way is shorter but it boils down to "if the micro-part is negative it
means that the number was in (-1,0)", which for some reason was already
being checked for despite not being possible before.
But regardless, I only care for this to be fixed, not how.
Cheers,
iza
On Mon, 24 Oct 2022, 19:54 Chet Ramey, <chet.ramey@case.edu> wrote:
> On 10/22/22 2:58 PM, izabera wrote:
> > if the argument is in the (-1, 0) range, the integer part is zero and
> > multiplying it by -1 has no effect, so the caller can't tell that the
> > argument was negative
>
> I suggest that a considerably easier way to solve this is
>
> *** ../bash-5.2-patched/lib/sh/uconvert.c 2020-06-04
> 12:28:58.000000000 -0400
> --- lib/sh/uconvert.c 2022-10-24 14:50:15.000000000 -0400
> ***************
> *** 41,45 ****
> do { \
> if (ip) *ip = ipart * mult; \
> ! if (up) *up = upart; \
> if (ep) *ep = p; \
> return (x); \
> --- 41,45 ----
> do { \
> if (ip) *ip = ipart * mult; \
> ! if (up) *up = upart * (ipart == 0 ? mult : 1); \
> if (ep) *ep = p; \
> return (x); \
>
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
>
>