bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] fix problem with uconvert


From: Chet Ramey
Subject: Re: [PATCH] fix problem with uconvert
Date: Mon, 24 Oct 2022 14:54:30 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.3

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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]