random wasn't. now uses integer compare with 0, which does
authorJan-Simon Pendry <pendry@ucbvax.Berkeley.EDU>
Tue, 5 Apr 1994 22:18:40 +0000 (14:18 -0800)
committerJan-Simon Pendry <pendry@ucbvax.Berkeley.EDU>
Tue, 5 Apr 1994 22:18:40 +0000 (14:18 -0800)
SCCS-vsn: games/random/random.c 8.4

usr/src/games/random/random.c

index 2e44bff..32303f5 100644 (file)
@@ -15,7 +15,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)random.c   8.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)random.c   8.4 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -95,7 +95,7 @@ main(argc, argv)
         * 0 (which has a 1 / denom chance of being true), we select the
         * line.
         */
         * 0 (which has a 1 / denom chance of being true), we select the
         * line.
         */
-       selected = !((denom * random()) / LONG_MAX);
+       selected = !(int)((denom * random()) / LONG_MAX);
        while ((ch = getchar()) != EOF) {
                if (selected)
                        (void)putchar(ch);
        while ((ch = getchar()) != EOF) {
                if (selected)
                        (void)putchar(ch);
@@ -105,7 +105,7 @@ main(argc, argv)
                                err(2, "stdout");
 
                        /* Now see if the next line is to be printed. */
                                err(2, "stdout");
 
                        /* Now see if the next line is to be printed. */
-                       selected = !((denom * random()) / LONG_MAX);
+                       selected = !(int)((denom * random()) / LONG_MAX);
                }
        }
        if (ferror(stdin))
                }
        }
        if (ferror(stdin))
@@ -116,6 +116,7 @@ main(argc, argv)
 void
 usage()
 {
 void
 usage()
 {
+
        (void)fprintf(stderr, "usage: random [-er] [denominator]\n");
        exit(1);
 }
        (void)fprintf(stderr, "usage: random [-er] [denominator]\n");
        exit(1);
 }