]> git.sur5r.net Git - cc65/blobdiff - samples/sieve.c
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / samples / sieve.c
index a82e972c9d1620a6578ea91b8b380784e3bb2968..9ecbab02052b5971b7495255bd322f412c4db644 100644 (file)
 
 /* Workaround missing clock stuff */
 #if defined(__APPLE2__) || defined(__APPLE2ENH__)
-#  define clock()              0
-#  define CLOCKS_PER_SEC       1
+#  define clock()               0
+#  define CLOCKS_PER_SEC        1
 #endif
 
 
 
 /*****************************************************************************/
-/*                                          Data                                    */
+/*                                   Data                                    */
 /*****************************************************************************/
 
 
 
-#define COUNT          16384           /* Up to what number? */
-#define SQRT_COUNT     128             /* Sqrt of COUNT */
+#define COUNT           16384           /* Up to what number? */
+#define SQRT_COUNT      128             /* Sqrt of COUNT */
 
 static unsigned char Sieve[COUNT];
 
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -59,8 +59,8 @@ int main (void)
 
     /* This is an example where register variables make sense */
     register unsigned char* S;
-    register unsigned      I;
-    register unsigned      J;
+    register unsigned       I;
+    register unsigned       J;
 
     /* Output a header */
     printf ("Sieve benchmark - calculating primes\n");
@@ -73,17 +73,17 @@ int main (void)
     /* Execute the sieve */
     I = 2;
     while (I < SQRT_COUNT) {
-       if (Sieve[I] == 0) {
-           /* Prime number - mark multiples */
+        if (Sieve[I] == 0) {
+            /* Prime number - mark multiples */
             J = I*2;
-           S = &Sieve[J];
-                   while (J < COUNT) {
-               *S = 1;
-               S += I;
-               J += I;
-           }
-       }
-       ++I;
+            S = &Sieve[J];
+            while (J < COUNT) {
+                *S = 1;
+                S += I;
+                J += I;
+            }
+        }
+        ++I;
     }
 
     /* Calculate the time used */
@@ -97,11 +97,11 @@ int main (void)
 
     /* Wait for a key and print the list if not 'Q' */
     if (ReadUpperKey () != 'Q') {
-       /* Print the result */
+        /* Print the result */
         J = 0;
-       for (I = 2; I < COUNT; ++I) {
-           if (Sieve[I] == 0) {
-               printf ("%4d\n", I);
+        for (I = 2; I < COUNT; ++I) {
+            if (Sieve[I] == 0) {
+                printf ("%4d\n", I);
                 if (++J == 23) {
                     printf ("Q to quit, any other key continues\n");
                     if (ReadUpperKey () == 'Q') {
@@ -109,11 +109,11 @@ int main (void)
                     }
                     J = 0;
                 }
-           }
-                   if (kbhit() && ReadUpperKey == 'Q') {
-               break;
-           }
-       }
+            }
+            if (kbhit() && ReadUpperKey == 'Q') {
+                break;
+            }
+        }
     }
 
     return EXIT_SUCCESS;