delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/05/22/15:02:04

Message-Id: <200005221901.PAA30815@delorie.com>
From: "Dieter Buerssner" <buers AT gmx DOT de>
To: djgpp-workers AT delorie DOT com
Date: Mon, 22 May 2000 21:06:55 +0200
MIME-Version: 1.0
Subject: Re: Bug 314
In-reply-to: <392937F4.B78491A5@cyberoptics.com>
X-mailer: Pegasus Mail for Win32 (v3.12b)
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 22 May 00, at 8:36, Eric Rudd wrote:

> I have done my own testing, and believe that these modified routines now conform
> to the requirements of ANSI, but I would appreciate it if someone else took a
> look at the code and verified that the new code is indeed correct.

The patch seems correct.

BTW. Have you sent the same patch twice, or do I need some glasses?
I think, the same patch is needed for ldiv and lldiv. Perhaps you 
wanted to sen those.

*** src/libc/ansi/stdlib/ldiv.old	Sat Dec 10 22:34:08 1994
--- src/libc/ansi/stdlib/ldiv.c	Mon May 22 21:02:06 2000
***************
*** 1,4 ****
! /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  #include <stdlib.h>
  
  ldiv_t
--- 1,4 ----
! /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
  #include <stdlib.h>
  
  ldiv_t
***************
*** 6,25 ****
  {
    ldiv_t r;
  
-   if (num > 0 && denom < 0)
-   {
-     num = -num;
-     denom = -denom;
-   }
-   r.quot = num / denom;
    r.rem = num % denom;
!   if (num < 0 && denom > 0)
!   {
!     if (r.rem > 0)
!     {
!       r.quot++;
!       r.rem -= denom;
!     }
!   }
    return r;
  }
--- 6,12 ----
  {
    ldiv_t r;
  
    r.rem = num % denom;
!   r.quot = num / denom;
    return r;
  }
*** src/libc/ansi/stdlib/lldiv.old	Sat May 18 14:53:42 1996
--- src/libc/ansi/stdlib/lldiv.c	Mon May 22 21:02:18 2000
***************
*** 1,4 ****
! /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  #include <stdlib.h>
  
--- 1,4 ----
! /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  #include <stdlib.h>
  
***************
*** 7,26 ****
  {
    lldiv_t r;
  
-   if (num > 0 && denom < 0)
-   {
-     num = -num;
-     denom = -denom;
-   }
-   r.quot = num / denom;
    r.rem = num % denom;
!   if (num < 0 && denom > 0)
!   {
!     if (r.rem > 0)
!     {
!       r.quot++;
!       r.rem -= denom;
!     }
!   }
    return r;
  }
--- 7,13 ----
  {
    lldiv_t r;
  
    r.rem = num % denom;
!   r.quot = num / denom;
    return r;
  }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019