diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2015-07-04 17:13:50 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2015-07-04 17:13:50 +0300 |
commit | 71cd8e3a743046573744123777061b64881bf372 (patch) | |
tree | 82522befe647f4fff186a5630cad0cad33f8ef53 /src/make-prime-list.c | |
parent | c18578632fd3c9e513e613a86ba2b7c4ebee6c45 (diff) | |
download | coreutils-upstream.tar.gz |
Imported Upstream version 8.24upstream/8.24upstream
Diffstat (limited to 'src/make-prime-list.c')
-rw-r--r-- | src/make-prime-list.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/make-prime-list.c b/src/make-prime-list.c index c01b1200..0d5b614f 100644 --- a/src/make-prime-list.c +++ b/src/make-prime-list.c @@ -3,7 +3,7 @@ Contributed to the GNU project by Torbjörn Granlund and Niels Möller Contains code from GNU MP. -Copyright 2012-2014 Free Software Foundation, Inc. +Copyright 2012-2015 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 the Free Software @@ -131,7 +131,7 @@ output_primes (const struct prime *primes, unsigned nprimes) abort (); printf ("P (%u, %u,\n (", primes[i].p - p, d8); print_wide_uint (primes[i].pinv, 0, wide_uint_bits); - printf ("),\n UINTMAX_MAX / %d)\n", primes[i].p); + printf ("),\n UINTMAX_MAX / %u)\n", primes[i].p); p = primes[i].p; } @@ -187,7 +187,7 @@ main (int argc, char **argv) } limit = atoi (argv[1]); if (limit < 3) - exit (EXIT_SUCCESS); + return EXIT_SUCCESS; /* Make limit odd */ if ( !(limit & 1)) @@ -211,12 +211,15 @@ main (int argc, char **argv) for (j = (p*p - 3)/2; j < size; j+= p) sieve[j] = 0; - while (i < size && sieve[++i] == 0) + while (++i < size && sieve[i] == 0) ; } output_primes (prime_list, nprimes); + free (sieve); + free (prime_list); + if (ferror (stdout) + fclose (stdout)) { fprintf (stderr, "write error: %s\n", strerror (errno)); |