summaryrefslogtreecommitdiffstats
path: root/factor
diff options
context:
space:
mode:
authorlukem <lukem@NetBSD.org>1997-10-10 12:49:45 +0000
committerlukem <lukem@NetBSD.org>1997-10-10 12:49:45 +0000
commit01f8d1db18471a5d88884cc54ab794ba91fd75ac (patch)
tree0adc24f4731925c6b0f09b90324461dadc2f5398 /factor
parent4af35eddcd99b72236d11e2354dd8fcd3b9f6e74 (diff)
downloadbsdgames-darwin-01f8d1db18471a5d88884cc54ab794ba91fd75ac.tar.gz
bsdgames-darwin-01f8d1db18471a5d88884cc54ab794ba91fd75ac.tar.zst
bsdgames-darwin-01f8d1db18471a5d88884cc54ab794ba91fd75ac.zip
WARNSify
Diffstat (limited to 'factor')
-rw-r--r--factor/factor.614
-rw-r--r--factor/factor.c13
2 files changed, 14 insertions, 13 deletions
diff --git a/factor/factor.6 b/factor/factor.6
index d21be552..8740314b 100644
--- a/factor/factor.6
+++ b/factor/factor.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: factor.6,v 1.4 1995/03/23 08:28:05 cgd Exp $
+.\" $NetBSD: factor.6,v 1.5 1997/10/10 12:51:27 lukem Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -50,14 +50,14 @@
.Nd
factor a number, generate primes
.Sh SYNOPSIS
-.Nm factor
+.Nm
.Op Ar number ...
.br
.Nm primes
.Op Ar start Op Ar stop
.Sh DESCRIPTION
The
-.Nm factor
+.Nm
utility will factor integers between -2147483648 and 2147483647 inclusive.
When a number is factored, it is printed, followed by a
.Dq \: ,
@@ -67,14 +67,14 @@ If a factor divides a value more than once, it will be printed
more than once.
.Pp
When
-.Nm factor
+.Nm
is invoked with one or more arguments,
each argument will be factored.
.Pp
When
-.Nm factor
+.Nm
is invoked with no arguments,
-.Nm factor
+.Nm
reads numbers, one per line, from standard input, until end of file or error.
Leading white-space and empty lines are ignored.
Numbers may be preceded by a single - or +.
@@ -118,7 +118,7 @@ Out of range or invalid input results in
.Sq ouch
being written to standard error.
.Sh BUGS
-.Nm Factor
+.Nm
cannot handle the
.Dq 10 most wanted
factor list,
diff --git a/factor/factor.c b/factor/factor.c
index 051188ea..a0febe27 100644
--- a/factor/factor.c
+++ b/factor/factor.c
@@ -1,4 +1,4 @@
-/* $NetBSD: factor.c,v 1.6 1997/01/07 12:05:10 tls Exp $ */
+/* $NetBSD: factor.c,v 1.7 1997/10/10 12:51:32 lukem Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -36,17 +36,17 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)factor.c 8.4 (Berkeley) 5/4/95";
#else
-static char rcsid[] = "$NetBSD: factor.c,v 1.6 1997/01/07 12:05:10 tls Exp $";
+__RCSID("$NetBSD: factor.c,v 1.7 1997/10/10 12:51:32 lukem Exp $");
#endif
#endif /* not lint */
@@ -88,6 +88,7 @@ static char rcsid[] = "$NetBSD: factor.c,v 1.6 1997/01/07 12:05:10 tls Exp $";
extern ubig prime[];
extern ubig *pr_limit; /* largest prime in the prime array */
+int main __P((int, char *[]));
void pr_fact __P((ubig)); /* print factors of a value */
void usage __P((void));
@@ -100,7 +101,7 @@ main(argc, argv)
int ch;
char *p, buf[100]; /* > max number of digits. */
- while ((ch = getopt(argc, argv, "")) != EOF)
+ while ((ch = getopt(argc, argv, "")) != -1)
switch (ch) {
case '?':
default: