X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fimaxdiv.c;h=4e23478f6269f3ffdca0d16d8be987efd9aaafd9;hb=1184458d513a6fe25c609fe642d1ccf8c159ac00;hp=81e7d80022d5daf67000aab36c3f32f2ff2ba376;hpb=57fdfd3f8ec62b105c53bcdf6f127c35c7fe7391;p=gnulib.git diff --git a/lib/imaxdiv.c b/lib/imaxdiv.c index 81e7d8002..4e23478f6 100644 --- a/lib/imaxdiv.c +++ b/lib/imaxdiv.c @@ -1,5 +1,5 @@ /* imaxdiv() function: division of 'intmax_t'. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,28 +35,28 @@ imaxdiv (intmax_t numer, intmax_t denom) often called "truncation toward zero".) If the quotient a/b is representable, the expression (a/b)*b + a%b shall equal a." */ if (!(denom == 0 - || (INTMAX_MIN + INTMAX_MAX < 0 - && denom == -1 - && numer < - INTMAX_MAX))) + || (INTMAX_MIN + INTMAX_MAX < 0 + && denom == -1 + && numer < - INTMAX_MAX))) { if (!(result.quot * denom + result.rem == numer)) - /* The compiler's implementation of / and % is broken. */ - abort (); + /* The compiler's implementation of / and % is broken. */ + abort (); if (!(numer >= 0 - ? result.rem >= 0 - && (denom >= 0 - ? result.rem < denom - : /* Don't write result.rem < - denom, - as it gives integer overflow if denom == INTMAX_MIN. */ - - result.rem > denom) - : result.rem <= 0 - && (denom >= 0 - ? result.rem > - denom - : result.rem > denom))) - /* The compiler's implementation of / and % may be ok according to - C89, but not to C99. Please report this to . - This might be a big portability problem. */ - abort (); + ? result.rem >= 0 + && (denom >= 0 + ? result.rem < denom + : /* Don't write result.rem < - denom, + as it gives integer overflow if denom == INTMAX_MIN. */ + - result.rem > denom) + : result.rem <= 0 + && (denom >= 0 + ? result.rem > - denom + : result.rem > denom))) + /* The compiler's implementation of / and % may be ok according to + C89, but not to C99. Please report this to . + This might be a big portability problem. */ + abort (); } return result;