summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-12-13 05:42:44 +0000
committerJim Meyering <jim@meyering.net>1994-12-13 05:42:44 +0000
commitbebb9b3286118f2d0779549a8c0b1277c1f134d7 (patch)
treec855c95b967545f2538851084a761664f3776590 /src
parent3ae9a27c258733ca18358b6e647fa19227a75730 (diff)
downloadcoreutils-bebb9b3286118f2d0779549a8c0b1277c1f134d7.tar.xz
(main): Move to end.
(factor, do_stdin): Declare static.
Diffstat (limited to 'src')
-rw-r--r--src/factor.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/src/factor.c b/src/factor.c
index 967799e1c..d7c5e4411 100644
--- a/src/factor.c
+++ b/src/factor.c
@@ -19,27 +19,7 @@
#include <stdio.h>
-void do_stdin ();
-void factor ();
-
-void
-main (argc, argv)
- int argc;
- char **argv;
-{
- if (argc == 1)
- do_stdin ();
- else if (argc == 2)
- factor ((unsigned) atoi (argv[1]));
- else
- {
- fprintf (stderr, "Usage: %s [number]\n", argv[0]);
- exit (1);
- }
- exit (0);
-}
-
-void
+static void
factor (n0)
unsigned long n0;
{
@@ -64,23 +44,42 @@ factor (n0)
{
while (n % d == 0)
{
- printf ("\t%d\n", d);
+ printf ("\t%ld\n", d);
n /= d;
}
}
if (n != 1 || n0 == 1)
- printf ("\t%d\n", n);
+ printf ("\t%ld\n", n);
}
-void
+static void
do_stdin ()
{
char buf[1000];
for (;;)
{
+ /* FIXME: Use getline. */
if (fgets (buf, sizeof buf, stdin) == 0)
exit (0);
+ /* FIXME: Use strtoul. */
factor ((unsigned long) atoi (buf));
}
}
+
+void
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ if (argc == 1)
+ do_stdin ();
+ else if (argc == 2)
+ factor ((unsigned) atoi (argv[1]));
+ else
+ {
+ fprintf (stderr, "Usage: %s [number]\n", argv[0]);
+ exit (1);
+ }
+ exit (0);
+}