pgen/pfilt: Special cases for primality checking.
[u/mdw/catacomb] / pfilt.c
diff --git a/pfilt.c b/pfilt.c
index 7f44569..e502404 100644 (file)
--- a/pfilt.c
+++ b/pfilt.c
@@ -59,7 +59,9 @@ static int smallenough(mp *m)
     max = mp_sqr(max, max);
     max->a->n--; /* Permanent allocation */
   }
-  if (MP_CMP(m, <, max))
+  if (MP_CMP(m, <=, MP_ONE))
+    rc = PGEN_FAIL;
+  else if (MP_CMP(m, <, max))
     rc = PGEN_DONE;
   return (rc);
 }
@@ -91,6 +93,7 @@ int pfilt_smallfactor(mp *m)
        rc = PGEN_DONE;
       else
        rc = PGEN_FAIL;
+      break;
     }
   }