Mail Archives: djgpp-workers/2000/05/22/15:02:04
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 -