diff options
Diffstat (limited to 'lib/buffer-lcm.c')
-rw-r--r-- | lib/buffer-lcm.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/buffer-lcm.c b/lib/buffer-lcm.c index c3f6109..44b736e 100644 --- a/lib/buffer-lcm.c +++ b/lib/buffer-lcm.c @@ -1,11 +1,11 @@ /* buffer-lcm.c - compute a good buffer size for dealing with two files - Copyright (C) 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2002-2016 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + 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 - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,11 +13,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Written by Paul Eggert. */ +#include <config.h> #include "buffer-lcm.h" /* Return a buffer size suitable for doing I/O with files whose block @@ -35,22 +35,22 @@ buffer_lcm (size_t a, size_t b, size_t lcm_max) else { if (b) - { - /* Return lcm (A, B) if it is in range; otherwise, fall back - on A. */ - - size_t lcm, m, n, q, r; - - /* N = gcd (A, B). */ - for (m = a, n = b; (r = m % n) != 0; m = n, n = r) - continue; - - /* LCM = lcm (A, B), if in range. */ - q = a / n; - lcm = q * b; - if (lcm <= lcm_max && lcm / b == q) - return lcm; - } + { + /* Return lcm (A, B) if it is in range; otherwise, fall back + on A. */ + + size_t lcm, m, n, q, r; + + /* N = gcd (A, B). */ + for (m = a, n = b; (r = m % n) != 0; m = n, n = r) + continue; + + /* LCM = lcm (A, B), if in range. */ + q = a / n; + lcm = q * b; + if (lcm <= lcm_max && lcm / b == q) + return lcm; + } size = a; } |