Commit a3985305 authored by Niels Möller's avatar Niels Möller
Browse files

Whitespace cleanup.

Rev: nettle/examples/eratosthenes.c:1.4
parent 024d5cde
...@@ -3,21 +3,21 @@ ...@@ -3,21 +3,21 @@
* An implementation of the sieve of Eratosthenes, to generate a list of primes. * An implementation of the sieve of Eratosthenes, to generate a list of primes.
* *
*/ */
/* nettle, low-level cryptographics library /* nettle, low-level cryptographics library
* *
* Copyright (C) 2007 Niels Mller * Copyright (C) 2007 Niels Mller
* *
* The nettle library is free software; you can redistribute it and/or modify * The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. * option) any later version.
* *
* The nettle library is distributed in the hope that it will be useful, but * The nettle library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details. * License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to * along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
...@@ -71,7 +71,7 @@ isqrt(unsigned n) ...@@ -71,7 +71,7 @@ isqrt(unsigned n)
x = n; x = n;
else else
/* Must avoid overflow in the first step. */ /* Must avoid overflow in the first step. */
x = n-1; x = n-1;
for (;;) for (;;)
{ {
...@@ -90,7 +90,7 @@ vector_alloc(unsigned size) ...@@ -90,7 +90,7 @@ vector_alloc(unsigned size)
unsigned end = (size + BITS_PER_LONG - 1) / BITS_PER_LONG; unsigned end = (size + BITS_PER_LONG - 1) / BITS_PER_LONG;
unsigned i; unsigned i;
unsigned long *vector = malloc (end * sizeof(long)); unsigned long *vector = malloc (end * sizeof(long));
if (!vector) if (!vector)
return NULL; return NULL;
...@@ -120,14 +120,14 @@ find_first_one (unsigned long x) ...@@ -120,14 +120,14 @@ find_first_one (unsigned long x)
unsigned table[0x10] = unsigned table[0x10] =
{ {
/* 0, 1, 2, 3, 4, 5, 6, 7 */ /* 0, 1, 2, 3, 4, 5, 6, 7 */
-1, 0, 1, 0, 2, 0, 1 , 0, -1, 0, 1, 0, 2, 0, 1 , 0,
/* 8, 9, 10, 11, 12, 13, 14, 15 */ /* 8, 9, 10, 11, 12, 13, 14, 15 */
3, 0, 1, 0, 2, 0, 1, 0 3, 0, 1, 0, 2, 0, 1, 0
}; };
/* Isolate least significant bit */ /* Isolate least significant bit */
x &= -x; x &= -x;
unsigned i = 0; unsigned i = 0;
#if NEED_HANDLE_LARGE_LONG #if NEED_HANDLE_LARGE_LONG
#ifndef SIZEOF_LONG #ifndef SIZEOF_LONG
...@@ -253,10 +253,10 @@ main (int argc, char **argv) ...@@ -253,10 +253,10 @@ main (int argc, char **argv)
struct output_info info; struct output_info info;
int quiet; int quiet;
int c; int c;
enum { FLAG_ODD = -100, FLAG_PRIME, FLAG_DIFF, FLAG_TABULAR, enum { FLAG_ODD = -100, FLAG_PRIME, FLAG_DIFF, FLAG_TABULAR,
FLAG_QUIET, FLAG_BLOCK }; FLAG_QUIET, FLAG_BLOCK };
static const struct option options[] = static const struct option options[] =
{ {
/* Name, args, flag, val */ /* Name, args, flag, val */
...@@ -274,7 +274,7 @@ main (int argc, char **argv) ...@@ -274,7 +274,7 @@ main (int argc, char **argv)
quiet = 0; quiet = 0;
block_size = 0; block_size = 0;
while ( (c = getopt_long(argc, argv, "?", options, NULL)) != -1) while ( (c = getopt_long(argc, argv, "?", options, NULL)) != -1)
switch (c) switch (c)
{ {
...@@ -349,11 +349,11 @@ main (int argc, char **argv) ...@@ -349,11 +349,11 @@ main (int argc, char **argv)
return EXIT_SUCCESS; return EXIT_SUCCESS;
sieve_limit = (isqrt(2*block_size + 1) - 1) / 2; sieve_limit = (isqrt(2*block_size + 1) - 1) / 2;
while (bit < sieve_limit) while (bit < sieve_limit)
{ {
unsigned n = 3 + 2 * bit; unsigned n = 3 + 2 * bit;
output(&info, n); output(&info, n);
prime_count++; prime_count++;
...@@ -399,7 +399,7 @@ main (int argc, char **argv) ...@@ -399,7 +399,7 @@ main (int argc, char **argv)
start = bit + k*n; start = bit + k*n;
} }
vector_clear_bits (vector, n, start, block + block_size); vector_clear_bits (vector, n, start, block + block_size);
bit = vector_find_next (vector, bit + 1, block + block_size); bit = vector_find_next (vector, bit + 1, block + block_size);
} }
for (bit = vector_find_next (vector, block, block + block_size); for (bit = vector_find_next (vector, block, block + block_size);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment