More changes. Still embryonic.
[u/mdw/catacomb] / lcrand.c
index 3686e17..88e9591 100644 (file)
--- a/lcrand.c
+++ b/lcrand.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: lcrand.c,v 1.1 1999/12/10 23:15:27 mdw Exp $
+ * $Id: lcrand.c,v 1.2 1999/12/13 15:34:01 mdw Exp $
  *
  * Simple linear congruential generator
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: lcrand.c,v $
+ * Revision 1.2  1999/12/13 15:34:01  mdw
+ * Add support for seeding from a generic pseudorandom source.
+ *
  * Revision 1.1  1999/12/10 23:15:27  mdw
  * Noncryptographic random number generator.
  *
@@ -201,6 +204,7 @@ static int gmisc(grand *r, unsigned op, ...)
        case GRAND_CHECK:
        case GRAND_SEEDINT:
        case GRAND_SEEDUINT32:
+       case GRAND_SEEDRAND:
          rc = 1;
          break;
        default:
@@ -214,6 +218,12 @@ static int gmisc(grand *r, unsigned op, ...)
     case GRAND_SEEDUINT32:
       g->x = va_arg(ap, uint32);
       break;
+    case GRAND_SEEDRAND: {
+      grand *rr = va_arg(ap, grand *);
+      uint32 x;
+      do x = rr->ops->word(rr); while (x >= P || x == LCRAND_FIXEDPT);
+      g->x = x;
+    } break;
     default:
       GRAND_BADOP;
       break;